About Us Knowledge Base Community Forum Electronics Toolbox FAQ Shipping & Delivery

Community Forum

Share your projects and post your questions

Search
Register or Sign In
Forum

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

48 Views - Created 6 days ago

6 days ago

Posted by:
Slofware

Users Avatar

When I runn my nodejs program without SUDO i get: bcm2835_init: Unable to open /dev/mem: Permission denied

That's because there is no permission to acces the GPIO, but is there a way to go around that?
Because I'm making a website that runs on a raspberry pi 4 that set's some outputs and counts some inputs.
Maybe I need to set-up the program different ?

6 days ago

Posted by:
andrew

Users Avatar

Location:
United Kingdom

Users Twitter  Users Website  

Unfortunately I do not know of a way to access GPIO without using sudo.  According to the official documentation for the rpio library we use to access the I2C port in nodejs, it needs the root user to access /dev/mem.

 

AB Electronics UK Tech Support

6 days ago

Posted by:
Slofware

Users Avatar

Thanks for the answer, I also had readed that :(

Is there another way to make a basic website (or other GUI) which show's some inputs and outputs?

6 days ago

Posted by:
andrew

Users Avatar

Location:
United Kingdom

Users Twitter  Users Website  

You could use another programming language such as Python which supports I2C and GPIO access without needing root.  To use python and apache together with i2c you need to make www-data a member of the i2c group.

sudo adduser www-data i2c

 

AB Electronics UK Tech Support

Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view, download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.