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

**URL:** <https://discourse.nodered.org/t/a-few-questions-about-sensors-and-node-red-as-well-dht-isnt-working/1210>\
**Category:** General\
**Created:** [30 June 2018 20:07 UTC](https://discourse.nodered.org/t/a-few-questions-about-sensors-and-node-red-as-well-dht-isnt-working/1210 "2018-06-30T20:07:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jordan](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jordan](https://discourse.nodered.org/u/jordan)\
**Post date:** [30 June 2018 20:07 UTC](https://discourse.nodered.org/t/a-few-questions-about-sensors-and-node-red-as-well-dht-isnt-working/1210/1 "2018-06-30T20:07:30Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [30 June 2018 21:23 UTC](https://discourse.nodered.org/t/a-few-questions-about-sensors-and-node-red-as-well-dht-isnt-working/1210/2 "2018-06-30T21:23:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jordan](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jordan](https://discourse.nodered.org/u/jordan)\
**Post date:** [4 July 2018 09:09 UTC](https://discourse.nodered.org/t/a-few-questions-about-sensors-and-node-red-as-well-dht-isnt-working/1210/3 "2018-07-04T09:09:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [4 July 2018 09:31 UTC](https://discourse.nodered.org/t/a-few-questions-about-sensors-and-node-red-as-well-dht-isnt-working/1210/4 "2018-07-04T09:31:57Z")

</div>

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](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…

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [4 July 2018 09:38 UTC](https://discourse.nodered.org/t/a-few-questions-about-sensors-and-node-red-as-well-dht-isnt-working/1210/5 "2018-07-04T09:38:53Z")

</div>

> [@jordan](#):
>
> I have the newest up to date node-red on RASPBIAN STRETCH.

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 [Redirecting…](https://nodered.org/docs/hardware/raspberrypi)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [4 July 2018 10:16 UTC](https://discourse.nodered.org/t/a-few-questions-about-sensors-and-node-red-as-well-dht-isnt-working/1210/6 "2018-07-04T10:16:15Z")

</div>

@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 ([Causes a freeze the pi when choosing physical pin 4 · Issue #14 · bpmurray/node-red-contrib-dht-sensor · 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.
