Skip to content
This repository was archived by the owner on Nov 12, 2019. It is now read-only.

Commit 9297cd6

Browse files
author
nicolas-rabault
committed
Allow no root to use gpio for raspberry pi
1 parent 9e8109b commit 9297cd6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Adafruit_DHT/Raspberry_Pi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def read(sensor, pin):
3131
# Signal no result could be obtained, but the caller can retry.
3232
return (None, None)
3333
elif result == common.DHT_ERROR_GPIO:
34-
raise RuntimeError('Error accessing GPIO. Make sure program is run as root with sudo!')
34+
raise RuntimeError('Error accessing GPIO.')
3535
elif result != common.DHT_SUCCESS:
3636
# Some kind of error occured.
3737
raise RuntimeError('Error calling DHT test driver read: {0}'.format(result))

source/Raspberry_Pi/pi_mmio.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ volatile uint32_t* pi_mmio_gpio = NULL;
3737

3838
int pi_mmio_init(void) {
3939
if (pi_mmio_gpio == NULL) {
40-
int fd = open("/dev/mem", O_RDWR | O_SYNC);
40+
int fd = open("/dev/gpiomem", O_RDWR | O_SYNC);
4141
if (fd == -1) {
42-
// Error opening /dev/mem. Probably not running as root.
42+
// Error opening /dev/gpiomem.
4343
return MMIO_ERROR_DEVMEM;
4444
}
4545
// Map GPIO memory to location in process space.

0 commit comments

Comments
 (0)