DHT11/AM2301 does not work
Posted: Sun Oct 07, 2018 10:03 am
I have ESP12E devkit and AM2301 sensor, a while ago tried that with LUA firmware and it worked well, now trying micropython and it does not, reports timeout on .measure(), debugging (built my own + printf) points to: https://github.com/micropython/micropyt ... /dht.c#L67
The very first (after the am2301 gets powered) call to .measure() actually does not time out and seems succeeded even though .temperature() shows 0 (which it wrong) and consequent calls give "tmeout". Why is that?
Tried different pins, verified with LED that the pin is correct:
>>> p = machine.Pin(13, machine.Pin.OUT)
>>> p.on()
>>> p.off()
Then replaced LED with the am2301 + pullup, reset the esp, and:
>>> import machine, dht
>>> d=dht.DHT11(machine.Pin(13))
>>> d.measure()
>>> d.temperature()
0
>>> d.measure()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "dht.py", line 16, in measure
OSError: [Errno 110] ETIMEDOUT
update:
I added some printfs into the 40bit loop, the ticks (%d) are (but timeout always occurs in 38th or 39th iteration):
25 5 25 25 26 73 25 25 73 74 75 26 73 27 72 25 26 27 27 27 25 25 25 74 26 73 25 26 27 74 25 26 25 26 73 74 26 26 72
which translates to:
04 ea 01 44 99
which does not seem right. Hmmm.
The very first (after the am2301 gets powered) call to .measure() actually does not time out and seems succeeded even though .temperature() shows 0 (which it wrong) and consequent calls give "tmeout". Why is that?
Tried different pins, verified with LED that the pin is correct:
>>> p = machine.Pin(13, machine.Pin.OUT)
>>> p.on()
>>> p.off()
Then replaced LED with the am2301 + pullup, reset the esp, and:
>>> import machine, dht
>>> d=dht.DHT11(machine.Pin(13))
>>> d.measure()
>>> d.temperature()
0
>>> d.measure()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "dht.py", line 16, in measure
OSError: [Errno 110] ETIMEDOUT
update:
I added some printfs into the 40bit loop, the ticks (%d) are (but timeout always occurs in 38th or 39th iteration):
25 5 25 25 26 73 25 25 73 74 75 26 73 27 72 25 26 27 27 27 25 25 25 74 26 73 25 26 27 74 25 26 25 26 73 74 26 26 72
which translates to:
04 ea 01 44 99
which does not seem right. Hmmm.