BME180 processing output for Dashboard

I'm stuck! I have a BME280 attached to a esp8266 with Tasmota firmware. The Console output is -
sensorBME/tele/SENSOR = {"Time":"2019-08-13T17:27:58","BME280":{"Temperature":21.0,"Humidity":56.7,"Pressure":1007.9},"PressureUnit":"hPa","TempUnit":"C"}

In Node-Red I have read the output with a MQTT input node and the raw data looks fine.
I would like to separate out the Time, Temperature, Pressure and Humidity outputs.
To do this I have used the Json node, then a Split node (using ,) and then sending data to a Change node.

I have not been able to change and separate the Object data -

13/08/2019, 17:22:59node: 5ac1839.91c387csensorBME/tele/Time : msg.payload : string[19]

"2019-08-13T17:22:57"

13/08/2019, 17:22:59node: 5ac1839.91c387csensorBME/tele/BME280 : msg.payload : Object

object

Temperature: 21

Humidity: 57

Pressure: 1008

13/08/2019, 17:22:59node: 5ac1839.91c387csensorBME/tele/PressureUnit : msg.payload : string[3]

"hPa"

13/08/2019, 17:22:59node: 5ac1839.91c387csensorBME/tele/TempUnit : msg.payload : string[1]

"C"

Any help in sorting out this data would be most welcome.

Not sure what you are trying to do, but you can access the properties by using msg.payload.Temperature etc

Thanks bakman2 getting there but no cigar.
Getting lots of Undefined debug reports as well as some correct reports.
Not sure what I have done to mess things up.

I am not sure what you are trying to do.

Please share the relevant part of your flow, so people can help. Otherwise it is hard to understand what it going wrong.

As @bakman2 has stated, you can already access distinct properties of your data once it has been converted into an object by either the mqtt-node or the json-node.

I'm very new so what I say maybe completely wrong but it sound similar to what I needed to do.

I use a function node and pick out what I need

var Temp=msg.payload.Temperature;
var Hum=msg.payload.Humidty;
var Pres=msg.payload.Pressure;
return msg;

or maybe this.....

Temp: {{payload.Temperature}}
Hum: {{payload.Humidity}}
Pres: {{payload.Pressure}}

If you want 3 separate data outputs you could select a function node with 3 outputs and use something like this...

Temp={};
Hum={};
Pres={};
Temp.payload = (msg.payload.Temperature);
Hum.payload = (msg.payload.Humidity);
Pres.payload = (msg.payload.Pres);
return [Temp,Hum,Pres];

Now I maybe completely wrong as I use mostly trial and error to get my nodes to work. It will depend upon your input string of course.
Hope I could help though.

Thanks to all - I'm not there yet!
I would like to separate out the temperature and pressure sensor outputs to trigger other MQTT attached devices.

Here is the flow editor output (I hope this is the correct way to share what i,m doing) -
[
{
"id": "399dba2a.7b0306",
"type": "mqtt in",
"z": "50e81bd1.24b564",
"name": "",
"topic": "esp8266BME/tele/SENSOR",
"qos": "0",
"datatype": "json",
"broker": "496ae199.0dca3",
"x": 280,
"y": 520,
"wires": [
[
"2e169ccf.7f3f24"
]
]
},
{
"id": "541f28e6.2f6358",
"type": "switch",
"z": "50e81bd1.24b564",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "cont",
"v": "msg.payload.Humidity",
"vt": "str"
},
{
"t": "cont",
"v": "msg.payload.Temperature",
"vt": "str"
},
{
"t": "cont",
"v": "msg.payload.Pressure",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 4,
"x": 730,
"y": 560,
"wires": [
[
"46cc26dd.9aa7a8"
],
[
"a73a5e3d.bc501"
],
[
"19b373f1.71440c"
],

]
},
{
"id": "46cc26dd.9aa7a8",
"type": "debug",
"z": "50e81bd1.24b564",
"name": "Humidity",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 909.9999771118164,
"y": 541.3333168029785,
"wires":
},
{
"id": "a73a5e3d.bc501",
"type": "debug",
"z": "50e81bd1.24b564",
"name": "Temperature",
"active": true,
"console": "false",
"complete": "value",
"x": 923.4999618530273,
"y": 588.6666145324707,
"wires":
},
{
"id": "19b373f1.71440c",
"type": "debug",
"z": "50e81bd1.24b564",
"name": "Pressure",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "value",
"targetType": "msg",
"x": 915.4999618530273,
"y": 640.6666145324707,
"wires":
},
{
"id": "486d72bb.48158c",
"type": "debug",
"z": "50e81bd1.24b564",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 680,
"y": 480,
"wires":
},
{
"id": "2e169ccf.7f3f24",
"type": "split",
"z": "50e81bd1.24b564",
"name": "",
"splt": "/",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "key",
"x": 530,
"y": 520,
"wires": [
[
"486d72bb.48158c",
"541f28e6.2f6358"
]
]
},
{
"id": "496ae199.0dca3",
"type": "mqtt-broker",
"z": "",
"name": "MQTT",
"broker": "192.168.1.129",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": true,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "true",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closeRetain": "false",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": ""
}
]

My initial posting contains the mqtt console output from the BME280 sensor.

Brian

Does it work, or if it doesn't, what doesn't work ?

It doesn't work from the Switch node.

Show us a properly formatted output of a debug node that you have connected to the MQTT node.

15/08/2019, 16:19:06node: 86adae18.20fc8esp8266BME/tele/SENSOR : msg : Object

object

topic: "esp8266BME/tele/SENSOR"

payload: object

Time: "2019-08-15T16:19:04"

BME280: object

Temperature: 22.5
Humidity: 53.6
Pressure: 1004.8

PressureUnit: "hPa"
TempUnit: "C"
qos: 0
retain: false
_msgid: "a6746b0b.f7aa48"

The switch switches based on value, not based on property. Splitting doesn't work either as it splits msg.payload

Try this flow, connect your MQTT node to both.

[{"id":"e4295f89.c628f","type":"debug","z":"681f8bde.8887bc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":616,"wires":[]},{"id":"d55c40ca.7b488","type":"change","z":"681f8bde.8887bc","name":"Temperature","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.BME280.Temperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":434,"y":616,"wires":[["e4295f89.c628f"]]},{"id":"9f6fe77e.49c6a8","type":"change","z":"681f8bde.8887bc","name":"Humidity","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.BME280.Humidity","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":424,"y":672,"wires":[["daa23c3b.b9864"]]},{"id":"daa23c3b.b9864","type":"debug","z":"681f8bde.8887bc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":610,"y":672,"wires":[]}]

I was working on tasmota with a bme280 as well, how convenient :wink:

bakman2, many thanks you have fixed it. My ignorance drives me mad!
Make sure that you have a BME180 because many of the sellers send you a BMP180 (no humidity).
Mine is attached to a esp8266 with tasmota and is working well.
Thanks again.

I'm also having problems getting the Temperature,Pressure and Humidity from the BME280.
I have it wired to a Wemos D1 and it shows the values correctly on its own Tasmota webpage ( for the Wemos) and I get

house/weather/tele/SENSOR : msg.payload : string[129]

"{"Time":"2020-01-14T21:00:07","BME280":{"Temperature":11.9,"Humidity":95.3,"Pressure":987.9},"PressureUnit":"hPa","TempUnit":"C"}"

from the node on my node-red page but I don't seem to be able to work out what I have to do to get the individual values for each on their own message topic.

How are you trying to access it? In your debug it shows msg.payload as a string. Where is this coming from? a MQTT-IN node? If so, look at the options and try setting the 'output' setting to 'a parsed json object'

yes I believe its coming from an MQTT-In node ( will have to check when I'm home). I did at one stage get the 'pressure' value out on its own but changed settings and lost it again

Stick a debug node on the output of the mqtt-in node so you can see msg payload and copy the path to each of the elements
Screen Shot 2020-01-15 at 8.23.00 AM

This is what I get from my MQTT in node

{"topic":"house/weather/tele/SENSOR","payload":"{\"Time\":\"2020-01-17T16:25:13\",\"BME280\":{\"Temperature\":5.8,\"Humidity\":76.5,\"Pressure\":1006.9},\"PressureUnit\":\"hPa\",\"TempUnit\":\"C\"}","qos":0,"retain":false,"_msgid":"e1a95e7a.6ef5b"}

As suggested earlier, change the MQTT in node to parsed JSON mode, which tells it to expect JSON formatted data and convert it to a javascript object.

Thanks - with a bit of help and some trial and error I now seem to have a working BME280 output - now to try and add a UV sensor to the Wemos as well

1 Like