Timing message on led display

Hi,

I am trying to display sensor values (via MQTT, parsed Json object) on a led matrix display. That works, if I send a single value via POST to the led matrix, but how can it show values like: CO2, Temp, Humidity one by one?

*My current flow with on the right, the nodes for controlling the led matrix display. *

[{"id":"990cf220ffa4c8fa","type":"debug","z":"e80feb6f8327e56e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":270,"y":220,"wires":[]},{"id":"81b7aea68348f674","type":"change","z":"e80feb6f8327e56e","name":"CO2","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.co2_concentration.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":260,"y":260,"wires":[["6286d773141d741e","dd53e79211c568d7","cffca18bdeb25c13","990cf220ffa4c8fa"]]},{"id":"4452bc860ad09632","type":"change","z":"e80feb6f8327e56e","name":"Temperature","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.air_temperature.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":300,"wires":[["8808bc3f89d08811","fe3d461ca6f59a82","09c08beb45decc6f"]]},{"id":"28e0a8ca344f2d0b","type":"change","z":"e80feb6f8327e56e","name":"Humidity","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.air_humidity.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":340,"wires":[["855cd7e38b1401ad","41241e19901626ee"]]},{"id":"ee96d856376d39a0","type":"change","z":"e80feb6f8327e56e","name":"Battery","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.battery_voltage.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":380,"wires":[["23fd7d1550476396"]]},{"id":"667daa8d4faac3fa","type":"inject","z":"e80feb6f8327e56e","name":"ExampleInputData","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"protocol_version\":2,\"device_id\":3548,\"battery_voltage\":{\"displayName\":\"Battery voltage\",\"value\":2.555,\"unit\":\"V\"},\"air_temperature\":{\"displayName\":\"Air temperature\",\"value\":19.939726863508042,\"unit\":\"°C\"},\"air_humidity\":{\"displayName\":\"Air humidity\",\"value\":40.189211871519035,\"unit\":\"%\"},\"barometric_pressure\":{\"displayName\":\"Barometric pressure\",\"value\":102840,\"unit\":\"Pa\"},\"ambient_light_visible_infrared\":{\"displayName\":\"Ambient light (visible + infrared)\",\"value\":11},\"ambient_light_infrared\":{\"displayName\":\"Ambient light (infrared)\",\"value\":1},\"illuminance\":{\"displayName\":\"Illuminance\",\"value\":14.511743999999998,\"unit\":\"lx\"},\"co2_concentration\":{\"displayName\":\"CO2 concentration\",\"value\":896,\"unit\":\"ppm\"},\"co2_sensor_status\":{\"displayName\":\"CO2 sensor status\",\"value\":0},\"raw_ir_reading\":{\"displayName\":\"Raw IR reading\",\"value\":36881},\"activity_counter\":{\"displayName\":\"Activity counter\",\"value\":0},\"total_voc\":{\"displayName\":\"Total VOC\",\"value\":126,\"unit\":\"ppb\"}}","payloadType":"json","x":230,"y":500,"wires":[["81b7aea68348f674"]]},{"id":"6286d773141d741e","type":"ui_gauge","z":"e80feb6f8327e56e","name":"","group":"8b4e1d07.734fc","order":1,"width":"3","height":"3","gtype":"gage","title":"CO2 Level","label":"ppm","format":"{{value}}","min":"350","max":"5000","colors":["#006f00","#e6e600","#ca3838"],"seg1":"1000","seg2":"2500","x":550,"y":220,"wires":[]},{"id":"1c31a0428a302646","type":"comment","z":"e80feb6f8327e56e","name":"Gauge and Chart for node-RED dashboard","info":"","x":540,"y":180,"wires":[]},{"id":"e0184460023746e9","type":"http request","z":"e80feb6f8327e56e","name":"Activated","method":"POST","ret":"obj","paytoqs":"ignore","url":"http://192.168.1.59/set?text=Livingroom+CO2%3A+{{payload}}ppm","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"credentials":{},"x":720,"y":240,"wires":[["b25f103f187349e2"]]},{"id":"8a9b3e6dca4c4891","type":"debug","z":"e80feb6f8327e56e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":870,"y":200,"wires":[]},{"id":"b25f103f187349e2","type":"delay","z":"e80feb6f8327e56e","name":"","pauseType":"queue","timeout":"18","timeoutUnits":"seconds","rate":"2","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":890,"y":240,"wires":[["3bcd56def4b89757"]]},{"id":"3bcd56def4b89757","type":"do-return","z":"e80feb6f8327e56e","name":"","mode":"abort","x":1090,"y":240,"wires":[]},{"id":"eaa4bc0b8214dedd","type":"do-return","z":"e80feb6f8327e56e","name":"","mode":"done","x":1190,"y":300,"wires":[]},{"id":"510aac7f74c460fb","type":"http request","z":"e80feb6f8327e56e","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.58/power?value=0","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":1050,"y":300,"wires":[["eaa4bc0b8214dedd"]]},{"id":"f048ceb70b95d33d","type":"http request","z":"e80feb6f8327e56e","name":"no message","method":"POST","ret":"txt","paytoqs":false,"url":"http://192.168.1.59/set?text=","tls":"","persist":false,"proxy":"","authType":"","x":870,"y":300,"wires":[["510aac7f74c460fb"]]},{"id":"73a46ba2eab1d714","type":"do","z":"e80feb6f8327e56e","name":"","tasks":["Task 1"],"outputs":2,"x":710,"y":300,"wires":[["e0184460023746e9"],["f048ceb70b95d33d"]]},{"id":"dd53e79211c568d7","type":"ui_chart","z":"e80feb6f8327e56e","name":"","group":"8b4e1d07.734fc","order":2,"width":"3","height":"3","label":"CO2 Level","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"CO2 level","dot":true,"ymin":"400","ymax":"2000","removeOlder":"2","removeOlderPoints":"8","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#5fad47","#ffff00","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":550,"y":260,"wires":[[]]},{"id":"cffca18bdeb25c13","type":"switch","z":"e80feb6f8327e56e","name":"","property":"payload","propertyType":"msg","rules":[{"t":"istype","v":"number","vt":"number"}],"checkall":"true","repair":false,"outputs":1,"x":530,"y":300,"wires":[["73a46ba2eab1d714","8a9b3e6dca4c4891"]]},{"id":"8808bc3f89d08811","type":"ui_gauge","z":"e80feb6f8327e56e","name":"","group":"29bc741a.95f084","order":1,"width":"3","height":"3","gtype":"gage","title":"Temperature","label":"C","format":"{{msg.payload | number:1}}","min":"5","max":"45","colors":["#0080ff","#008000","#ca3838"],"seg1":"17","seg2":"30","x":550,"y":340,"wires":[]},{"id":"09c08beb45decc6f","type":"switch","z":"e80feb6f8327e56e","name":"","property":"payload","propertyType":"msg","rules":[{"t":"istype","v":"number","vt":"number"}],"checkall":"true","repair":false,"outputs":1,"x":530,"y":380,"wires":[[]]},{"id":"fe3d461ca6f59a82","type":"ui_chart","z":"e80feb6f8327e56e","name":"","group":"29bc741a.95f084","order":2,"width":"3","height":"3","label":"Temperature","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"10","ymax":"40","removeOlder":"2","removeOlderPoints":"8","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":550,"y":420,"wires":[[]]},{"id":"855cd7e38b1401ad","type":"ui_gauge","z":"e80feb6f8327e56e","name":"","group":"c1081cc9.435","order":2,"width":"3","height":"3","gtype":"gage","title":"Humidity","label":"%","format":"{{msg.payload | number:0}}","min":"40","max":"100","colors":["#ffff00","#008000","#0000ff"],"seg1":"50","seg2":"70","x":540,"y":460,"wires":[]},{"id":"41241e19901626ee","type":"ui_chart","z":"e80feb6f8327e56e","name":"","group":"c1081cc9.435","order":3,"width":"3","height":"3","label":"Humidity","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"40","ymax":"100","removeOlder":"2","removeOlderPoints":"8","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#ffff00","#008000","#ff0000","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":540,"y":500,"wires":[[]]},{"id":"23fd7d1550476396","type":"ui_gauge","z":"e80feb6f8327e56e","name":"Battery","group":"90483de4.9cb3b","order":2,"width":"3","height":"3","gtype":"gage","title":"Battery","label":"V","format":"{{msg.payload | number:1}}","min":"2.0","max":"4.2","colors":["#ff0000","#008000","#ff0000"],"seg1":"2.3","seg2":"3.7","x":540,"y":540,"wires":[]},{"id":"6e2b28ed2307db12","type":"do","z":"e80feb6f8327e56e","name":"","tasks":["Task 1"],"outputs":2,"x":710,"y":440,"wires":[["a5a9f4e34b8789a4"],["74478be908efeff6"]]},{"id":"a5a9f4e34b8789a4","type":"http request","z":"e80feb6f8327e56e","name":"Activated","method":"POST","ret":"obj","paytoqs":"ignore","url":"http://192.168.1.59/set?text=Livingroom+Temparature%3A+{{payload}}ppm","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"credentials":{"user":"","password":""},"x":720,"y":380,"wires":[["69b2575189d75822"]]},{"id":"69b2575189d75822","type":"delay","z":"e80feb6f8327e56e","name":"","pauseType":"queue","timeout":"18","timeoutUnits":"seconds","rate":"2","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":890,"y":380,"wires":[["6a716f63f6966e1c"]]},{"id":"6a716f63f6966e1c","type":"do-return","z":"e80feb6f8327e56e","name":"","mode":"abort","x":1090,"y":380,"wires":[]},{"id":"7065d7eec79ec5c7","type":"do-return","z":"e80feb6f8327e56e","name":"","mode":"done","x":1170,"y":440,"wires":[]},{"id":"ddd2346d9165ab61","type":"http request","z":"e80feb6f8327e56e","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://192.168.1.58/power?value=0","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":1030,"y":440,"wires":[["7065d7eec79ec5c7"]]},{"id":"74478be908efeff6","type":"http request","z":"e80feb6f8327e56e","name":"no message","method":"POST","ret":"txt","paytoqs":false,"url":"http://192.168.1.59/set?text=","tls":"","persist":false,"proxy":"","authType":"","x":870,"y":440,"wires":[["ddd2346d9165ab61"]]},{"id":"a1cb5530c50c2df8","type":"link in","z":"e80feb6f8327e56e","name":"3548","links":["9354d589.9b86b8","9909c064.50b7e","b9bcbeab.0fbfb","bdc9a255.8dd68"],"x":135,"y":280,"wires":[["81b7aea68348f674","4452bc860ad09632","28e0a8ca344f2d0b","ee96d856376d39a0"]]},{"id":"8b4e1d07.734fc","type":"ui_group","name":"3548","tab":"350e4f32.7b2918","order":5,"disp":true,"width":"6","collapse":false},{"id":"29bc741a.95f084","type":"ui_group","name":"3548","tab":"350e4f32.7b2918","order":6,"disp":true,"width":"6","collapse":false},{"id":"c1081cc9.435","type":"ui_group","name":"3548","tab":"350e4f32.7b2918","order":7,"disp":true,"width":"6","collapse":false},{"id":"90483de4.9cb3b","type":"ui_group","name":"3548","tab":"350e4f32.7b2918","order":8,"disp":true,"width":"6","collapse":false},{"id":"350e4f32.7b2918","type":"ui_tab","name":"DecentLab","icon":"dashboard","order":24,"disabled":false,"hidden":false}]

I think you need to provide some more information -

eg What type of matrix, what nodes you are using etc....

Can you explain what you mean by that? Do you need help with interfacing to the display, or is it help with preparing the data to send to the display that you need?

You would need to create an array of readings you wish to display. Then you could split that array and display one at a time.
something like this

[{"id":"39980144.bbe2be","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$encodeUrl($$.payload)\t","tot":"jsonata"},{"t":"move","p":"payload","pt":"msg","to":"url","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1050,"y":1300,"wires":[["38ee36a.c636c4a","e0184460023746e9"]]},{"id":"f9ce3348.dc0118","type":"template","z":"bf9e1e33.030598","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"http://192.168.1.59/set?text=Livingroom {{payload.displayName}} {{payload.value}} {{payload.unit}}","output":"str","x":830,"y":1300,"wires":[["8a9b3e6dca4c4891","39980144.bbe2be","2c8b7f47.d55118"]]},{"id":"2c8b7f47.d55118","type":"trigger","z":"bf9e1e33.030598","name":"","op1":"","op2":"http://192.168.1.59/set?text=","op1type":"nul","op2type":"str","duration":"32","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":820,"y":1340,"wires":[["8a9b3e6dca4c4891","39980144.bbe2be"]]},{"id":"38ee36a.c636c4a","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"url","targetType":"msg","statusVal":"$substring($$.url, 23)","statusType":"jsonata","x":1270,"y":1220,"wires":[]},{"id":"e0184460023746e9","type":"http request","z":"bf9e1e33.030598","name":"Activated","method":"POST","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":1310,"y":1300,"wires":[[]]},{"id":"b25f103f187349e2","type":"delay","z":"bf9e1e33.030598","name":"","pauseType":"rate","timeout":"18","timeoutUnits":"seconds","rate":"1","nbRateUnits":"30","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":640,"y":1300,"wires":[["f9ce3348.dc0118"]]},{"id":"8a9b3e6dca4c4891","type":"debug","z":"bf9e1e33.030598","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1090,"y":1360,"wires":[]},{"id":"6ff6ce93.92e628","type":"change","z":"bf9e1e33.030598","name":"round value","rules":[{"t":"set","p":"payload.value","pt":"msg","to":"$round($$.payload.value,1)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":1240,"wires":[["b25f103f187349e2"]]},{"id":"cffca18bdeb25c13","type":"switch","z":"bf9e1e33.030598","name":"","property":"payload.value","propertyType":"msg","rules":[{"t":"istype","v":"number","vt":"number"}],"checkall":"true","repair":false,"outputs":1,"x":460,"y":1300,"wires":[["6ff6ce93.92e628"]]},{"id":"f461c580.049498","type":"split","z":"bf9e1e33.030598","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":310,"y":1300,"wires":[["cffca18bdeb25c13"]]},{"id":"1f8a27c4.00cc4","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"set","p":"hold","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"[]","tot":"json"},{"t":"set","p":"payload[0]","pt":"msg","to":"hold.co2_concentration","tot":"msg"},{"t":"set","p":"payload[1]","pt":"msg","to":"hold.air_temperature","tot":"msg"},{"t":"set","p":"payload[2]","pt":"msg","to":"hold.air_humidity","tot":"msg"},{"t":"set","p":"payload[3]","pt":"msg","to":"hold.battery_voltage","tot":"msg"},{"t":"delete","p":"hold","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":150,"y":1300,"wires":[["f461c580.049498"]]},{"id":"667daa8d4faac3fa","type":"inject","z":"bf9e1e33.030598","name":"ExampleInputData","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"protocol_version\":2,\"device_id\":3548,\"battery_voltage\":{\"displayName\":\"Battery voltage\",\"value\":2.555,\"unit\":\"V\"},\"air_temperature\":{\"displayName\":\"Air temperature\",\"value\":19.939726863508042,\"unit\":\"°C\"},\"air_humidity\":{\"displayName\":\"Air humidity\",\"value\":40.189211871519035,\"unit\":\"%\"},\"barometric_pressure\":{\"displayName\":\"Barometric pressure\",\"value\":102840,\"unit\":\"Pa\"},\"ambient_light_visible_infrared\":{\"displayName\":\"Ambient light (visible + infrared)\",\"value\":11},\"ambient_light_infrared\":{\"displayName\":\"Ambient light (infrared)\",\"value\":1},\"illuminance\":{\"displayName\":\"Illuminance\",\"value\":14.511743999999998,\"unit\":\"lx\"},\"co2_concentration\":{\"displayName\":\"CO2 concentration\",\"value\":896,\"unit\":\"ppm\"},\"co2_sensor_status\":{\"displayName\":\"CO2 sensor status\",\"value\":0},\"raw_ir_reading\":{\"displayName\":\"Raw IR reading\",\"value\":36881},\"activity_counter\":{\"displayName\":\"Activity counter\",\"value\":0},\"total_voc\":{\"displayName\":\"Total VOC\",\"value\":126,\"unit\":\"ppb\"}}","payloadType":"json","x":420,"y":1400,"wires":[["1f8a27c4.00cc4"]]}]

This should display the 4 readings for 30 seconds each then wipe the screen.

[edit] encoded url to change spaces to %20, and rounded values

Hi,

I use 4x Max7219 Led matrix display, with a Wemos D1 mini that has a webserver. Sending sensor values via the node-RED HTTP request node, using the POST command, is not the problem, that is working fine, at least for one measurement (for example CO2)
Is use the switch node to filter the value as a number > the do node to create a task to send the value to the display > the delay node for trying to time or schedule the message > and the same node to send a empty message to clear the Led matrix display

The nodes are in the attached code

Hi,

No, the display working fine and sending data to the display is not the problem.
My problem is timing or scheduling the messages from the device. I receive the payload from a device in one object all together, for instance: CO2: 958, Temperature: 19, Humidity: 50 and the display won't show them of course not all together at once. So it would be nice if I can show them one after each other.
After that I would like to show the data from multiple devices :wink:

Hi,

Thank you, that looks interesting, :+1:, I'm going to look into this more closely

Thank you @E1cid this was very helpful and I learned something new. A nice example of how an array can be created and used. Rounding the values works perfectly. This is what I was looking for.
Another question:
Is it possible to change payload.displayName to just the text "CO2" so that this and the value is shown in the display instead of "CO2 concentration" and the value?

You can adjust each array object value in the change node round value
The following uses a look up object called names to alter the object displayName.

You can change the names in the lookup object

(
$names := {
    "Battery voltage":"Batt",
    "Air temperature": "Temp",
    "Air humidity": "Humidity",
    "CO2 concentration": "CO2"};
{
    "displayName": $lookup($names,$$.payload.displayName),
    "value": $round($$.payload.value,1),
    "unit": $$.payload.unit
    }
)
[{"id":"f4939f92.858c98","type":"change","z":"bf9e1e33.030598","name":"round value","rules":[{"t":"set","p":"payload","pt":"msg","to":"(\t$names := {\t    \"Battery voltage\":\"Batt\",\t    \"Air temperature\": \"Temp\",\t    \"Air humidity\": \"Humidity\",\t    \"CO2 concentration\": \"CO2\"};\t{\t    \"displayName\": $lookup($names,$$.payload.displayName),\t    \"value\": $round($$.payload.value,1),\t    \"unit\": $$.payload.unit\t    }\t)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":560,"wires":[["b4599974.65347"]]}]

the property name needs to be payload, not payload.value, as now the change node is altering the payload property. Not as before the payload.value property.

2 Likes

Problem solved! This works fine! :+1:
Thank you very much :smile:

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