# Let the messenge from MQTT to dashboard

**URL:** <https://discourse.nodered.org/t/let-the-messenge-from-mqtt-to-dashboard/62611>\
**Category:** General\
**Tags:** database, function-node\
**Created:** [14 May 2022 05:55 UTC](https://discourse.nodered.org/t/let-the-messenge-from-mqtt-to-dashboard/62611 "2022-05-14T05:55:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![andy0129](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@andy0129](https://discourse.nodered.org/u/andy0129)\
**Post date:** [14 May 2022 05:55 UTC](https://discourse.nodered.org/t/let-the-messenge-from-mqtt-to-dashboard/62611/1 "2022-05-14T05:55:07Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/d/0d1e7c962b600fc33cb73d892c386d12bf6d49df.png)

```auto
[
    {
        "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
    }
]

```

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [14 May 2022 06:16 UTC](https://discourse.nodered.org/t/let-the-messenge-from-mqtt-to-dashboard/62611/2 "2022-05-14T06:16:38Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [14 May 2022 07:50 UTC](https://discourse.nodered.org/t/let-the-messenge-from-mqtt-to-dashboard/62611/3 "2022-05-14T07:50:44Z")

</div>

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

 ![chrome_screenshot_1652514360297](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/3/43299241f93e7d2bdc2f0c035782d0e079bc70ea.jpeg)  
and set the mqtt in node to a parsed json object  
 ![chrome_screenshot_1652514816866](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/0/b0b39648d08161275fa8e6bf4a188473390213cb.png)

---

<div class="post-metadata">

**Author:** ![andy0129](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@andy0129](https://discourse.nodered.org/u/andy0129)\
**Post date:** [14 May 2022 08:21 UTC](https://discourse.nodered.org/t/let-the-messenge-from-mqtt-to-dashboard/62611/4 "2022-05-14T08:21:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [28 May 2022 08:22 UTC](https://discourse.nodered.org/t/let-the-messenge-from-mqtt-to-dashboard/62611/5 "2022-05-28T08:22:34Z")

</div>

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