Here are the steps I took to install Node-RED on my Raspberry Pi B, and then to wire it up to a DHT22 humidity and temperature sensor to log the conditions in my office. It’s based on my work last year using Node-RED to log electricity and water consumption data.
First, I wired up the DHT22 on a breadboard connected to my Raspberry Pi’s GPIO port by ribbon cable, using the helpful Adafruit guide here. The result looked like this:
Next, I installed Node and Node-RED, as detailed here:
wget http://node-arm.herokuapp.com/node_0.10.36_armhf.deb
sudo dpkg -i node_0.10.36_armhf.deb
sudo npm install -g --unsafe-perm node-red
That last step took a while (5 to 10 minutes). I was patient.
Next, I installed DHT22 support for Node-RED, first installing the bcm2835 library:
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.58tar.gz
tar zxvf bcm2835-1.58.tar.gz
cd bcm2835-1.58
./configure
make
sudo make check
sudo make install
And then:
sudo npm install --unsafe-perm -g node-dht-sensor
sudo npm install --unsafe-perm -g node-red-contrib-dht-sensor
I then started up Node-RED:
node-red-start
I was then able to see Node-RED from a browser at http://hostname-or-ip-address:1880/
I created a Node-RED workflow to read the temperature and humidity every 5 minutes and upload it to a PHP script on my webserver that squirrels it away in a MySQL database:
The key here was figuring out the settings for the DHT22 node, which required selecting BCM GPIO as the “pin numbering” scheme:
After that it was simple as running a functio node to make a URL for posting to my server:
and sending that to an HTTP Request node.
I fired things up and the data started to flow:
And from there I was able to export the data and make pretty charts:
Comments
Great project
Great project
great.!! Can you share this
great.!! Can you share this source code?
Add new comment