Node-red node for node-dht-sensor
This is a Node Red node to manage connection to a DHT11 or DHT22 sensor on a Raspberry Pi. It allows you to specify the variables that define the connections to the sensor.
This node is added to the Raspberry Pi section.
This node requires that node-dht-sensor is installed and accessible from Node Red. Since this requires accesss to low-level parts of the Raspberry Pi, you must run your flow with superuser access.
Installing this node requires three steps:
- Install the BCM2835 library from here.
- Install the node-dht-sensor dependency
sudo npm install -g node-dht-sensor
sudo npm install -g node-red-contrib-dht-sensor
Configuring the node
You can specify the following, as seen in the picture here:
- The topic of the message - this is passed through so it can be used as an ID for the sensor.
- The name of the node. This can be a unique value to tag the sensor, useful if you have multiple sensors connected.
- The sensor type - this can be either DHT11 or DHT22.
- The pin number scheme. This can be any of
- the BCM-GPIO scheme
- the physical sequence number, for revision 1 of the Pi
- the physical sequence number, for revision 2 of the Pi (and A+ or B+)
- the wiringpi sequence, for revision 1 of the Pi
- the wiringpi sequence, for revision 2 of the Pi (and A+ or B+)
Using the node
The node is added to the Raspberry Pi section of the Node-RED pallette, and it can be used in a flow as usual:
The message returned includes the temperature as the payload, and the humidity and the device ID as part of the message itself:
- The temperature values is in °C and the humidity values are % relative humidity.
- If you're using an older release of Raspbian, you will have to run node-RED as root, otherwise you may run into problems with permissions.