bpmurray / node-red-contrib-dht-sensor

Node-RED node to process DHT11/22 sensor data
Apache License 2.0
7 stars 8 forks source link

Using dht node within Node-red running in docker #18

Open cowboy28 opened 5 years ago

cowboy28 commented 5 years ago

I have Nodered running within Docker and managing it with Portainer. I get nothing but "typeErrors" when running dht-sensor. The dht node works great when nodered is running without docker.

I've also installed "pi-gpiod" for virtualized GPIO pins...didn't help.

Thank you for the help!

bpmurray commented 5 years ago

No idea - I'm not using Docker so can't test it! I'll have a look at what it might take.

pavelantolik commented 2 years ago

@bpmurray @cowboy28 any luck resolving this issue? I've just recently installed IOTstack on my RPI4 (so the Node RED runs in Docker container) and I am getting the same error. Funnily enough, I used to run the same stack before my card got corrupted (without backup) and everything worked just fine back then.

bpmurray commented 2 years ago

@pavelantolik @cowboy28 I have no idea! It sounds very much like Docker is doing something but I can't see what it might be. If you had it running before, I'm guessing you had some setting that made all the difference but you lost that when your card was corrupted. Just FYI I haven't been maintaining this & haven't looked at it in years.

pavelantolik commented 2 years ago

@bpmurray @cowboy28 Yeah i thought this was no longer maintained but I had to give it a try as after many hours trying to make it work I got a bit desperate .))

Anyway, as it usually happens to me, I managed to solve it a short while after posting my question. so if anyone runs into "TypeError: failed to initialize" when trying to read DHT11 with node-red-contrib-dht-sensor package's node running in IOTstack docker container, the solution that worked for me was this:

Editing Node Red's Dockerfile and adding lines of code that install:

  1. BCM2835 library
  2. node-dht-sensor npm package
  3. node-red-contrib-dht-sensor package

This alone wasn't enough though, so I also had to edit docker-compose.yml a bit:

  1. Adding flag to run node-red docker in privileged mode
  2. Mapping "/dev/mem/" just to be "sure"

Some of the steps might not even be necessarry, but I didn't have time to rule 'em out yet. Hopefully this will help someone in the future as google didn't seem to have heard about this particular issue.

bpmurray commented 2 years ago

Thanks for that info - I'll update the README so that people can use it.