Weird problem: Sensor only works on GPIO2 !?

Swift42
Posts: 1
Joined: Fri Mar 06, 2020 3:34 pm

Weird problem: Sensor only works on GPIO2 !?

Postby Swift42 » Fri Mar 06, 2020 3:57 pm

Hello,

I have a very weird problem that is driving me crazy:

I have a DHT12 temperature sensor and I'm using this library: https://github.com/xreef/DHT12_sensor_library
This lib should work with every GPIO, because the constructor has a value for the pin: DHT12 dht12([pin], true);
I use the OneWire connection.

The weird thing is: The sensor only works if I connect it to GPIO2 on my Heltec LoRa 32 V2!
But because GPIO2 is involved in the flashing/programming process, I need to disconnect the sensor while flashing. If I reconnect it after the flashing, I get correct values. E.g.:
DHT12=> Humidity: 24.00 % Temperature: 25.30 *C 77.54 *F Heat index: 24.51 *C 76.12 *F Dew point: 3.22 *C 37.80 *F
Because I need to disconnect the sensor, this GPIO is suboptimal.

But if I connect the sensor to ANY other free GPIO (and change the constructor call), the sensor doesn't work!
I tried GPIO0, GPIO17, GPIO23, GPIO22, GPIO12, GPIO13 and GPIO36 to GPIO39.
I always get "DHT12 read error". But why?
All the ports seem to work correctly (e.g. I can connect a LED and let it blink).
If I use a pullup resistor (or not) for the DHT12, this changes nothing: It still works on GPIO2 and it does not work on every other GPIO.
I also tried to use an external power source, but this also changes nothing.

What's so special about GPIO2? And why all other pins aren't working with this sensor? Where's my error?
Please help me.

mikemoy
Posts: 626
Joined: Fri Jan 12, 2018 9:10 pm

Re: Weird problem: Sensor only works on GPIO2 !?

Postby mikemoy » Sat Mar 07, 2020 7:02 pm

I am more curious why you need GPIO2 to flash your device.
GPIO0 is all that is needed.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Weird problem: Sensor only works on GPIO2 !?

Postby WiFive » Sat Mar 07, 2020 11:39 pm

mikemoy wrote:
Sat Mar 07, 2020 7:02 pm
I am more curious why you need GPIO2 to flash your device.
GPIO0 is all that is needed.
https://github.com/espressif/esptool/wi ... tion#gpio2

mikemoy
Posts: 626
Joined: Fri Jan 12, 2018 9:10 pm

Re: Weird problem: Sensor only works on GPIO2 !?

Postby mikemoy » Sun Mar 08, 2020 3:57 am

yes, i am aware of the other bootstrap pins. I took his statement to litterally, as if its part of the active flashing process like tx/rx pins
But because GPIO2 is involved in the flashing/programming process,
Did you go through the DHT12 code to see if the author messed up anywhere ?
it seems he wrote it for more devices than the ESP32.

Who is online

Users browsing this forum: No registered users and 67 guests