Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

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

The ADC Pi is an Analogue to Digital converter for the Raspberry Pi

22/05/2020

Posted by:
Slofware

Slofware 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 ?

22/05/2020

Posted by:
andrew

andrew Avatar

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.

22/05/2020

Posted by:
Slofware

Slofware 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?

22/05/2020

Posted by:
andrew

andrew Avatar

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

Sign in to post your reply


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.

Home

Shop

Learn

Forum

FAQ

Contact

0 item

Your cart is empty

Please browse our shop to order from the wide range of Raspberry Pi boards and accessories.

Subtotal:£0.00
View Basket Continue to Checkout