jjcarstens / dht

Elixir implementation to read DHT11 and DHT22 sensors
Apache License 2.0
17 stars 1 forks source link

DHT22/AM2302 Error when reading: `{:error, -1}` #3

Closed jonlunsford closed 3 years ago

jonlunsford commented 4 years ago

Hi there, thanks for writing this awesome lib. I'm guessing I have a driver mismatch or this particular sensor isn't quite what this lib is expecting, I was hoping to get some pointers on debugging further.

May target is an rpi_0 with an AM2302 connected to 5V and GPIO #4, I do see the Starting DHT Port log, so dht is starting up OK. However, when attempting a read I get:

iex > DHT.read(4, :am2302)
{:error, -1}

I'm guessing -1 is the return from the C lib? Any ideas on getting at the actual error? Fwiw, here's the sensor I'm attempting to use (with built in pull-up resistors):

PXL_20201103_051317222 PXL_20201103_051300162

jjcarstens commented 4 years ago

Sorry @jonlunsford ! I really need to get on watching my own libs... 🤦

What device are you using this with? (beagle bone, raspberypi, etc etc)

For this case, it seems like -1 is referencing DHT_ERROR_TIMEOUT which basically tells me that its getting some weird behavior with the timing of data on the wire. This could be faulty DHT sensor or bad wiring.

GPIO 4 on the rpi also has potential be setup as One-wire protocol pin, which could mess things up here. Have you tried other pins as well?

jonlunsford commented 4 years ago

no worries @jjcarstens! Thanks for the reply.

Hmm, Yeah, I'm using gpio 4 setup with one-wire enabled. I'll attempt another sensor and pin.

Feel free to close this for now, if need be. Not sure when I'll really be able to dig back into this.

Thanks again!

jjcarstens commented 3 years ago

I think we're good on this for now since I'm really able reproduce this outside of using the 1wire pin with that overlay enabled (which would be unexpected behavior anyway)