ESP32 and 5V I2C sensors

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.

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.

Then I added a MOSFET level shifter between the ESP32 and AHT20 sensor, and it works too.

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?

Often, internal signal limiting circuits will offer enough protection for one to ‘get away with’ such abuses for short periods of time. It is, however, extremely unwise to depend on this to work indefinitely.

The datasheet of the ESP tells in a section named "Absolute maximum voltages" for the various pins.

Depending on what AHT20 module you have, you can feed it with 3V3 and not worry anymore with pin abuse or logic level shifter.

The module sold here works with 3V3...

How you know that? Because magic smoke didn't puff out immediately?
Esp32 is quite robust and lot of people here are abusing those, but that doesn't mean they don't get damaged.

You should read and understand the datasheets for every component you use in your design.
What does the ESP32-S3 datasheet say about the maximum and recommended voltage on a GPIO?

maybe simpler to switch to the bme280-arduino-ide-pressure-temperature-humidity - works OK with the ESP32 at 3.3V

I would use one of two ICs: the PCA9306 or the TXS0108E. The latest I²C specification defines a logic high as greater than or equal to 0.7 times the supply voltage, and a logic low as less than or equal to 0.3 times the supply voltage. For a 5V system, that means a high is 3.5V or above (0.7 × 5V), and a low is 1.5V or below (0.3 × 5V).

In the past the Logic level thresholds could vary between devices depending on the technology used to manufacture the chip, so it's important to verify compatibility when connecting different components.

Without knowing about your specific board I'm going to guess it has a 5V to 3.3v regulator on the AHT20 board. And likely the output of the sensor is 3.3v. This is a guess, it must be verified. If you have a multimeter (even a cheap one is recommend for a hobbyist) you can measure the voltage on the Chip of the AHT20.

And the level shifter you drew will not work. It is much too slow for I2C.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.