Dht sensor error

16-06-09 18:20:19 homeassistant.components.sensor: Error while setting up platform dht
Traceback (most recent call last):
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 109, in _setup_platform
    discovery_info)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/sensor/dht.py", line 61, in setup_platform
    dev.append(DHTSensor(data, variable, unit, name))
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/sensor/dht.py", line 81, in __init__
    self.update()
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/sensor/dht.py", line 100, in update
    self.dht_client.update()
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/util/__init__.py", line 289, in wrapper
    result = method(*args, **kwargs)
  File "/srv/hass/hass_venv/lib/python3.4/site-packages/homeassistant/components/sensor/dht.py", line 125, in update
    self.pin)
  File "/home/hass/deps/Adafruit_DHT/common.py", line 90, in read_retry
    humidity, temperature = read(sensor, pin, platform)
  File "/home/hass/deps/Adafruit_DHT/common.py", line 77, in read
    return platform.read(sensor, pin)
  File "/home/hass/deps/Adafruit_DHT/Raspberry_Pi_2.py", line 34, in read
    raise RuntimeError('Error accessing GPIO. Make sure program is run as root with sudo!')
RuntimeError: Error accessing GPIO. Make sure program is run as root with sudo!

I added hass user to gpio,root,sudo groups and still the same error

1 Like

If you’re logged in as the hass user, can you manually use GPIO without getting any errors?

1 Like

No. im logged in as pi via putty. pi user and hass user are in root,gpio,sudo groups

Hmm…

Is there any particular reason why you won’t simply run
sudo hass

That would be the easiest way

well i have installed HA with the AiO installer. and im not good at linux. and HA runs at boot soo :S

Aah. I’ve not really looked much into the AiO installer I’m afraid. Give me a sec

1 Like

Okay, first things first.
Did you run the AiO installer as sudo?

Assuming you did, I can’t quite get my head around some design choices for the installer…
The all in one installer makes an entry in systemd, which is a service that autostarts programs, amongst other things. My question to the creators of the installer is: why not make sure that entry gets root rights right away?

Next problem.
If you manually edit the systemd entry, to run hass as root, the directory with configuration files will change too, to /root/.homeassistant/

Actually, now that I’ve typed that…
The AiO installer is supposed to be ran on the lastest Raspbian version.
On that version, root should not be required to acces the GPIO.

Did you use a Raspbian Jessie image?

jepp. downloaded just yesterday. Just let me check if i can use rpi2 GPIO as switch

Yeah, GPIO can be used as switch. but dht its down

Hmm, so it’s related to none of what I’ve looked into :sweat_smile:

1 Like

Maybe its the sensor itself. but I tested on my arduino and its working.

You could try out different GPIO pins maybe?

tried 13, 23 :S nope :stuck_out_tongue:

Hmm, only thing I can think of is at this point that the Adafruit DHT library is not yet optimised for using GPIO as non-root.
Only fixes to this would be to run hass as root (see problems above) or open a bug report on the DHT sensor component.

I’ve manually installed HASS, and I run it as root. I can access my DHT no problem

currently im receiving data from dht dht connected to ARDUINO digital pin (even that its not supported)

1 Like

Yeah but i have hass user. hass user its member of the root group, GPIO group …

Any idea to use dht from arduino ?

I think that by doing it that way you’re simply reading the analog value from the Arduino pin.

I don’t know how proficient you are in arduinos but you could set your Arduino up to publish DHT data to your HASS installation by using MQTT

Maybe look into getting an ESP8266. They’re cheap, have wireless capabilities, and can be programmed from the arduino IDE after some fiddling.

currently im pushing data to HA via USB. yeah ESP8266 are really cheap, but i need to wait more than 3 weeks to receive them. in my situation, i like to keep thing wired up so ill appreciate if u can find me a tutorial for MQTT over serial communication. cause i cant find nothing :S