Hello,
I am using an ESP32-C3 Super Mini board. I am unable to read from any attached I2C devices. I have connected them to a Raspberry Pi and they show up under i2cdetect and I can read and write from them with no issues. I have also tried an ESP32 board, and they work fine, however I cannot seem to make them work on the ESP32-C3 Super Mini. I have connected the sensor (PCT2075D) to pins 8 and 9 (SDA and SCL). I then ran a sketch pct2075_test.ino (https://raw.githubusercontent.com/adafr ... 5_test.ino) to test it, but it cannot see the sensor. I then tried running WireScan.ino (https://raw.githubusercontent.com/espre ... reScan.ino), and this also does not show any devices found. I connected my logic analyzer to the port, and it can see write activity from the ESP32-C3 Super Mini, but it does not show any devices connected. Attached is a screenshot of the capture. I have 3 of them, and none of them want to work with I2C. I have also tried different board options in Arduino, including Adafruit QT Py ESP32-C3, Geekble Mini ESP32-C3 and ESP32C3 Dev Module.
Any help would be greatly appreciated!
Unable to use I2C sensors with ESP32-C3
-
jamesyoung
- Posts: 1
- Joined: Wed Aug 28, 2024 5:05 am
Unable to use I2C sensors with ESP32-C3
- Attachments
-
- Screenshot 2024-08-28 151123.png (189.82 KiB) Viewed 9459 times
-
- Screenshot 2024-08-28 151134.png (250.32 KiB) Viewed 9459 times
-
lbernstone
- Posts: 1137
- Joined: Mon Jul 22, 2019 3:20 pm
Re: Unable to use I2C sensors with ESP32-C3
The esp32 is a 3V3 device. Make sure all your signals are at 3V3, and have pull up resistors also connected to 3V3. Note that pin9 is the boot pin, so the pull up must be weaker than the path through the boot button.
Re: Unable to use I2C sensors with ESP32-C3
This helped me:
ESP32C3 Dev Modul + Arduino IDE v.2.3.2
Menu >>> Tools >>> USB CDC On Boot: "Enabled", JTAG Adapter: "Integrated USB JTAG"
ESP32C3 Dev Modul + Arduino IDE v.2.3.2
Menu >>> Tools >>> USB CDC On Boot: "Enabled", JTAG Adapter: "Integrated USB JTAG"
Re: Unable to use I2C sensors with ESP32-C3
1. ESP32-C3 Supermini does not need any external pull up resistor.
2. Connect Vin of I2C device with ESP's any pin (I used 6) and keep it HIGH in setup.
3. Connect PIN_9-> SDA, PIN_10-> SCL, avoid Pin 8.
Supermini's PIN 8 works on inverted logic (LOW means ON), for which it does not work if try to use as SDA.
I connected VL53L1X with Supermini using Arduino IDE 2.3.3, selected board MakerGo ESP32-C3 Supermini with the help of the library from Sparkfun.
2. Connect Vin of I2C device with ESP's any pin (I used 6) and keep it HIGH in setup.
3. Connect PIN_9-> SDA, PIN_10-> SCL, avoid Pin 8.
Supermini's PIN 8 works on inverted logic (LOW means ON), for which it does not work if try to use as SDA.
I connected VL53L1X with Supermini using Arduino IDE 2.3.3, selected board MakerGo ESP32-C3 Supermini with the help of the library from Sparkfun.
-
Riaz Ahmed
- Posts: 1
- Joined: Mon Jan 06, 2025 8:59 am
Re: Unable to use I2C sensors with ESP32-C3
I am using ESP32-C3 super mini to receive data from a pressure sensor (using sda/scl on pins 9/10) and an air quality sensor (using rx/tx on pins 3/2). I only get data from the sda/scl and not from rx/tx. When i omit the code for sda/scl i start getting data from the tx/rx. Earlier with ESP32-Wroom32 i used to get both the data without any trouble. I have tried the 5v for rx/tx and 3.3v for sda/scl but that does not solve my problem on ESP32-C3. Please help
Code: Select all
#include <XGZP6897D.h>
#define K 8192 // see table above for the correct value for your sensor, according to the sensitivity.
XGZP6897D mysensor(K);
float pressure, temperature;
#include <SoftwareSerial.h>
SoftwareSerial pmsSerial(3, 2);
void setup() {
// our debugging output
Serial.begin(115200);
// sensor baud rate is 9600
pmsSerial.begin(9600);
while (!mysensor.begin()) // initialize and check the device
{
Serial.println("Device not responding.");
delay(500);
}
}
struct pms5003data {
uint16_t framelen;
uint16_t pm10_standard, pm25_standard, pm100_standard;
uint16_t pm10_env, pm25_env, pm100_env;
uint16_t particles_03um, particles_05um, particles_10um, particles_25um, particles_50um, particles_100um;
uint16_t unused;
uint16_t checksum;
};
struct pms5003data data;
void loop() {
if (readPMSdata(&pmsSerial)) {
Serial.println(data.pm10_standard);
Serial.println(data.pm25_standard);
Serial.println(data.pm100_standard);
Serial.println(data.particles_03um);
Serial.println(data.particles_05um);
Serial.println(data.particles_10um);
Serial.println(data.particles_25um);
Serial.println(data.particles_50um);
Serial.println(data.particles_100um);
}
if (mysensor.readSensor(temperature, pressure))
{
Serial.println(temperature);
Serial.println(pressure);
Serial.println();
}
else Serial.println("Reading fails. Timeout ??");
delay(10);
}
boolean readPMSdata(Stream *s) {
if (! s->available()) {
return false;
}
// Read a byte at a time until we get to the special '0x42' start-byte
if (s->peek() != 0x42) {
s->read();
return false;
}
// Now read all 32 bytes
if (s->available() < 32) {
return false;
}
uint8_t buffer[32];
uint16_t sum = 0;
s->readBytes(buffer, 32);
// get checksum ready
for (uint8_t i=0; i<30; i++) {
sum += buffer[i];
}
/* debugging
for (uint8_t i=2; i<32; i++) {
Serial.print("0x"); Serial.print(buffer[i], HEX); Serial.print(", ");
}
Serial.println();
*/
// The data comes in endian'd, this solves it so it works on all platforms
uint16_t buffer_u16[15];
for (uint8_t i=0; i<15; i++) {
buffer_u16[i] = buffer[2 + i*2 + 1];
buffer_u16[i] += (buffer[2 + i*2] << 8);
}
// put it into a nice struct :)
memcpy((void *)&data, (void *)buffer_u16, 30);
if (sum != data.checksum) {
Serial.println("Checksum failure");
return false;
}
// success!
return true;
}-
chris.reyna
- Posts: 1
- Joined: Wed Jul 08, 2026 9:33 pm
Re: Unable to use I2C sensors with ESP32-C3
I had same issue and tried several options, two options that worked for me were
1.- To use physical pull up resistor (GPIO pins can be changed)
SDA pin Sensor / ESP32 C3 GPIO2 pin / resistor / 3.3v ESP32 C3 pin
SCL pin Sensor / ESP32 C3 GPIO3 pin / resistor / 3.3v ESP32 C3 pin
GND pin Sensor / GND ESP32 C3 pin
VCC pin Sensor / 5v ESP32 C3 pin
2.- To enable ESP32 C3 Supermini pull up resistor using code
Same as above but no physical resistors needed (Code enable)
SDA Sensor / ESP32 C3 GPIO2
SCL Sensor / ESP32 C3 GPIO3
GND Sensor / GND ESP32 C3
VCC Sensor / 5v ESP32 C3
Arduino IDE code i2C scanner, with this you will be able to get address from sensor (I'm sorry Spanish comments)
If all is connected properly you will get i2c addr in my case 0x23, also if needed then you can add same pull up stuff code in YAML ESPhome as well.
Hope this helps you!
Cheers
1.- To use physical pull up resistor (GPIO pins can be changed)
SDA pin Sensor / ESP32 C3 GPIO2 pin / resistor / 3.3v ESP32 C3 pin
SCL pin Sensor / ESP32 C3 GPIO3 pin / resistor / 3.3v ESP32 C3 pin
GND pin Sensor / GND ESP32 C3 pin
VCC pin Sensor / 5v ESP32 C3 pin
2.- To enable ESP32 C3 Supermini pull up resistor using code
Same as above but no physical resistors needed (Code enable)
SDA Sensor / ESP32 C3 GPIO2
SCL Sensor / ESP32 C3 GPIO3
GND Sensor / GND ESP32 C3
VCC Sensor / 5v ESP32 C3
Arduino IDE code i2C scanner, with this you will be able to get address from sensor (I'm sorry Spanish comments)
Code: Select all
#include <Wire.h>
// Usamos los pines que me funcionaron
#define SDA_PIN 2
#define SCL_PIN 3
void setup() {
// 1. ACTIVAR PULL-UPS INTERNAS ANTES DE INICIAR I2C
pinMode(SDA_PIN, INPUT_PULLUP);
pinMode(SCL_PIN, INPUT_PULLUP);
// Un pequeño delay para que se estabilice el voltaje interno
delay(10);
// 2. INICIAR EL BUS I2C (Arduino aplicará el Pull-Up aquí también)
Wire.begin(SDA_PIN, SCL_PIN);
// Activar comunicación serie para el monitor
Serial.begin(115200);
while (!Serial);
Serial.println("\n--- Probando I2C con Pull-Ups de Software ---");
}
void loop() {
byte error, address;
int nDevices = 0;
Serial.println("Escaneando bus...");
for (address = 1; address < 127; address++) {
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0) {
Serial.print("¡Dispositivo encontrado en la dirección 0x");
if (address < 16) Serial.print("0");
Serial.print(address, HEX);
Serial.println("!");
nDevices++;
}
else if (error == 4) {
Serial.print("Error crítico en dirección 0x");
if (address < 16) Serial.print("0");
Serial.println(address, HEX);
}
}
if (nDevices == 0) {
Serial.println("No se detectó nada. Las pull-ups por software NO son suficientes.\n");
} else {
Serial.println("Escaneo finalizado con éxito.\n");
}
delay(3000);
}Code: Select all
# Configuración I2C optimizada por software 🚀
i2c:
sda: GPIO2
scl: GPIO3
scan: false
frequency: 100kHz
# Esto le dice a ESPHome que mantenga activados los pull-ups del chip
sda_pullup_enabled: true
scl_pullup_enabled: trueCheers
Who is online
Users browsing this forum: ChatGPT-User, PerplexityBot, YisouSpider and 0 guests