Problems with the DHT example
-
- Posts: 1
- Joined: Thu Sep 01, 2016 2:47 pm
Problems with the DHT example
Hi to all,
as written in the topic i can get the dht example to work.
>>> import dht
>>> import machine
>>> d = dht.DHT22(machine.Pin(3))
>>> d.measure()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "dht.py", line 13, in measure
OSError: [Errno 110] ETIMEDOUT
>>>
after the error the REPL is frozen and i have to reset the module. m using a esp12 module and a dht22 sensor
as written in the topic i can get the dht example to work.
>>> import dht
>>> import machine
>>> d = dht.DHT22(machine.Pin(3))
>>> d.measure()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "dht.py", line 13, in measure
OSError: [Errno 110] ETIMEDOUT
>>>
after the error the REPL is frozen and i have to reset the module. m using a esp12 module and a dht22 sensor
-
- Posts: 463
- Joined: Wed Apr 08, 2015 5:19 am
Re: Problems with the DHT example
There is no pin with number 3 on esp8266 boards. Available pins are: 0, 2, 4, 5, 12, 13, 14, 15, 16.
On the Pyboard and the WiPy you can use
to see what pins are available, but, alas, on the esp8266 port machine.Pin has no such attribute.
On the Pyboard and the WiPy you can use
Code: Select all
import pb
pyb.Pin.board
Re: Problems with the DHT example
Actually there is gpio3, but it's used for the UART connection. You can use it for other things if you don't use UART.
Of course, if you start using it, the REPL, which uses UART, will stop working.
Of course, if you start using it, the REPL, which uses UART, will stop working.
-
- Posts: 15
- Joined: Thu Aug 04, 2016 3:04 pm
Re: Problems with the DHT example
I'm getting the "ETIMEDOUT" message every time I try to use a DHT22 (AM2302) as well. I'm using a Lolin NodeMCU V3. I've tried with and without a pullup resistor. The device works fine on a WiPy (without a pullup resistor). I've even tried configuring the pin as output and toggling it just to make sure I have the pin numbering correct (NodeMCU pin number isn't same as GPIO #).
Is this a time/frequency issue? machine.freq() returns 80000000. I tried machine.freq(160000000) and then running the code but no joy.
Code: Select all
>>> from machine import Pin
>>> import dht
>>> d=dht.DHT22(Pin(14))
>>> d.measure()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "dht.py", line 13, in measure
OSError: [Errno 110] ETIMEDOUT
-
- Posts: 15
- Joined: Thu Aug 04, 2016 3:04 pm
Re: Problems with the DHT example
After rewiring my circuit onto a different proto board, it appears to be working now. Same NodeMCU and same sensor. There must have been a faulty connection. It does not appear to need a pullup resistor; the internal pullup appears to be sufficient, at least for short leads to the sensor.
Re: Problems with the DHT example
[quote="SpotlightKid"]There is no pin with number 3 on esp8266 boards. Available pins are: 0, 2, 4, 5, 12, 13, 14, 15, 16.
On the Pyboard and the WiPy you can use
[code]import pb
pyb.Pin.board[/code]
to see what pins are available, but, alas, on the esp8266 port [i]machine.Pin[/i] has no such attribute.[/quote]
Why I can't import this library? I am using esp8266 WeMos D1
On the Pyboard and the WiPy you can use
[code]import pb
pyb.Pin.board[/code]
to see what pins are available, but, alas, on the esp8266 port [i]machine.Pin[/i] has no such attribute.[/quote]
Why I can't import this library? I am using esp8266 WeMos D1
-
- Posts: 463
- Joined: Wed Apr 08, 2015 5:19 am
Re: Problems with the DHT example
The "pyb" module isn't present on the esp8266 port, the Pin class is in the "machine" module, but it (annoyingly) has a slightly different interface.
Re: Problems with the DHT example
All gpio pins, 0-16, are "available". Some of them will just have undesirable side effects if you start using them. The pins 1 and 3 are used for the UART, the pins 6-11 for the flash memory. They are left available because they may be useful if you are careful and know what you are doing.
Re: Problems with the DHT example
Sorry I didn't quite get why the pin could not be read by the DHT.py (i'm on pin 4)
Or what do I have to change to let it read pin 4.
This on a Wemos D1 mini (pro)
Or what do I have to change to let it read pin 4.
This on a Wemos D1 mini (pro)
Re: Problems with the DHT example
First of all, what *physical* pin are you connecting to? The pin marked D4 on the D1 Mini is actually pin 2, and the pin 4 is marked on the D1 Mini as D2...