Node-red-contrib-dht-sensor

I am trying to install node-red-contrib-dht-sensor. I have followed the three steps which are:

Step 1- Installing BCM2835 library

Step 2 & 3 - Install the node-dht-sensor dependency

nodejs version: v12.22.12
npm version: 8.19.2

However, it is not installed. Here is the error message that I get:


2022-10-21T12:02:01.048Z Install : node-red-contrib-dht-sensor 1.0.4

2022-10-21T12:02:01.217Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production --engine-strict node-red-contrib-dht-sensor@1.0.4
2022-10-21T12:02:14.116Z [err] npm ERR! code 1
2022-10-21T12:02:14.116Z [err] npm ERR! path /home/pi/.node-red/node_modules/node-dht-sensor
2022-10-21T12:02:14.129Z [err] npm
2022-10-21T12:02:14.130Z [err] ERR! command failed
2022-10-21T12:02:14.130Z [err] npm ERR! command sh -c node-gyp configure
2022-10-21T12:02:14.130Z [err] npm
2022-10-21T12:02:14.130Z [err] ERR! gyp info it worked if it ends with ok
2022-10-21T12:02:14.130Z [err] npm
2022-10-21T12:02:14.130Z [err] ERR! gyp info using node-gyp@3.8.0
2022-10-21T12:02:14.131Z [err] npm ERR!
2022-10-21T12:02:14.131Z [err] gyp info using node@12.22.12 | linux | arm
2022-10-21T12:02:14.131Z [err] npm
2022-10-21T12:02:14.131Z [err] ERR! gyp ERR! configure error
2022-10-21T12:02:14.131Z [err] npm
2022-10-21T12:02:14.131Z [err] ERR! gyp ERR! stack Error: Command failed: /usr/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
2022-10-21T12:02:14.131Z [err] npm ERR!
2022-10-21T12:02:14.131Z [err] gyp ERR! stack File "", line 1
2022-10-21T12:02:14.131Z [err] npm
2022-10-21T12:02:14.131Z [err] ERR! gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
2022-10-21T12:02:14.131Z [err] npm ERR!
2022-10-21T12:02:14.132Z [err] gyp ERR! stack ^
2022-10-21T12:02:14.132Z [err] npm ERR!
2022-10-21T12:02:14.132Z [err] gyp ERR! stack SyntaxError: invalid syntax
2022-10-21T12:02:14.132Z [err] npm
2022-10-21T12:02:14.132Z [err] ERR! gyp ERR! stack
2022-10-21T12:02:14.132Z [err] npm
2022-10-21T12:02:14.132Z [err] ERR!
2022-10-21T12:02:14.132Z [err] gyp ERR! stack at ChildProcess.exithandler (child_process.js:308:12)
2022-10-21T12:02:14.132Z [err] npm ERR!
2022-10-21T12:02:14.132Z [err] gyp ERR! stack at ChildProcess.emit (events.js:314:20)
2022-10-21T12:02:14.132Z [err] npm
2022-10-21T12:02:14.132Z [err] ERR! gyp ERR! stack at maybeClose (internal/child_process.js:1022:16)
2022-10-21T12:02:14.132Z [err] npm
2022-10-21T12:02:14.133Z [err] ERR!
2022-10-21T12:02:14.133Z [err] gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
2022-10-21T12:02:14.133Z [err] npm ERR!
2022-10-21T12:02:14.133Z [err] gyp ERR! System Linux 5.15.61-v7+
2022-10-21T12:02:14.133Z [err] npm
2022-10-21T12:02:14.133Z [err] ERR! gyp ERR! command "/usr/bin/node" "/home/pi/.node-red/node_modules/.bin/node-gyp" "configure"
2022-10-21T12:02:14.133Z [err] npm
2022-10-21T12:02:14.133Z [err] ERR! gyp ERR! cwd /home/pi/.node-red/node_modules/node-dht-sensor
2022-10-21T12:02:14.133Z [err] npm ERR!
2022-10-21T12:02:14.133Z [err] gyp ERR! node -v v12.22.12
2022-10-21T12:02:14.133Z [err] npm ERR!
2022-10-21T12:02:14.134Z [err] gyp ERR! node-gyp -v v3.8.0
2022-10-21T12:02:14.134Z [err] npm
2022-10-21T12:02:14.134Z [err] ERR! gyp ERR! not ok
2022-10-21T12:02:14.206Z [err]
2022-10-21T12:02:14.206Z [err] npm ERR!
2022-10-21T12:02:14.206Z [err] A complete log of this run can be found in:
2022-10-21T12:02:14.206Z [err] npm ERR! /home/pi/.npm/_logs/2022-10-21T12_02_14_140Z-debug.log
2022-10-21T12:02:14.232Z rc=1

Hi @Alsama7ii

Did you do all of the necessary steps to install the library?

tar zxvf bcm2835-1.xx.tar.gz
cd bcm2835-1.xx
./configure
make
sudo make check
sudo make install

Usually you do not have to use sudo to install a node, and you should be in /home/pi/.node-red when you install.
However, these days it is easier to install a node via"Manage Palette" in the editor


Yes, I did all of the necessary steps to install the library. And I have tried to delete node-dht-sensor dependency and the install via "Manage Palette". Still the same error.

... however if you read the readme for this node - then in this case you do... (and you need to run Node-RED as root...) which is also not recommended... Also node v12 is no longer supported...

All in all I really wouldn't use this node... And those DHT sensors are well known to be inaccurate - so again good to avoid if at all possible.

but yes - you need to need t be in the ~/.node-red directory when you install nodes manually.

Indeed inaccurate for measuring relative humidity but for temperature they are pretty OK.

I find they are usually 3-4 degC off - but yes you can compensate.

Maybe that is the case for the dht11, but for the dht22 I have never seen that issue.

1 Like