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

bcm2835_init: Unable to open /dev/mem: Permission denied #4

Closed shooftie closed 8 years ago

shooftie commented 8 years ago

I know that this is not an issue with this package. I'm not sure where else to start a conversation about getting it working.

I am running this on a Pi and am led to believe that the bcm2835 library needs to be run as root.

Does this mean that I must run node-red as root also? I'm worried that this presents a security issue. I am the only user of the Pi but it makes me reluctant to use it for anything sensitive.

bpmurray commented 8 years ago

The real issue here is that it's based on node-dht-sensor which uses the bcm2835 library which itself requires root access. Probably the simplest solution is to rewrite my node to use the WiringPi library - that can now be initialised without being superuser. However, that will require some free time. I'll see what I can do in the near future. In the meantime, if you run node-red as root, it'll work OK.

shooftie commented 8 years ago

Nice, thanks for that. I was hoping you'd say otherwise but at least I now know.

bpmurray commented 8 years ago

I've tried a bunch of things, and I can get it to work not using the BCM library. However, because of timing issues, there's no way to do it without being root. One possible alternative is to separate out the task to monitor the sensors, writing the data to a file, while the NodeRED part would then only have to read the file.

bpmurray commented 8 years ago

For the time being, I'm closing this as a software limitation. When I get time, I'll redo this using a daemon that provides the information in the background.

shooftie commented 8 years ago

Thanks mate. I've put the RPi away for the time being but will pick it up again in the future for sure...

TTVert commented 7 years ago

Any progress on this? I'm in a weird situation where with my other Pi3 install it worked but on this new install i get the same issue "bcm2835_init: Unable to open /dev/mem: Permission denied" I tried to give that file 777 as a test then I got "bcm2835_init: Unable to open /dev/mem: Operation not permitted 31 Dec 22:50:18 - [error] [rpi-dht22:f5826526.273b68] TypeError: failed to initialize"

Dave

whatifwhatelse commented 7 years ago

got same problem and managed to solved that way : I noticed that bcm2835 release 1.52 solved the problem allowing to use /dev/memgpio instead of /dev/men, thus not requiring root access. so to make node-red-contrib-dht-sensor work i ha d to do this :

uninstall old bcm2835.1.38 (simply remove directory install and make new release 1.52 uninstall node-red-contrib-dht-sensor using : sudo npm uninstall --unsafe-perm -g node-red-contrib-dht-sensor uninstall node-red-dht-sensor using : sudo npm uninstall --unsafe-perm -g node-dht-sensor reinstall both items above using sudo npm install --unsafe-perm -g node-dht-sensor sudo npm install --unsafe-perm -g node-red-contrib-dht-sensor

after these operations, node-red dht node worked perfectly.

bpmurray commented 7 years ago

Thanks for the info - I'll add that to the doc.

pakair commented 6 years ago

installed bcm release 1.52 but I still get errors on sudo npm install -g node-dht-sensor Tried the latest bcm 1.56, still errors on the npm command. Is there a solution?