ArduinoTroubleshooting

Beetle ESP32 - C3 I2C (SDA/SCL) not working

userHead vlsim 2024-09-23 04:23:45 200 Views6 Replies

Hi,

 

I am using Beetle ESP32 - C3 from DFRobot to interact with some I2C device. I have tried different configurations and was unable to get it to work.

 

Here is an example of code I used for AHT10 sensor as it has a very simple interface and usually works out of the box:

 

#include <Wire.h>


 

#define AHT10_ADDRESS 0x38

#define AHT10_CMD_INIT 0xE1

#define AHT10_CMD_TRIGGER 0xAC

#define AHT10_CMD_RESET 0xBA


 

void setup() {

Serial.begin(115200);

Wire.begin(8, 9); // SDA, SCL

 

if (!aht10_init()) {

Serial.println("AHT10 initialization failed!");

while (1);

}

Serial.println("AHT10 initialized successfully.");

}


 

void loop() {

// Sensor data reading code...

}


 

bool aht10_init() {

Wire.beginTransmission(AHT10_ADDRESS);

Wire.write(AHT10_CMD_INIT);

Wire.write(0x08);

Wire.write(0x00);

if (Wire.endTransmission() != 0) {

return false;

}

delay(20);

return true;

}


The code above produces the following error:

AHT10 initialization failed!

 

I have set the SDA and SCL to 8 and 9 respectively as it is shown in the pinout of the board.

 

I have tried the same code with different boards like the ESP-WROOM-32 from other manufacturers where SDA and SCL are set to default pins 21 and 22 and everything seems to work.

 

Is there something I am missing here?

 

2024-09-23 18:10:42

If you have a multimeter, you could try measuring the voltage of SDA/SCL on the ESP32-C3 relative to GND. The voltage should be around 3.3V if the bus is OK.

userHeadPic Yeez_B
vlsim wrote:

Thanks Yeez_B, yo saved me hours of debugging and wire swapping :) 

I measured the connection and SDA/SCL pins where not showing contant voltage. Everything was fine on the other boards I tested - the reading was constat 3.3V. I re-soldered the pins so the voltage is now constant and I2C works perfectly.

2024-09-24 04:06:44
Yeez_B wrote:

Good to know that!

2024-09-24 09:31:28
2 Replies
2024-09-23 15:22:40

Check Your Hardware Connections: Make sure that the SDA and SCL wires from your AHT10 sensor are correctly hooked up to pins 8 and 9 on your Beetle ESP32 - C3.

Try Different Pins: If it's an option, you might want to give it a shot with SDA and SCL on other pins that support I2C, just to see if that makes a difference.

Use an I2C Scanner: It could be helpful to whip up or find a ready-made I2C scanner program to check if your AHT10 shows up on the I2C bus. This can help you figure out if the sensor is being detected.

userHeadPic 1471300
vlsim wrote:

Thank you for the reply. I made sure that AHT10 is wired correctly multiple times with no luck unfortunately. 

 

I also tried using different pin combinations on Beetle ESP32 - C3, but with no luck. Also the product page for Beetle ESP32 - C3 states that SDA and SCL are only available on pins 8 and 9.

 

I tried running ready-made I2C scanners and none of them detected the device unfortunately. I will repeat the same experiments with different boards that I have, but I start to suspect there may be something wrong with this particular Beetle ESP32 - C3. Or at least I hope it is the specific board as I have 4 more backordered from DFRobot.

2024-09-23 17:48:08
1 Replies