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:
- ESP32: I2C Scanner (Arduino IDE) – Finding the Address of I2C Devices
- 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);
}