d2r2 / go-dht

Golang library to interact with DHT11/DHT22/DHT12 temperature and humidity sensors from Raspberry PI.
MIT License
133 stars 52 forks source link

Ubuntu Server 20.04.1 on Raspberry Pi 3B V2.1: "NewDHT error: pin out high error: sysfs-gpio (GPIO17): sysfs gpio is not initialized" #27

Closed VictorSesma closed 3 years ago

VictorSesma commented 3 years ago

Hello!

I have been trying to use the first reading example in the code.

As said in the title I am using Ubuntu server 20.04 64bits. I have tested this on Ubuntu 20.10 also. Checked in all 64 and 32 bits editions.

The thermometer works on Raspbian just fine using this library but it doesn't on Ubuntu. This is the error:

[     dht] WARN  Error during call C.dial_DHTxx_and_read(): failed to open GPIO export for writing

The thermometer model is AOSONG AM2302

Do you know how this could be fixed?

Thanks a lot!

VictorSesma commented 3 years ago

Note: I also tried to use this other library and failed.

VictorSesma commented 3 years ago

Hello! The problem is fixed running the Go program with sudo. Lol. I guess there must be a way for giving permision to my user to run GPIO but I haven't investigated futher.

I close this issue now.

Thanks!