Let the messenge from MQTT to dashboard

Hello
I am new to Node-red ,me and my partner use MQTT send a vumerical value to Node-RED and we want to let the numerical value show on dashboard.
But dashboard doesn't display normally
What should we type in the function to make JSON to num and then it work properly

Thank you guys
Here is my Dashboard problem
image

[
    {
        "id": "f9fe2c2f01e99be8",
        "type": "tab",
        "label": "流程1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "e535daf2d4fb1eb0",
        "type": "mqtt in",
        "z": "f9fe2c2f01e99be8",
        "name": "",
        "topic": "voice",
        "qos": "2",
        "datatype": "auto",
        "broker": "a4935c13259d9e5d",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 230,
        "y": 220,
        "wires": [
            [
                "c454898996b32641",
                "4373f8d70e343e80"
            ]
        ]
    },
    {
        "id": "c454898996b32641",
        "type": "function",
        "z": "f9fe2c2f01e99be8",
        "name": "",
        "func": "obj= JSON.parse(msg.payload);\nlet val= obj.sensorValue;\nmsg.topic = `insert into sensorvalue.value(sensorValue) VALUES (${val})`;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 350,
        "y": 360,
        "wires": [
            [
                "ace86d2a958a4fd1"
            ]
        ]
    },
    {
        "id": "0ec410b85991ab2a",
        "type": "debug",
        "z": "f9fe2c2f01e99be8",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 830,
        "y": 360,
        "wires": []
    },
    {
        "id": "ace86d2a958a4fd1",
        "type": "mysql",
        "z": "f9fe2c2f01e99be8",
        "mydb": "fb4ddc1302d2bf5b",
        "name": "",
        "x": 600,
        "y": 420,
        "wires": [
            [
                "0ec410b85991ab2a"
            ]
        ]
    },
    {
        "id": "4373f8d70e343e80",
        "type": "ui_gauge",
        "z": "f9fe2c2f01e99be8",
        "name": "",
        "group": "2ef1b540c7ab0e2e",
        "order": 0,
        "width": 0,
        "height": 0,
        "gtype": "gage",
        "title": "gauge",
        "label": "units",
        "format": "{{value}}",
        "min": 0,
        "max": "500",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "className": "",
        "x": 620,
        "y": 200,
        "wires": []
    },
    {
        "id": "a4935c13259d9e5d",
        "type": "mqtt-broker",
        "name": "",
        "broker": "192.168.68.57",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "2",
        "birthRetain": "true",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    },
    {
        "id": "fb4ddc1302d2bf5b",
        "type": "MySQLdatabase",
        "name": "",
        "host": "localhost",
        "port": "3306",
        "db": "sensorvalue",
        "tz": "",
        "charset": "UTF8"
    },
    {
        "id": "2ef1b540c7ab0e2e",
        "type": "ui_group",
        "name": "Default",
        "tab": "5e5688de16969c96",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "5e5688de16969c96",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

First of all... Welcome to the forum.

I think we need more details from you in order to give you a sensible response.
Can you explain what is not working on the Dashboard?
Can you share the Node-RED flow you have created so far?

You can change the {{value}} to {{payload.sensorValue}}


and set the mqtt in node to a parsed json object

1 Like

Thank you for helping me solve such a simple problem Thanks a lot

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.