Esp32 IDF release/5.0 running on ESP32S3 Feather I2C problem
-
- Posts: 5
- Joined: Sat Jan 07, 2023 8:03 pm
Esp32 IDF release/5.0 running on ESP32S3 Feather I2C problem
Hi all,
I’m unable to detect an I2c device when running the example I2c code that scans the bus for I2c devices.
I expect that it should discover the LC709203 but the scan discovers nothing and times out.
I’m using release/5.0, I’m currently at the tip of this release branch but it still doesn’t work, however I have had success with arduino ide which works without failure. With Arduino ide I can read voltages, IC version etc.
Can anyone share their experiences with ESP32S3 feather and espidf accessing the LC709203 battery monitor via I2C. I’m using VsCode on Ubuntu, if it matters that much.
Are you aware of any impending fixes that are due specifically for S3 Feather?
Thanks all!
I’m unable to detect an I2c device when running the example I2c code that scans the bus for I2c devices.
I expect that it should discover the LC709203 but the scan discovers nothing and times out.
I’m using release/5.0, I’m currently at the tip of this release branch but it still doesn’t work, however I have had success with arduino ide which works without failure. With Arduino ide I can read voltages, IC version etc.
Can anyone share their experiences with ESP32S3 feather and espidf accessing the LC709203 battery monitor via I2C. I’m using VsCode on Ubuntu, if it matters that much.
Are you aware of any impending fixes that are due specifically for S3 Feather?
Thanks all!
Re: Esp32 IDF release/5.0 running on ESP32S3 Feather I2C problem
Do you have a minimal working code or similar which you can post?
In my experience with I2C the pins are important. So please mention the SCL and SDA carefully.!
In my experience with I2C the pins are important. So please mention the SCL and SDA carefully.!
-
- Posts: 5
- Joined: Sat Jan 07, 2023 8:03 pm
Re: Esp32 IDF release/5.0 running on ESP32S3 Feather I2C problem
Hi @ujurmsde
Thanks for quick response.
The example I'm running ultimately boils down to this call which is supposed to detect the device. It can be found in /esp/esp-idf/examples/peripherals/i2c/i2c_tools
And this is the output it produces, note I'm using pin 3 and 4 for sda and scl respectively.
Do you also have an S3 feather and is your I2C comms ok with release/5.0?
Any thoughts?
Cheers,
RedPin.
Thanks for quick response.
The example I'm running ultimately boils down to this call which is supposed to detect the device. It can be found in /esp/esp-idf/examples/peripherals/i2c/i2c_tools
Code: Select all
static int do_i2cdetect_cmd(int argc, char **argv)
{
i2c_driver_install(i2c_port, I2C_MODE_MASTER, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0);
i2c_master_driver_initialize();
uint8_t address;
printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\r\n");
for (int i = 0; i < 128; i += 16) {
printf("%02x: ", i);
for (int j = 0; j < 16; j++) {
fflush(stdout);
address = i + j;
i2c_cmd_handle_t cmd = i2c_cmd_link_create();
i2c_master_start(cmd);
i2c_master_write_byte(cmd, (address << 1) | WRITE_BIT, ACK_CHECK_EN);
i2c_master_stop(cmd);
esp_err_t ret = i2c_master_cmd_begin(i2c_port, cmd, 50 / portTICK_PERIOD_MS);
i2c_cmd_link_delete(cmd);
if (ret == ESP_OK) {
printf("%02x ", address);
} else if (ret == ESP_ERR_TIMEOUT) {
printf("UU ");
} else {
printf("-- ");
}
}
printf("\r\n");
}
i2c_driver_delete(i2c_port);
return 0;
}
Code: Select all
| Steps to Use i2c-tools |
| |
| 1. Try 'help', check all supported commands |
| 2. Try 'i2cconfig' to configure your I2C bus |
| 3. Try 'i2cdetect' to scan devices on the bus |
| 4. Try 'i2cget' to get the content of specific register |
| 5. Try 'i2cset' to set the value of specific register |
| 6. Try 'i2cdump' to dump all the register (Experiment) |
| |
==============================================================
Type 'help' to get the list of commands.
Use UP/DOWN arrows to navigate through command history.
Press TAB when typing command name to auto-complete.
i2c-tools> i2cconfig --port=0 --freq=100000 --sda=3 --scl=4
W (32623) cmd_i2ctools: Bus is busy
i2c-tools>
Any thoughts?
Cheers,
RedPin.
Re: Esp32 IDF release/5.0 running on ESP32S3 Feather I2C problem
In those examples it tells to select the correct I2C SDA and SCL pins from menuconfig. Have you done that?
-
- Posts: 5
- Joined: Sat Jan 07, 2023 8:03 pm
Re: Esp32 IDF release/5.0 running on ESP32S3 Feather I2C problem
Reading https://github.com/espressif/esp-idf/bl ... /README.md which is the tool I’m trying to use the pins can be configured by using the i2cconfig command.
Do you use the s3 feather?
Do you use the s3 feather?
Re: Esp32 IDF release/5.0 running on ESP32S3 Feather I2C problem
No. I do not have S3 feather yet.
What I do normally to test i2c is define some function to initialize the i2c. Then there are methods to do write/read transactions at particular port/pin.
What I do normally to test i2c is define some function to initialize the i2c. Then there are methods to do write/read transactions at particular port/pin.
static esp_err_t i2c_master_init(void){
int i2c_port = CONFIG_I2C_MASTER_PORT;
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = CONFIG_I2C_MASTER_SDA_IO,
.scl_io_num = CONFIG_I2C_MASTER_SCL_IO,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = I2C_MASTER_FREQ_HZ,
};
i2c_param_config(i2c_port, &conf);
return i2c_driver_install(i2c_port, conf.mode, 0, 0, 0);
}
-
- Posts: 5
- Joined: Sat Jan 07, 2023 8:03 pm
Re: Esp32 IDF release/5.0 running on ESP32S3 Feather I2C problem
Yep, I agree with that.
However, the pins can be reconfigured by running the config command, overriding the defaults and replacing them with the users choice.
The driver install and initialise functions are called by running the detect command.
And master initialise looks like this
Are you able to test out the detect project on your board and run the commands as I have done? Obviously use your own pin. Umbers that are appropriate for your board. This would at least validate what I’m doing.
Also which idf version are you using?
Any idea when your s3 feather is turning up?
Apologies for so many question but it takes a while for my post to get reviewed so thought I’d get as many possible questions in as possible
Cheers!
However, the pins can be reconfigured by running the config command, overriding the defaults and replacing them with the users choice.
The driver install and initialise functions are called by running the detect command.
Code: Select all
static int do_i2cdetect_cmd(int argc, char **argv)
{
i2c_driver_install(i2c_port, I2C_MODE_MASTER, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0);
i2c_master_driver_initialize();
uint8_t address;
printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\r\n");
for (int i = 0; i < 128; i += 16) {
printf("%02x: ", i);
<snip>
Code: Select all
static esp_err_t i2c_master_driver_initialize(void)
{
i2c_config_t conf = {
.mode = I2C_MODE_MASTER,
.sda_io_num = i2c_gpio_sda,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_io_num = i2c_gpio_scl,
.scl_pullup_en = GPIO_PULLUP_ENABLE,
.master.clk_speed = i2c_frequency,
// .clk_flags = 0, /*!< Optional, you can use I2C_SCLK_SRC_FLAG_* flags to choose i2c source clock here. */
};
return i2c_param_config(i2c_port, &conf);
}
Are you able to test out the detect project on your board and run the commands as I have done? Obviously use your own pin. Umbers that are appropriate for your board. This would at least validate what I’m doing.
Also which idf version are you using?
Any idea when your s3 feather is turning up?
Apologies for so many question but it takes a while for my post to get reviewed so thought I’d get as many possible questions in as possible
Cheers!
Re: Esp32 IDF release/5.0 running on ESP32S3 Feather I2C problem
My apologies for late reply. Now I got some time to test the i2c functionality on the ESP-IDF-V5 and I also realised that it is not working.
So I guess I will have to debug the issue.
So I guess I will have to debug the issue.
-
- Posts: 5
- Joined: Sat Jan 07, 2023 8:03 pm
Re: Esp32 IDF release/5.0 running on ESP32S3 Feather I2C problem
Hi,
thanks for getting back to me. Which board did you try it on?
thanks for getting back to me. Which board did you try it on?
Re: Esp32 IDF release/5.0 running on ESP32S3 Feather I2C problem
I found on the S3 Feather I needed to add additional pull-up strength to get the LC709203 to respond reliably. Try adding 2k-5k additional resistors between the two I2C lines and a 3.3V source. I've monitored the i2c pins with my scope and can see that without additional pullup strength the pulse rise time is extremely sluggish and never even reaches 3V peak. The documentation mentions there are already 5k resistors, but looking at the schematic I can see they're actually 10k resistors, which should be barely enough for low speed i2c but in practice don't work reliably with the LC709203.
Please let me know if this helps!
Please let me know if this helps!
Who is online
Users browsing this forum: No registered users and 266 guests