1-Wire to MQTT Bridge using Raspberry Pi GPIO Interface

This flow is an example of using the 1-Wire node which can be found here: https://github.com/RobQuads/node-red-contrib-1wire

This simple flows reads a 1-wire temperature sensor (DS18S20) and publishes the reading to MQTT as a retained message.

Image of Flow

In this flow, the inject node is used to specify the reference name of the 1-wire device to be read from (i.e 28-0114b8096eff, this triggers every minute. This is then passed to the 1-Wire node which reads the value of the sensor from the filesystem (i.e. /sys/bus/w1/devices/28-0114b8096eff/w1_slave)

The change node is used to set msg.retain to true - this causes MQTT to keep a copy of the latest temperature reading, so when a new client subscribes, it immediately gets a value.

Credit to njh for "1-wire to MQTT" bridge as this is based on it with the modifications of replacing owfs with GPIO as the interface

[{"id":"eb19c569.14e638","type":"mqtt-broker","broker":"localhost","port":"1883"},{"id":"ac705941.538fa8","type":"inject","name":"28-0114b8096eff","topic":"28-0114b8096eff","payload":"","payloadType":"none","repeat":"60","crontab":"","once":true,"x":116,"y":81,"z":"f2cc9fc7.0d336","wires":[["d7d13764.282ec8"]]},{"id":"4380f027.bc7f1","type":"mqtt out","name":"","topic":"","qos":"","retain":"","broker":"eb19c569.14e638","x":632,"y":111,"z":"f2cc9fc7.0d336","wires":[]},{"id":"1de7775e.e21889","type":"change","action":"replace","property":"retain","from":"","to":"true","reg":false,"name":"","x":418,"y":81,"z":"f2cc9fc7.0d336","wires":[["4380f027.bc7f1","c305c923.3cfa38"]]},{"id":"c305c923.3cfa38","type":"debug","name":"","active":true,"console":false,"complete":false,"x":651,"y":51,"z":"f2cc9fc7.0d336","wires":[]},{"id":"d7d13764.282ec8","type":"1-Wire","identifier":"","name":"","format":"1","x":271,"y":81,"z":"f2cc9fc7.0d336","wires":[["1de7775e.e21889"]]}]

Flow Info

Created 9 years, 9 months ago
Updated 4 years, 3 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • change (x1)
  • debug (x1)
  • inject (x1)
  • mqtt out (x1)
  • mqtt-broker (x1)
Other

Tags

  • 1-Wire
  • DS18S20
  • GPIO
  • Raspberry
  • Pi
  • mqtt
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option