ESP32S3 I2C Configuration

sw-phung
Posts: 1
Joined: Mon Nov 06, 2023 5:57 am

ESP32S3 I2C Configuration

Postby sw-phung » Mon Nov 06, 2023 5:59 am

I am attempting to configure GPIO4 and GPIO5 of the ESP32S3 for I2C communication. Based on ESPRESSIF's API, I have written the following code for the I2C set up:

#define MST_TX_BUF_LEN 0
#define MST_RX_BUF_LEN 0

static esp_err_t i2c_conf_master(void) {
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = GPIO_NUM_4,
.scl_io_num = GPIO_NUM_5,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = 400000
};
i2c_param_config(I2C_NUM_0, &conf);
return i2c_driver_install(I2C_NUM_0, conf.mode, MST_RX_BUF_LEN, MST_TX_BUF_LEN, 0);
}

void app_main(void) {
ESP_ERROR_CHECK(i2c_conf_master());
}

I require a 400kHz clock signal on GPIO5 to interface with another one of my modules, but the signal appears to jump to 3.2V when I probe it. Looks like a bunch of noise with no particular frequency.

Wondering if anyone else has successfully set up their ESP for I2C? I have purchased my devkit from AliExpress and I am not sure if it could be a missing component issue? (GPIO48 was left open and I had to jump it with a bit of solder for the RGB LED to turn on)

MicroController
Posts: 1708
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: ESP32S3 I2C Configuration

Postby MicroController » Mon Nov 06, 2023 10:11 pm

Your code doesn't transfer any data over I2C. What do you expect to see on the SCL line in this state?

Who is online

Users browsing this forum: Google [Bot] and 88 guests