Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with temperature sensor connected to GPIO 26 #1726

Open
wailla opened this issue Nov 2, 2024 · 0 comments
Open

Issue with temperature sensor connected to GPIO 26 #1726

wailla opened this issue Nov 2, 2024 · 0 comments

Comments

@wailla
Copy link

wailla commented Nov 2, 2024

Good morning, according to the documentation pins 29 to 40 are used only not in the case of a single panel and that is why I would like to use it to read a sensor, but it keeps giving me error :

fabio@raspberrypi:~/project/projectPanelLed $ sudo python test3.py 
Traceback (most recent call last):
  File "/home/fabio/project/projectPanelLed/test3.py", line 21, in <module>
  File "/usr/local/lib/python3.11/dist-packages/Adafruit_DHT/common.py", line 81, in read
    return platform.read(sensor, pin)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/Adafruit_DHT/Raspberry_Pi_2.py", line 34, in read
    raise RuntimeError('Error accessing GPIO.')
RuntimeError: Error accessing GPIO.

I ask why I can't read sensor if the sensor test code is this.

import time
from rgbmatrix import RGBMatrix, RGBMatrixOptions
import Adafruit_DHT

options = RGBMatrixOptions()
options.rows = 64
options.cols = 64
options.chain_length = 1 # only one panel
options.parallel = 1
options.hardware_mapping = 'regular'
matrix = RGBMatrix(options=options)

DHT_SENSOR = Adafruit_DHT.DHT11
DHT_PIN = 26 # Use an unused pin if there are conflicts

while True:
    humidity, temperature = Adafruit_DHT.read(DHT_SENSOR, DHT_PIN)
    
    if humidity is not None and temperature is not None:
        print(f'Temperature: {temperature:.1f}°C, Humidity: {humidity:.1f}%')
    else:
        print(“Error reading the sensor.”)
    
    time.sleep(2) 

Or the program give me this error

python3 test2.py
Traceback (most recent call last):
  File "/home/fabio/project/projectPanelLed/test2.py", line 59, in <module>
  File "/home/fabio/project/projectPanelLed/test2.py", line 41, in get_sensor_data
RuntimeError: No access to /dev/mem.  Try running as root
whoami
root

PS: the sensor works since with other scripts the required output comes out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant