I have DHT22 sensor hooked up to my Raspberry Pi2 running default Raspbian image. I have similar setup on Raspberry Pi B and it is working. I am using Adafruit library for DH22. However when I try running the code to read data from DHT22 I get the following exception (using the example code that comes with library):
Traceback (most recent call last): File "AdafruitDHT.py", line 41, in <module> humidity, temperature = Adafruit_DHT.read_retry(sensor, pin) File "build/bdist.linux-armv7l/egg/Adafruit_DHT/common.py", line 90, in read_retry File "build/bdist.linux-armv7l/egg/Adafruit_DHT/common.py", line 77, in read File "build/bdist.linux-armv7l/egg/Adafruit_DHT/Raspberry_Pi_2.py", line 34, in read RuntimeError: Error accessing GPIO.
I have found on internet that the exception it related to lack of permission and that running the code as sudo should fix the problem. But I had no luck so far with it.
I have tried running the code as:
python AdafruitDHT.py 2302 4
sudo python AdafruitDHT.py 2302 4
su - python AdafruitDHT.py 2302 4
However all ways yield the same exception. How can I fix this problem?