I'm Stuck - ESP32-S3-DevKitC-1 No I2C Communications

Greetings,

I have a new ESP32-S3-DevKitC-1 board, at least that's what I think it is (it has a tell-tale onboard addressable RGB LED on GPIO38). Right out of the box running the Arduino IDE v2.3.3 on a 14" Dell Latitude 7480 Core i7 laptop with Windows 11 Pro, I was able to blink a regular Red Led. Next I bought a bag of 0.96" I2C SSD1306 white OLED displays that I will eventually need in my project. The first step for me was to get the 0.96" I2C OLED displays working. I have been able to use the same I2C OLED displays with the previous version ESP32 DevKitC v4 board.

I know the ESP32-S3-DevKitC-1 board has two native I2C ports, and that I can use most any two GPIO pins for SCL and SDA. So I studied some tutorials on Rui Santos' excellent RANDOM NERD TUTORIALS site:

  1. ESP32: I2C Scanner (Arduino IDE) – Finding the Address of I2C Devices
  1. ESP32 I2C Communication: Set Pins, Multiple Bus Interfaces and Peripherals (Arduino IDE)

The one thing I am missing is what the default GPIO pins are used for the two default I2C ports on the ESP32-S3-DevKitC-1 board. But I don't think that should matter, I will just pick two GPIO pins and use those in the I2C scanner sketch. So I chose to use GPIO4 for SCL, and GPIO5 for SDA. Here is my I2C bus scanner sketch modified for those two I2C SCL and SDA pins. The SCL and SDA pins on the OLED display has on board 3.9K pull-up resistors. The I2C scanner sketch compiles without errors or warnings. But it always just prints "Scanning... No I2C devices found" on the Serial Monitor. There's a schematic in the header comments of the sketch below. I must be doing something dumb. Anyone spot something wrong? Thanks, David

/**********************************

      ESP32-S3 I2C Scanner
     OLED          ESP32-S3
 +----------+    +----------+
 |       GND|----|GND       |
 |       VCC|----|3V3       |
 |       SCL|----|GPIO4     |
 |       SDA|----|GPIO5     |
 +----------+    +----------+

Posted by Rui Santos: https://randomnerdtutorials.com/esp32-i2c-scanner-arduino/
Output is always:
Scanning...
No I2C devices found

Hardware:
ESP32-S3-DevKitC-1: https://www.amazon.com/dp/B0D9W4Y3F3
0.96" White SSD1306 I2C OLED Display: https://www.amazon.com/dp/B09T6SJBV5
**********************************/

#include <Wire.h>

void setup() {
  //Wire.begin(I2C_SDA, I2C_SCL);
  Wire.begin(5, 4);
  Serial.begin(115200);
  Serial.println("\nI2C Scanner");
}

void loop() {
  byte error, address;
  int nDevices;
  Serial.println("Scanning...");
  nDevices = 0;
  for(address = 1; address < 127; address++ ) {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
    if (error == 0) {
      Serial.print("I2C device found at address 0x");
      if (address<16) {
        Serial.print("0");
      }
      Serial.println(address,HEX);
      nDevices++;
    }
    else if (error==4) {
      Serial.print("Unknow error at address 0x");
      if (address<16) {
        Serial.print("0");
      }
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0) {
    Serial.println("No I2C devices found\n");
  }
  else {
    Serial.println("done\n");
  }
  delay(5000);
}

if I run

// ESP32 I2C detect

#include <Wire.h>
#include <i2cdetect.h>

#define I2C_SDA 4
#define I2C_SCL 5

void setup() {
  Wire.begin(I2C_SDA, I2C_SCL);
  //Wire.begin();
  Serial.begin(115200);
  Serial.println("i2cdetect example\n");
  Serial.print("Scanning address range 0x03-0x77\n\n");
  
}

void loop() {
  i2cdetect();
  delay(2000);
}

with a 0.96" I2C SSD1306 connected to GPIO 4 and 5 I get

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

if I run your program of post 1 (changing GPIO pins to suit) I get

Scanning...
I2C device found at address 0x3C
done

EDIT: once the device is found try the esp8266-oled-ssd1306 library examples

Wires backward?

@horace, thank you for your help. But...

Are you CERTAIN you are using an ESP32-S3-DevKitC-1 board when you say you successfully tested the I2C scanner on the I2C OLED board?

I moved from the troublesome ESP32-S3-DevKitC-1 board over to an older ESP32-DevKitC-V4 board and the I2C scanner immediately found the I2C OLED display at address 0x3C, just like your results.

But when I move back to the ESP32-S3-DevKitC-1 board, the I2C scan never works. In the Serial Terminal it just reports:

Scanning...
No I2C devices found

When I am using the ESP32-S3-DevKitC-1 board in Arduino IDE v2.3.3 I must set the following:

Tools > Board: "ESP32S3 Dev Module"
Tools > Port: "COM7" <- This is how the ESP32-S3's USB port (not UART port) enumerates
Tools > USB CDC On Boot: "Enabled" <- With the ESP32-S3 only, this must be "Enabled" for the IDE's Serial Monitor to work

Note: Without the USB CDC On Boot: set to "Enabled", the Serial Monitor in the Arduino IDE does not work with the ESP32-S3-DevKitC-1 board. But the Serial Monitor with the ESP32-DevKitC-V4 works regardless of how the USB CDC On Boot: is set.

When I go back to the older ESP32-DevKitC-V4 board, and change the IDE settings to:

Tools > Board: "ESP32 Dev Module"
Tools > Port: "COM8"

With the I2C OLED display plugged in the serial monitor reports:

Scanning...
I2C device found at address 0x3C
done

@horace: Once again... Are you CERTAIN you are using an ESP32-S3-DevKitC-1 board when you successfully test the I2C scanner? The more testing I do, the more I am convinced that the I2C device discovery problem has something specifically to do with the ESP32-S3-DevKitC-1 boards. The ESP32-DevKitC-V4 boards I have work fine with the I2C scanner. I have three brand new ESP32-S3-DevKitC-1 boards, all three S3 boards blink a LED fine, but none of the three S3 boards can communicate over I2C with the I2C scanner sketch. Does anyone have any ideas about this? Thank you, David

@sonofcy you said: "Wires backward?"

Nope, SDA SCL wires are not backwards. I just triple-checked. This has something specific to do with the ESP32-S3-DevKitC-1 boards. I am not having this I2C device discovery problem with the older ESP32-DevKitC-v4 boards. Thanks anyway, David

Using --
Wire.begin();
it looks like SCL should be on GPIO22 and SDL should be on GPIO21

ESP32_dev_board_pinout-1536x746.jpg (1536×746)

What board are you picking in the Boards menu, I find NO match.

There is a LOLIN S3

Post a link which refers to this exact board. There is something odd that you need to do this:

Because the board has a usb/uart chip. The above is required for native USB only.

Maybe post also a photo of your wiring.

Rui Santos, referring to this DevKitC, says --

I2C

When using the ESP32-S3 with the Arduino IDE, these are the ESP32 I2C default pins:

  • GPIO 8 (SDA)
  • GPIO 9 (SCL)

but none of that is shown on his pinout map.
ESP32-S3 DevKitC Pinout Refence Guide: GPIOs Explained | Random Nerd Tutorials

@runaway_pancake said: "Using -- Wire.begin(); it looks like SCL should be on GPIO22 and SDL should be on GPIO21"

ESP32_dev_board_pinout-1536x746.jpg (1536×746)


I do NOT believe the picture and pinout on that page you linked to is for the ESP32-S3-DevKitC-1 board, which I have, and is quite prolific in the wild. It looks like it may be a pinout for the older ESP32-DevKitC-V4. The ESP32-S3-DevKitC-1 board has TWO USB-c connectors on it, one is labeled UART the other is labeled USB. The USB port seems to enumerate as a virtual COMxx port (mine appears as COM7). I can upload a simple blink sketch to the port labeled USB just fine. Here is a picture and pinout of my ESP32-S3-DevKitC-1 board:

I suspect the ESP32-S3-DevKitC-1 board having two ports may have something to do with the I2C not working as expected for me. But I'm just guessing. Maybe someone else here (that is way smarter than me) knows what the truth is regarding the GPIO pin numbers for the two default built-in ESP32-S3-DevKitC-1 I2C ports?

@sonofcy said: "ESP32-S3-DevKitC-1? What board are you picking in the Boards menu, I find NO match."

Tools > Board: "ESP32S3 Dev Module"
Tools > Port: "COM7" <- My board shows up as COM7 when plugged in to the USB-C port labeled USB (not labeled UART)
Tools > Use CDC On Boot: "Enabled" <- If Disabled, the Tools > Serial Monitor does not work

In Arduino IDE v2.3.3 running in Windows 11 Pro, those settings above allow me to program my ESP32-S3-DevKitC-1 boards with a simple Blink example.

@6V6GT: 6V6 is a beam-power tetrode vacuum tube. Very tasty:

The ESP32-S3-DevKitC-1 picture and pinout is here:

You can buy the ESP32-S3-DevKitC-1 boards here (I have three of these):

Espressif refers to the ESP32-S3-DevKitC-v1.1, but I have only seen some passing references to the v1.1 boards, most of the actual boards I have ever run across are actually v1.0 not the latest v1.1. The only difference is rumored to be the pin connected to the single onboard addressable RGB LED. The v1.0 board uses GPIO38, but for some reason other boards use a different GPIO number for the one onboard addressable RGB LED, like GPIO42 or something. Here is an Espressif link for the ESP32-S3 hardware reference if you care to do a time-wasting deep-dive:

https://docs.espressif.com/projects/esp-idf/en/stable/esp32s3/hw-reference/index.html

Thanks and good luck. Regards, David

It was my first electronics project some years ago now: PWM Frequency Library - Still will not compile for ATmega1284 - #6 by 6v6gt

On that esp32 variant I guess you are aware that the labelling of the pins is under the pin. Could it be as simple as that?

@runaway_pancake: (Profile - runaway_pancake - Arduino Forum)

YOU SOLVED IT, THANK YOU!

/**********************************

      ESP32-S3 I2C Scanner
     OLED          ESP32-S3
 +----------+    +----------+
 |       GND|----|GND       |
 |       VCC|----|3V3       |
 |       SCL|----|GPIO9     |
 |       SDA|----|GPIO8     |
 +----------+    +----------+

Posted by Rui Santos: https://randomnerdtutorials.com/esp32-s3-devkitc-pinout-guide/
I2C: When using the ESP32-S3 with the Arduino IDE, these are the ESP32 I2C default pins:

GPIO 8 (SDA)

GPIO 9 (SCL)

Select these two pins like this in your sketch:
//Wire.begin(I2C_SDA, I2C_SCL);
  Wire.begin(8, 9);

Serial Monitor says:
Scanning...
I2C device found at address 0x3C 

Hardware:
ESP32-S3-DevKitC-1: https://www.amazon.com/dp/B0D9W4Y3F3
0.96" White SSD1306 I2C OLED Display: https://www.amazon.com/dp/B09T6SJBV5

Problem: The onboard addresable RGB LED on GPIO38 is always
on bright white. I cannot find a way to simply disable it.

**********************************/

#include <Wire.h>

#define rgbledPin 38

void setup() {
  //Wire.begin(I2C_SDA, I2C_SCL);
  Wire.begin(8, 9);
  //Wire.begin(5, 4);
  //Wire.begin(33, 32);
  pinMode(rgbledPin, OUTPUT);
  //pinMode(rgbledPin, INPUT);
  Serial.begin(115200);
  Serial.println("\nI2C Scanner Started...");
}

void loop() {
  byte error, address;
  int nDevices;
  Serial.println("Scanning...");
  digitalWrite(rgbledPin, LOW);
  //digitalWrite(rgbledPin, HIGH);
  nDevices = 0;
  for(address = 1; address < 127; address++ ) {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
    if (error == 0) {
      Serial.print("I2C device found at address 0x");
      if (address<16) {
        Serial.print("0");
      }
      Serial.println(address,HEX);
      nDevices++;
    }
    else if (error==4) {
      Serial.print("Unknow error at address 0x");
      if (address<16) {
        Serial.print("0");
      }
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0) {
    Serial.println("No I2C devices found\n");
  }
  else {
    Serial.println("done\n");
  }
  //digitalWrite(ledPin, LOW);
  delay(2000);
}

the board I used certainly looks identical to esp32-s3-devkitc-1-development-board

Good that it is fixed. Normally the port multiplexer allows you to reroute pins belonging to the I2C peripheral(s) and Wire.begin( mySDA, mySCL ) should be valid for most choices of pins. Maybe you got unlucky and selected pins which were invalid targets.

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