BME280 Output Object Splitting

First please read https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506

I think this is what you are trying todo

please copy and paste this when importing

[{"id":"a21e68f9.74436","type":"function","z":"33a0358a.93f17a","name":"Setup Object","func":"\nmsg.payload = \n{\"TempatureC\":\"32.54\",\"humidity\":\"51.8845672\",\"pressure_hPa\":\"987.982345\"};\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":280,"wires":[["b7f08be0.380038"]]},{"id":"b7f08be0.380038","type":"debug","z":"33a0358a.93f17a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":510,"y":280,"wires":[]},{"id":"f5c838c4.c526d","type":"inject","z":"33a0358a.93f17a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":280,"wires":[["a21e68f9.74436"]]},{"id":"eef947dd.b4d0d8","type":"comment","z":"33a0358a.93f17a","name":"understand the structure of an object","info":"","x":350,"y":240,"wires":[]},{"id":"bb570529.bd6e5","type":"function","z":"33a0358a.93f17a","name":"Setup Object","func":"\nmsg.payload = \n{\"TempatureC\":\"32.54\",\"humidity\":\"51.8845672\",\"pressure_hPa\":\"987.982345\"};\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":360,"wires":[["c09f6353.b671","1528c89c.cb53df","938107a4.269e5"]]},{"id":"391d6ed.8b77012","type":"debug","z":"33a0358a.93f17a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":950,"y":360,"wires":[]},{"id":"b0057f01.1a1a7","type":"inject","z":"33a0358a.93f17a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":360,"wires":[["bb570529.bd6e5"]]},{"id":"c09f6353.b671","type":"change","z":"33a0358a.93f17a","name":"msg.payload.TempatureC","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.TempatureC","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":360,"wires":[["391d6ed.8b77012"]]},{"id":"1528c89c.cb53df","type":"change","z":"33a0358a.93f17a","name":"msg.payload.humidity","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.humidity","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":400,"wires":[["823eddcb.73709"]]},{"id":"938107a4.269e5","type":"change","z":"33a0358a.93f17a","name":"msg.payload.pressure_hPa","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.pressure_hPa","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":440,"wires":[["d916da65.57f17"]]},{"id":"823eddcb.73709","type":"debug","z":"33a0358a.93f17a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":950,"y":400,"wires":[]},{"id":"d916da65.57f17","type":"debug","z":"33a0358a.93f17a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":950,"y":440,"wires":[]},{"id":"e59e3172.896538","type":"comment","z":"33a0358a.93f17a","name":"splitting the opbject into individual msg.payloads","info":"","x":340,"y":320,"wires":[]},{"id":"b3d2d4b5.9c3bb8","type":"function","z":"33a0358a.93f17a","name":"Setup Object","func":"\nmsg.payload = \n{\"TempatureC\":\"32.54\",\"humidity\":\"51.8845672\",\"pressure_hPa\":\"987.982345\"};\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":540,"wires":[["1500db1b.55ecbd","a4df9424.029b88","1e6b00ab.d79e37"]]},{"id":"991d46f5.93bd38","type":"debug","z":"33a0358a.93f17a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":950,"y":540,"wires":[]},{"id":"395827d3.d28bc","type":"inject","z":"33a0358a.93f17a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":540,"wires":[["b3d2d4b5.9c3bb8"]]},{"id":"1500db1b.55ecbd","type":"change","z":"33a0358a.93f17a","name":"msg.topic and msg.payload.TempatureC","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.TempatureC","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"TempatureC","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":540,"wires":[["991d46f5.93bd38"]]},{"id":"a4df9424.029b88","type":"change","z":"33a0358a.93f17a","name":"msg.topic and msg.payload.humidity","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.humidity","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"humidity","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":580,"wires":[["5c635b5f.06a3bc"]]},{"id":"1e6b00ab.d79e37","type":"change","z":"33a0358a.93f17a","name":"msg.topic and msg.payload.pressure_hPa","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.pressure_hPa","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"pressure_hPa","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":620,"wires":[["e79301f2.6c1ab8"]]},{"id":"5c635b5f.06a3bc","type":"debug","z":"33a0358a.93f17a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":950,"y":580,"wires":[]},{"id":"e79301f2.6c1ab8","type":"debug","z":"33a0358a.93f17a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":950,"y":620,"wires":[]},{"id":"fa9cb913.c46528","type":"comment","z":"33a0358a.93f17a","name":"adding a topic to make it better","info":"","x":350,"y":500,"wires":[]},{"id":"fb6316bd.c63668","type":"function","z":"33a0358a.93f17a","name":"function","func":"//Get Values from payload object and put in to a var\nvar TempatureC = msg.payload.TempatureC;\nvar humidity = msg.payload.humidity;\nvar pressure_hPa = msg.payload.pressure_hPa;\n\n\n//send it\nvar msg1 = {payload:TempatureC};\nvar msg2 = {payload:humidity};\nvar msg3 = {payload:pressure_hPa};\nreturn [[msg1,msg2,msg3]];","outputs":1,"noerr":0,"x":560,"y":740,"wires":[["8c4ec24d.16862"]]},{"id":"8c4ec24d.16862","type":"debug","z":"33a0358a.93f17a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":750,"y":740,"wires":[]},{"id":"28a03896.b722d","type":"inject","z":"33a0358a.93f17a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":740,"wires":[["bca4730a.c85128"]]},{"id":"bca4730a.c85128","type":"function","z":"33a0358a.93f17a","name":"Setup Object","func":"\nmsg.payload = \n{\"TempatureC\":\"32.54\",\"humidity\":\"51.8845672\",\"pressure_hPa\":\"987.982345\"};\nreturn msg;","outputs":1,"noerr":0,"x":390,"y":740,"wires":[["fb6316bd.c63668"]]},{"id":"f5b69ce7.227488","type":"comment","z":"33a0358a.93f17a","name":"using a function to do it","info":"","x":360,"y":680,"wires":[]},{"id":"125ac65b.d1b402","type":"function","z":"33a0358a.93f17a","name":"function","func":"//Get Values from payload object and put in to a var\nvar TempatureC = msg.payload.TempatureC;\nvar humidity = msg.payload.humidity;\nvar pressure_hPa = msg.payload.pressure_hPa;\n\n\n//send it\nvar msg1 = {payload:TempatureC,topic:\"TempatureC\"};\nvar msg2 = {payload:humidity,topic:\"humidity\"};\nvar msg3 = {payload:pressure_hPa,topic:\"pressure_hPa\"};\nreturn [[msg1,msg2,msg3]];","outputs":1,"noerr":0,"x":560,"y":880,"wires":[["30a02e15.1b4412"]]},{"id":"30a02e15.1b4412","type":"debug","z":"33a0358a.93f17a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":750,"y":880,"wires":[]},{"id":"4ed5ec7e.3fe1f4","type":"inject","z":"33a0358a.93f17a","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":880,"wires":[["3414ae6c.b74b2a"]]},{"id":"3414ae6c.b74b2a","type":"function","z":"33a0358a.93f17a","name":"Setup Object","func":"\nmsg.payload = \n{\"TempatureC\":\"32.54\",\"humidity\":\"51.8845672\",\"pressure_hPa\":\"987.982345\"};\nreturn msg;","outputs":1,"noerr":0,"x":390,"y":880,"wires":[["125ac65b.d1b402"]]},{"id":"2495aa21.e48cae","type":"comment","z":"33a0358a.93f17a","name":"Adding a topic and using a function to do it","info":"","x":420,"y":820,"wires":[]}]

your not trying to split ... your want to separate a object into individual msg

NOTE: the function called "Setup Object" is just a place holder for you node BME280. Its basically just giving the same format of output as the BME280 node.

1 Like