Unable to use DHT on pins 4, 5 & 15

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Unable to use DHT on pins 4, 5 & 15

Post by devnull » Sat Mar 11, 2017 9:22 am

Device is ESP-12F (8266).

I am unable to read DHT sensor on PIN 4 & 5, it works OK on pin 0.

I have tested pins 4 & 5 as an input buy pulling high and reading value and as an output by connecting a LED, both work fine and as expected

There is nothing else connected to pins 4 & 5, attempting to measure() on 4 or 5 results in a ETIMEDOUT error:

Code: Select all

>>> import dht
>>> import machine
>>> d = dht.DHT22(machine.Pin(4))
>>> d.measure()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "dht.py", line 13, in measure
OSError: [Errno 110] ETIMEDOUT

>>> import dht
>>> import machine
>>> d = dht.DHT22(machine.Pin(5))
>>> d.measure()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "dht.py", line 13, in measure
OSError: [Errno 110] ETIMEDOUT

>>> d = dht.DHT22(machine.Pin(0))
>>> d.measure()
>>> d.temperature()
28.99999

I have already designed and routed my PCB based on using 2 x dht devices one on 4 and the other on 5 and I would rather not throw it in the bin and re-design the board !

I also just tested on pin 15, that also fails, pins 0 & 2 work ?!

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: Unable to use DHT on pins 4, 5 & 15

Post by devnull » Sat Mar 11, 2017 10:00 am

OK, just found the cause, there's no on-board pullup so you need to use the soft pullups:

Code: Select all

DHT22(machine.Pin(5,machine.Pin.IN, machine.Pin.PULL_UP))

Post Reply