Accessing DHT 11 Sensor in Node Red using Raspberry Pi

1,561 views
Skip to first unread message

Kyaw Zin Latt

unread,
Aug 24, 2014, 3:36:50 PM8/24/14
to node...@googlegroups.com
Hi,

I am a student. I would like to know how to access DHT11 sensor data using rpi-gpio nodes in Node Red. I also wanna know the FLOW of nodes in Node Red if possible.

Thanks 

Mark Setrem

unread,
Aug 24, 2014, 4:57:59 PM8/24/14
to node...@googlegroups.com
The DHT11 requires a library to convert the reading to a temperature.

One way of getting the temperature reading into Node-red would be to follow the instructions here: https://www.endian.se/content/?p=127

and then use the "exec" node to execute the Unix command to get the result into Node-Red

alternatively you might be able to read the file with the File Read Node.



Kyaw Zin Latt

unread,
Aug 25, 2014, 10:58:04 AM8/25/14
to node...@googlegroups.com
Thanks for your advice. As I am very new to Node Red, could you please show me step by step?
Message has been deleted

Scott C. Lemon

unread,
Aug 25, 2014, 11:21:15 AM8/25/14
to node...@googlegroups.com
This is actually a nice little program ... it could be easily modified to output JSON by adding a new "format" type to it ... and then it would come into Node-RED quite easily with EXEC.

Note to self: give it a try this weekend ...  :-)

Mark Setrem

unread,
Aug 25, 2014, 12:50:37 PM8/25/14
to node...@googlegroups.com

Before starting on Node-Red, follow the instructions in the original post, when you have that part working, then you can think about getting the data into Node-Red.

But I'd try something like an "Inject">"Exec">"Debug" flow...


Kyaw Zin Latt

unread,
Aug 25, 2014, 1:49:51 PM8/25/14
to node...@googlegroups.com
Thanks a lot. It is working now. Btw, is there any other way to get sensor data in Node Red using rpi-gpio nodes?

Mark Setrem

unread,
Aug 25, 2014, 4:23:00 PM8/25/14
to node...@googlegroups.com
Glad you got it working.  It depends on the sensor you want to connect.  

For some such as a PIR proximity sensor (on or off) it's easy to link it and read it directly.

For others such as the DHT11, which require a more complex technique, I personally think that life is too short!



Dave C-J

unread,
Aug 25, 2014, 5:12:04 PM8/25/14
to node...@googlegroups.com
Hi

the GPIO nodes are really only for simple digital IO - so reading switches, PIR, that sort of thing. Anything more complex that needs a communications channel (like reading the DHT11 etc) is better off handled by some native code as per the pointers already given. In theory someone could write a native module and then wrap it in a node.js wrapper to help make a node - but that would be a considerable effort for a fairly specific result. Much better (imho) to use the general approach already outlined (ie write to a file, or socket) and then read that into Node-RED.

Kyaw Zin Latt

unread,
Aug 26, 2014, 12:32:31 PM8/26/14
to node...@googlegroups.com


On Tuesday, August 26, 2014 5:12:04 AM UTC+8, Dave C-J wrote:
Hi

the GPIO nodes are really only for simple digital IO - so reading switches, PIR, that sort of thing. Anything more complex that needs a communications channel (like reading the DHT11 etc) is better off handled by some native code as per the pointers already given. In theory someone could write a native module and then wrap it in a node.js wrapper to help make a node - but that would be a considerable effort for a fairly specific result. Much better (imho) to use the general approach already outlined (ie write to a file, or socket) and then read that into Node-RED.


Thanks a lot for your explanation



 

Kyaw Zin Latt

unread,
Aug 26, 2014, 12:33:16 PM8/26/14
to node...@googlegroups.com
Thanks a lot for your discussion.
 
Reply all
Reply to author
Forward
0 new messages