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
-
- 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 4186 times
-
- Screenshot 2024-08-28 151134.png (250.32 KiB) Viewed 4186 times
-
- Posts: 886
- 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.
-
- 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;
}
Who is online
Users browsing this forum: Bing [Bot], sazanof and 66 guests