Issue
This is what i did:
git clone https://github.com/adafruit/Adafruit_Python_DHT.git
cd Adafruit_Python_DHT
sudo apt-get install build-essential python-dev
sudo python setup.py install
This^ was given in the github link itself. I did this and my code worked perfectly with DHT11 sensor in python 2.x but its failing with python 3. The error that I'm getting is:
RuntimeError: Error accessing GPTO. Make sure program is run as root with sudo!
My code is:
import Adafruit_DHT
import time
while True:
time.sleep(1)
humidity, temperature = Adafruit_DHT.read_retry(Adafruit_DHT.DHT11,4)
print(temperature)
print(humidity)
Works perfectly well with python 2, the issue is with python 3. I'm using a Raspberry Pi3 B for the GPIO interface.
Edit:
I tried sudo python temper.py
and it works again, but sudo python3 temper.py
still doesn't work, with one small change, it doesn't give any errors but now the output is
None
None
None
None
basically, 'None' appears in place of the sensor value for Temperature and Humidity.
Solution
Since you are using Python 3 please install the library using the right command:
sudo python3 setup.py install
Answered By - Pitto