ESP32 Cannot find I2C devices

I've got a ESP32 ch340c usb-c and tried wiring it with an AHT10 and AHT20+BMP280 sensor. Neither of the devices can be connected to. I've also ran an I2C scanner program and it cannot find any connected devices.

Below is an example wiring of a BMP280:

GND -> GND
VCC -> 3.3V
SCL -> GPIO 22 (with pullup resistor)
SDA -> GPIO 21 (with pullup resistor)

Any idea what could be the issue here? Below is the scanner code:

/*********
  Rui Santos
  Complete project details at https://randomnerdtutorials.com  
*********/

#include <Wire.h>
 
void setup() {
  Wire.begin();
  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);          
}

It would be worth checking the connectivity, with your multimeter in resistance mode, and no power applied. There are occasionally problems with faulty breadboards. I've had issues with the headers on the ESP32 board damaging the breadboard connectors.
The sketch should be fine, assuming you didn't edit it. I've used the ESP32 I2C scanner from randomnerdtutorials in the past with no problems.
AFAICT from the photo your connections look correct.
It looks like there's a regulator on the module in the photo. IDK how that module works on 3.3V. Do you have a link to the data sheet for it?

Once the basic DMM checks per @Dave_Lowther are made, my go-to troubleshooting technique for issues like this is to see what the hardware is actually doing. You can get a very capable Logic Analyzer (with USB interface) from Amazon for well under 50USD. And, there's powerful, free software available for download. The software has decoders for dozens of protocols (including I2C) enabling you to see what's actually happening on the I2C interface. I find this technique invaluable.

It would take a miracle for that board to work without having the header properly soldered to it.

Thanks for the replies! This was the issue. I did not know that soldering the headers was required for a proper connection when on a breadboard. I though that as long as the pins touched, then it would be fine.

A miracle did happen and the sensor did start working when I fiddled around with the wires for a bit. I guess I'll have to solder the pins next time :slight_smile:

1 K pullup may be too low. (and not needed)
https://www.electroschematics.com/temperature-sensor/

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