Help For New User

I am just starting to use MQTT and Node Red as an introduction to IOT and Home Automation, and having some basic issues.
Background is as an initial experiment I have a BMP280 connected to a Tasmota device (Wemos D1 MiniD1) and communicating with MQTT on an RPI 4b. I can see from debug nodes in Node Red that the message is getting through MQTT but I can't get Temperature and Pressure to display on the dashboard. The gauges are being displayed, but the Pressure and Temperature values are not being extracted by the Change nodes, so this is where I assume I am going wrong.

I believe I am making a very fundamental and simple mistake, but due to my lack of knowledge and experience, I can't see what I am doing wrong, so I would appreciate some guidance. The flow is as per the enclosed text, and I have added an inject node on the Temperature Flow to simulate the output of MQTT.

Any suggestion on what I need to do to correct the issue would be greatly appreciated.

Regards,
Dave

[{"id":"cbf4fba7.b2a9a8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"d883ab46.b52778","type":"mqtt in","z":"cbf4fba7.b2a9a8","name":"","topic":"tele/House/LoungeRoom/SENSOR","qos":"0","datatype":"auto","broker":"4dfa2901.da50e8","x":210,"y":80,"wires":[["c0cf8123.0ed54","b46ffcb5.0bfca","40d862e0.7d2bec"]],"outputLabels":["Temperature"]},{"id":"2b749042.1fc83","type":"debug","z":"cbf4fba7.b2a9a8","name":"Temperature","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":570,"y":240,"wires":[]},{"id":"c0cf8123.0ed54","type":"change","z":"cbf4fba7.b2a9a8","name":"Extract Pressure","rules":[{"t":"set","p":"payload","pt":"msg","to":"data.Pressure","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":40,"wires":[["f477510c.d9536","ec5005b8.1b4b38"]]},{"id":"f477510c.d9536","type":"debug","z":"cbf4fba7.b2a9a8","name":"Pressure","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":620,"y":20,"wires":[]},{"id":"ec5005b8.1b4b38","type":"ui_gauge","z":"cbf4fba7.b2a9a8","name":"Baro Pressure","group":"a70772f8.5b41e","order":3,"width":0,"height":0,"gtype":"gage","title":"Pressure","label":"hPa","format":"{{value}}","min":"970","max":"1030","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":830,"y":80,"wires":[]},{"id":"512caced.dc6ec4","type":"ui_gauge","z":"cbf4fba7.b2a9a8","name":"","group":"a70772f8.5b41e","order":1,"width":0,"height":0,"gtype":"gage","title":"Temperature","label":"Deg C","format":"{{value}}","min":0,"max":"30","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":800,"y":180,"wires":[]},{"id":"b46ffcb5.0bfca","type":"change","z":"cbf4fba7.b2a9a8","name":"Extract Temperature","rules":[{"t":"set","p":"payload","pt":"msg","to":"data.\"Temperature\":","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":160,"wires":[["512caced.dc6ec4","2b749042.1fc83"]]},{"id":"40d862e0.7d2bec","type":"debug","z":"cbf4fba7.b2a9a8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":480,"y":100,"wires":[]},{"id":"68387582.8a605c","type":"inject","z":"cbf4fba7.b2a9a8","name":"","topic":"","payload":"tele/House/LoungeRoom/SENSOR : msg.payload : string[114] \"{\"Time\":\"2020-08-02T07:42:23\",\"BMP280\":{\"Temperature\":15.1,\"Pressure\":1017.9},\"PressureUnit\":\"hPa\",\"TempUnit\":\"C\"}\"","payloadType":"str","repeat":"5","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":180,"wires":[["b46ffcb5.0bfca"]]},{"id":"4dfa2901.da50e8","type":"mqtt-broker","z":"","name":"","broker":"192.168.0.44","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"a70772f8.5b41e","type":"ui_group","z":"","name":"tele/House/LoungeRoom/SENSOR","tab":"2773783e.d03e88","order":1,"disp":false,"width":"6","collapse":false},{"id":"2773783e.d03e88","type":"ui_tab","z":"","name":"Current","icon":"dashboard"}]

I cannot read your flow- Here is what I do from a BME680.

In the .ino file I write the sensor data to mqtt:

void sendBME680Data() {
  String topic = String(mqtt_topic);
  String info =
    String("{\"temperature\":{\"value\":") + String(bme.temperature, 2) +
    String(",\"unit\":\"degC\"}") +
    String(",\"pressure\":{\"value\":") + String(bme.pressure/100.0, 1) +
    String(",\"unit\":\"hPa\"}") +
    String(",\"humidity\":{\"value\":") + String(bme.humidity, 1) +
    String(",\"unit\":\"%\"}") +
    String(",\"gas_resistance\":{\"value\":") + String(bme.gas_resistance) +
    String(",\"unit\":\"Ohm\"}}");
  if (!client.publish(topic.c_str(), info.c_str())) {
    Serial.println("MQTT publish failed");
  }
}

then the flow:

[
    {
        "id": "80d23a4.05fb2c8",
        "type": "ui_gauge",
        "z": "7ffc2d8b.308ee4",
        "name": "Trykk",
        "group": "772cd93a.a08b78",
        "order": 1,
        "width": "4",
        "height": "3",
        "gtype": "gage",
        "title": "Trykk",
        "label": "hPa",
        "format": "{{value}}",
        "min": "925",
        "max": "1075",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "x": 750,
        "y": 402,
        "wires": []
    },
    {
        "id": "62d15a62.1ff704",
        "type": "ui_gauge",
        "z": "7ffc2d8b.308ee4",
        "name": "Temperatur",
        "group": "772cd93a.a08b78",
        "order": 2,
        "width": "4",
        "height": "3",
        "gtype": "gage",
        "title": "Temp",
        "label": "⁰C",
        "format": "{{value}}",
        "min": "-20",
        "max": "50",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "x": 771,
        "y": 439,
        "wires": []
    },
    {
        "id": "1aed2ae1.47df75",
        "type": "ui_gauge",
        "z": "7ffc2d8b.308ee4",
        "name": "Fuktighet",
        "group": "772cd93a.a08b78",
        "order": 3,
        "width": "4",
        "height": "3",
        "gtype": "wave",
        "title": "Fukt",
        "label": "%",
        "format": "{{value}}",
        "min": 0,
        "max": "100",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "x": 763,
        "y": 474,
        "wires": []
    },
    {
        "id": "86fe8dfd.fe843",
        "type": "ui_chart",
        "z": "7ffc2d8b.308ee4",
        "name": "",
        "group": "772cd93a.a08b78",
        "order": 4,
        "width": 0,
        "height": 0,
        "label": "Gas",
        "chartType": "line",
        "legend": "false",
        "xformat": "auto",
        "interpolate": "step",
        "nodata": "",
        "dot": false,
        "ymin": "0",
        "ymax": "1000000",
        "removeOlder": "52",
        "removeOlderPoints": "1000",
        "removeOlderUnit": "604800",
        "cutout": 0,
        "useOneColor": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "useOldStyle": false,
        "x": 754,
        "y": 512,
        "wires": [
            [],
            []
        ]
    },
    {
        "id": "a8b0ec9.5acd11",
        "type": "mqtt in",
        "z": "7ffc2d8b.308ee4",
        "name": "",
        "topic": "BME680",
        "qos": "2",
        "broker": "bac4dabb.70bda8",
        "x": 160,
        "y": 423,
        "wires": [
            [
                "53180dc6.a88044"
            ]
        ]
    },
    {
        "id": "53180dc6.a88044",
        "type": "json",
        "z": "7ffc2d8b.308ee4",
        "name": "to object",
        "property": "payload",
        "action": "obj",
        "pretty": false,
        "x": 331,
        "y": 423,
        "wires": [
            [
                "6a267a68.0084e4"
            ]
        ]
    },
    {
        "id": "6a267a68.0084e4",
        "type": "function",
        "z": "7ffc2d8b.308ee4",
        "name": "Split Bme680 sensor",
        "func": "return [msg.payload.temperature,\n        msg.payload.pressure,\n        msg.payload.humidity,\n        {payload:msg.payload.gas_resistance.value}];",
        "outputs": 4,
        "noerr": 0,
        "x": 530,
        "y": 460,
        "wires": [
            [
                "62d15a62.1ff704"
            ],
            [
                "80d23a4.05fb2c8"
            ],
            [
                "1aed2ae1.47df75"
            ],
            []
        ]
    },
    {
        "id": "772cd93a.a08b78",
        "type": "ui_group",
        "z": "",
        "name": "Bme680",
        "tab": "42d2cd56.806a04",
        "order": 3,
        "disp": true,
        "width": "12",
        "collapse": true
    },
    {
        "id": "bac4dabb.70bda8",
        "type": "mqtt-broker",
        "z": "",
        "name": "Mqtt",
        "broker": "moxon",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    },
    {
        "id": "42d2cd56.806a04",
        "type": "ui_tab",
        "z": "",
        "name": "Home",
        "icon": "dashboard",
        "order": 2
    }
]

which look like this

I guess you can do something similar.

Please export your flow again, this time, use the </> icon and post your flow inside the backticks.

Also post the debug output (make sure to set the debug node to complete msg object)

Apologies for the delayed response - some distractions!

This is the flow:

[{"id":"cbf4fba7.b2a9a8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"d883ab46.b52778","type":"mqtt in","z":"cbf4fba7.b2a9a8","name":"","topic":"tele/House/LoungeRoom/SENSOR","qos":"0","datatype":"auto","broker":"4dfa2901.da50e8","x":210,"y":80,"wires":[["c0cf8123.0ed54","b46ffcb5.0bfca","40d862e0.7d2bec"]],"outputLabels":["Temperature"]},{"id":"2b749042.1fc83","type":"debug","z":"cbf4fba7.b2a9a8","name":"Temperature","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":570,"y":240,"wires":[]},{"id":"c0cf8123.0ed54","type":"change","z":"cbf4fba7.b2a9a8","name":"Extract Pressure","rules":[{"t":"set","p":"payload","pt":"msg","to":"data.Pressure","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":40,"wires":[["f477510c.d9536","ec5005b8.1b4b38"]]},{"id":"f477510c.d9536","type":"debug","z":"cbf4fba7.b2a9a8","name":"Pressure","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":620,"y":20,"wires":[]},{"id":"ec5005b8.1b4b38","type":"ui_gauge","z":"cbf4fba7.b2a9a8","name":"Baro Pressure","group":"a70772f8.5b41e","order":3,"width":0,"height":0,"gtype":"gage","title":"Pressure","label":"hPa","format":"{{value}}","min":"970","max":"1030","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":830,"y":80,"wires":[]},{"id":"512caced.dc6ec4","type":"ui_gauge","z":"cbf4fba7.b2a9a8","name":"","group":"a70772f8.5b41e","order":1,"width":0,"height":0,"gtype":"gage","title":"Temperature","label":"Deg C","format":"{{value}}","min":0,"max":"30","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":800,"y":180,"wires":[]},{"id":"b46ffcb5.0bfca","type":"change","z":"cbf4fba7.b2a9a8","name":"Extract Temperature","rules":[{"t":"set","p":"payload","pt":"msg","to":"data.\"Temperature\":","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":160,"wires":[["512caced.dc6ec4","2b749042.1fc83"]]},{"id":"40d862e0.7d2bec","type":"debug","z":"cbf4fba7.b2a9a8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":460,"y":100,"wires":[]},{"id":"68387582.8a605c","type":"inject","z":"cbf4fba7.b2a9a8","name":"","topic":"","payload":"tele/House/LoungeRoom/SENSOR : msg.payload : string[114] \"{\"Time\":\"2020-08-02T07:42:23\",\"BMP280\":{\"Temperature\":15.1,\"Pressure\":1017.9},\"PressureUnit\":\"hPa\",\"TempUnit\":\"C\"}\"","payloadType":"str","repeat":"5","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":180,"wires":[["b46ffcb5.0bfca"]]},{"id":"4dfa2901.da50e8","type":"mqtt-broker","z":"","name":"","broker":"192.168.0.44","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"a70772f8.5b41e","type":"ui_group","z":"","name":"tele/House/LoungeRoom/SENSOR","tab":"2773783e.d03e88","order":1,"disp":false,"width":"6","collapse":false},{"id":"2773783e.d03e88","type":"ui_tab","z":"","name":"Current","icon":"dashboard"}]

This is the Debug message:

{"topic":"","payload":"tele/House/LoungeRoom/SENSOR : msg.payload : string[114] \"{\"Time\":\"2020-08-02T07:42:23\",\"BMP280\":{\"Temperature\":15.1,\"Pressure\":1017.9},\"PressureUnit\":\"hPa\",\"TempUnit\":\"C\"}\"","_msgid":"d65649c3.5487b8"}

Any help would be appreciated.

Reagrds,
Dave

Thanks @harelabb, I will give it a try.
(looks like I will learn some Norwegian words as well).

regards,
Dave

The payload you get from the injection node seems strange, and conversion to json fails.
Can you post the real output from the mqtt node. The problem may be further upstream.

This is the output from the MQTT node:

topic: "tele/House/LoungeRoom/SENSOR"
payload: "{"Time":"2020-08-10T13:32:18","BMP280":{"Temperature":20.8,"Pressure":1009.8},"PressureUnit":"hPa","TempUnit":"C"}"
qos: 0
retain: false
_msgid: "57b9edaa.7c79e4"type or paste code here

Regards,
Dave

See this example flow. Check the gauge nodes and the "Value format" field.

[{"id":"db00675f.235288","type":"ui_gauge","z":"28231c15.904c8c","name":"Baro Pressure","group":"8ef2c7d.d298038","order":3,"width":0,"height":0,"gtype":"gage","title":"Pressure","label":"hPa","format":"{{payload.BMP280.Pressure}}","min":"970","max":"1030","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":416,"y":192,"wires":[]},{"id":"43f95d2d.46b63c","type":"ui_gauge","z":"28231c15.904c8c","name":"","group":"8ef2c7d.d298038","order":1,"width":0,"height":0,"gtype":"gage","title":"Temperature","label":"Deg C","format":"{{payload.BMP280.Temperature}}","min":0,"max":"30","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":406,"y":144,"wires":[]},{"id":"4eba1543.d64d1c","type":"inject","z":"28231c15.904c8c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":false,"onceDelay":0.1,"topic":"tele/House/LoungeRoom/SENSOR","payload":"{\"Time\":\"2020-08-10T13:32:18\",\"BMP280\":{\"Temperature\":20.8,\"Pressure\":1009.8},\"PressureUnit\":\"hPa\",\"TempUnit\":\"C\"}","payloadType":"json","x":218,"y":192,"wires":[["43f95d2d.46b63c","db00675f.235288","e09b06bd.4abd68"]]},{"id":"e09b06bd.4abd68","type":"debug","z":"28231c15.904c8c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":386,"y":240,"wires":[]},{"id":"8ef2c7d.d298038","type":"ui_group","z":"","name":"tele/House/LoungeRoom/SENSOR","tab":"360d2119.bf27b6","order":1,"disp":false,"width":"6","collapse":false},{"id":"360d2119.bf27b6","type":"ui_tab","z":"","name":"Current","icon":"dashboard"}]

To understand why this works, make sure to read the documentation of node-red. Using/accessing data/properties is the core of node-red.

The "working with messages" part in the documentation explains how this works. Make sure to watch the video(s) as well.

Set the mqtt node output to a "parsed JSON object", or attach a json node behind it.

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