Introduction
Previously, we learned how to connect our Dallas sensor to a Raspberry PLC using the 1-Wire protocol.
Then, we learned how to get the temperature from our Dallas sensor from Linux.
And, we learned how to parse the temperature and how to get it from Node-RED.
In this blog, we are going to learn how to display this information in a friendly way, with a Touchberry Pi.
Related Links
Explanation
Using the Touchberry Pi panel to display information
For this example, we will use the new Touchberry Pi, a panel that will be very useful to directly see the data obtained. (The connection of the sensor must be with a pin with direct GPIO such as the CS1 Touchberry pin, that connects to GPIO 7, then we will only have to do the configuration as we did on the Raspberry plc but with gpio pin 7 instead of with the 25).
If you use a Raspberry PLC you won't need to configure anything additionally.
With the sensor connected properly and with node-red obtaining the pertinent data, we can now create the interface we prefer, here we leave you an example.
EXAMPLE
This is what the example we propose would look like.
In order to do this, we must add some blocks:
As we can see, we have added some function blocks to make the transformation from degrees Celsius to the different types of temperature measurement units. In addition, we have added the necessary blocks for displaying the data in gauge format.
Here we leave you the code why you import it in your projects.
Remember that, in the execution block, you must replace the directory name, since it will have another name.
CODE:
To obtain this example you only have to copy the JSON that we leave you below, in Node-Red import and copy the code.
[{"id":"711d6d4e196989c7","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"e9eb17d866a83f7a","type":"inject","z":"711d6d4e196989c7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"0.5","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":130,"y":200,"wires":[["9ead71aef2ae83f5"]]},{"id":"9ead71aef2ae83f5","type":"exec","z":"711d6d4e196989c7","command":"sudo cat /sys/bus/w1/devices/28-01204f9f82f6/w1_slave | sed -e 's/.*t=//' | sed '1d'","addpay":"","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":510,"y":200,"wires":[["5bf1762b8f47306c","cdd59e7e050bedea"],[],[]]},{"id":"5bf1762b8f47306c","type":"function","z":"711d6d4e196989c7","name":"get_temp","func":"msg.payload = parseFloat((msg.payload / 1000).toFixed(3));\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":900,"y":200,"wires":[["6306d3e51cb99169","fbe6da72b9906651","28e9622a81066ade"]]},{"id":"6306d3e51cb99169","type":"ui_gauge","z":"711d6d4e196989c7","name":"","group":"3d1764834ab89c7d","order":2,"width":10,"height":6,"gtype":"gage","title":"Celsius","label":"","format":"{{value}} ºC","min":"-50","max":"100","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","diff":false,"className":"","x":1340,"y":220,"wires":[]},{"id":"dda3aa2879ccde60","type":"ui_gauge","z":"711d6d4e196989c7","name":"","group":"3d1764834ab89c7d","order":4,"width":10,"height":6,"gtype":"gage","title":"Fahrenheit","label":"","format":"{{value}} ºF","min":"-58","max":"212","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","diff":false,"className":"","x":1350,"y":160,"wires":[]},{"id":"fbe6da72b9906651","type":"function","z":"711d6d4e196989c7","name":"Celsius2Fahrenheit","func":"msg.payload = (9/5 * msg.payload + 32).toFixed(3)\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1110,"y":160,"wires":[["dda3aa2879ccde60"]]},{"id":"8802b29b44a16a36","type":"ui_gauge","z":"711d6d4e196989c7","name":"","group":"3d1764834ab89c7d","order":3,"width":10,"height":6,"gtype":"gage","title":"Kelvin","label":"","format":"{{value}} K","min":"224","max":"374","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","diff":false,"className":"","x":1330,"y":100,"wires":[]},{"id":"28e9622a81066ade","type":"function","z":"711d6d4e196989c7","name":"Celsius2Kelvin","func":"msg.payload = (msg.payload + 273.15).toFixed(3)\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1100,"y":100,"wires":[["8802b29b44a16a36"]]},{"id":"0e6277e00911b3e5","type":"ui_text","z":"711d6d4e196989c7","group":"3d1764834ab89c7d","order":1,"width":0,"height":0,"name":"","label":"Temperature measured from the Dallas DS18B20 sensor","format":"{{msg.payload}}","layout":"col-center","className":"","style":true,"font":"Arial Black,Arial Black,Gadget,sans-serif","fontSize":"30","color":"#000000","x":1490,"y":40,"wires":[]},{"id":"cdd59e7e050bedea","type":"debug","z":"711d6d4e196989c7","name":"debug","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":890,"y":240,"wires":[]},{"id":"3d1764834ab89c7d","type":"ui_group","name":"Dashboard","tab":"ebd052791c5bf967","order":1,"disp":true,"width":"30","collapse":false,"className":""},{"id":"ebd052791c5bf967","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
IV. Temperature Sensor and Touchberry: How to display temperature using Node-RED