1
\$\begingroup\$

I have a question that has really confused me. I connected an ESP32 to an AHT20 (an I2C-based temperature and humidity sensor) powered by 5V.

enter image description here

I connected the sensor directly to the ESP32 and checked the SCL and SDA pins, which showed a voltage of 5V. My question is, why wasn't the ESP32 damaged by this 5V connection? I looked at the datasheet for the development board, but I couldn't find any level shifters or protection circuits.

enter image description here

Then I add MOSFET base level shifter in between esp32 and AHT20 sensor thats works too

enter image description here

enter image description here

Can I connect 5V I2C sensors directly to an ESP32 S3 Mini if I make my own PCB board, or should I use a MOSFET-based level shifter?

\$\endgroup\$
2
  • \$\begingroup\$ The esp32 and the AHT20 are both 3.3v devices. What is the level shifter for? \$\endgroup\$ Commented Jul 31 at 12:40
  • \$\begingroup\$ I would use 3.3V as supply for AHT20 as suggested by @user1850479 when making a custom board. Also, for reliable operation across boards and time, it's better to use a translation circuit unless explicitly stated as a higher voltage capable pin by the manufacturer. \$\endgroup\$ Commented Jul 31 at 13:11

1 Answer 1

2
\$\begingroup\$

My question is, why wasn't the ESP32 damaged by this 5V connection?

ESP32 could possibly be damaged, since the AHT20's I2C pullup resistors try to pull up to +5V, which exceeds ESP32's 3.3V VDD supply. This causes a small current to flow the wrong way, into ESP32 I2C pins. Wrong-way currents can cause the ESP32 to seize into latch-up, even when present momentarily.

Since ESP32 I/O pins are very likely protected by clamping diodes which conduct wrong-way currents, latch-up seems prevented. These wrong-way currents are sourced through AHT20's pull-up resistors to its +5V supply. Pull-up resistors are apparently of large enough value that current is small enough that ESP32's clamping diodes are effective.

Wrong-way GPIO currents should never be allowed. The obvious solution would be to power AHT20 from a 3.3V supply rather than 5V supply as @EarthLord has suggested...

Could you tap some power from ESP32's 3.3V DC regulator? That might be possible, if the regulator can handle the extra 980 uA DC supply current required by AHT20.

Otherwise, AHT20 might be powered from its own 3.3V regulator from the +5V source.
Another crude solution drops 5V down to about 3.7V by powering AHT20 through two silicon diodes (which drop about 0.6V each).

\$\endgroup\$
2
  • \$\begingroup\$ In his diagram I believe he actually has it connected to the 3.3V pin (although he covered the 3.3V label with "5V" for some reason. \$\endgroup\$ Commented Jul 31 at 14:20
  • \$\begingroup\$ @user1850479 If a measurement of AHT20 I2C pins was "+5V", then it is unlikely that AHT20 is powered from +3.3V. But the scenario I've outlined, where AHT20's I2C pins connect directly to ESP32's I2C pins (with AHT20 powered from +5V), then the clamping diodes inside ESP32 should reduce the measured voltage on an idle I2C pin to something like +4V, not +5V. Perhaps that +5V measurement was made with I2C pins open-circuit? \$\endgroup\$ Commented Jul 31 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.