I2C – ESP32 I2C Circuit

esp32i2c

I am using I2C communication with the ESP32 as the master.

Do I need pull-up/pull-down resistors on the SDA and SCL lines?

I could not find anything on the datasheet that said whether there were internal pull-up/pull-down resistors.

Links to datasheets:

https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf

https://www.espressif.com/sites/default/files/documentation/esp32-wroom-32e_esp32-wroom-32ue_datasheet_en.pdf

Best Answer

Do I need pull-up/pull-down resistors on the SDA and SCL lines?

Yes. 2k2-3k3 is fine.

If you're using one of the off-the-shelf I2C peripherals like the LCD display, IO expanders, etc then warning: most of them require 5V, and ESP32 runs on 3V3.

You must not connect the pullups on the ESP side to +5V, but to 3V3!

I've been using this simple voltage translation schematic with success:

enter image description here

"2.5V" on the left should be 3V3, of course, and the gpio numbers are wrong, but you get the idea. You can use any N MOSFET with low capacitance and threshold Vgs such that it turns on properly when about 3V Vgs. The easiest way is to search for MOSFETs with RdsON of a few ohms or tens of ohms, specified at Vgs of 2.5, and sort by price. Here's the one I'm using. Also very neat for driving loads from a 3V3 GPIO.

Since you now have two pullups on each line instead of one, it's a good idea to double the resistor value to get the same current, so 4k7 instead of 2k2 for example.

Related Topic