A few questions about sensors and node-red (as well dht isn't working)

#1

Hi there,

I am running Raspberry Pi with 2018-03-13-raspbian-stretch.

  1. I am trying to set up the DHT-22 sensor with node-red but isn’t working. The debug says 'TypeError: failed to initialize".

If I run python code from the shell it gives me results from DHT-22 successfully, I also installed necessary library.

  1. How should I set up MQTT client let’s say to work with DHT-22 and node red?

Thank you!

0 Likes

#2

What node-RED node are you using to try and read the DHT-22?

0 Likes

#3

I have the newest up to date node-red on RASPBIAN STRETCH.

0 Likes

#4

Which node are you using to read it ?
I seem to recall that most of the DHT nodes require you to run Node-RED as root - which is a pain and causes issues like you are seeing. If you do run as root you’ll need some command line parameters to point to your existing user directory. https://nodered.org/docs/getting-started/running

I’d advise anyone not to use the DHT sensors if at all possible. Yes they work but the number of issues we have…

0 Likes

#5

If by that you mean the one that comes installed on Raspbian stretch then it unfortunately isn’t the newest available and uses a very old version of nodejs. There are simple instructions to how to get the latest version of Node-RED (v0.18.7) here https://nodered.org/docs/hardware/raspberrypi

0 Likes

#6

@dceejay - I’ve no problem running NR v0.18.7 as user pi with latest raspbian and using a dht22…well there was the issue of setting the dht22 to use physical pin 4 - which is ground - causing the pi to freeze. But other than that, it seems to run fine.

I did open an issue in github (https://github.com/bpmurray/node-red-contrib-dht-sensor/issues/14#issuecomment-401920796) about it but the authors ‘solution’ was to change the readme to:

Note: If you’re daft enough to select an earth (ground) pin, this will cause the Pi to freeze.

1 Like