ESP32 I2C_scanner reports 'No device found'

I have connected a Wemos OLED ESP32 with another OLED display and a 3-wire DHT11 sensor breakout (with pull-up resistor). I have tested the displays and they both produce the test picture. I can't get the I2C_scanner to work - it says there are no devices. SLC - pin 4, SDA - pin 5. I'm running the devices off the 3.3V pin.

Update: When I unplug the DHT11 sensor I2C:scanner finds the OLED.

/*** Rui Santos ***/

#include <Wire.h>

void setup() {
  Wire.begin();
  Serial.begin(115200);
  while(!Serial);
  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);          
}

I have a feeling you did not install the pull up resistors. A schematic would be great, not one of those frizzy things.

Without a schematic, we're only guessing....
Try this:

Wire.begin(4, 5);       //SDA is GPIO4, SCL is GPIO5
1 Like

if you use the wire-library without specifying IO-pins the hardware I2C-interface on GPIO 21 SDA and GPIO22 SCL is used.

The Wemos OLED-board seems to have not connected these GPIOs to the PIN-header at all.
(Which if true I think is a bad idea to left them out)

RNT has a lot of useful information about ESP8266 ESP32

best regards Stefan

SteveMann
I tested with wire.begin(5,4) and it finds one device if DHT11 is not connected. Now with wire.begin(4,5) it works better and I see two devices, 0x3C and 0x01. One is obviously the built-in OLED and the other could be the other external OLED. As soon as I wire in the DHT11 I get no devices at all. I have tried two different hookups.
GilSchultz
The DHT11 module has a built-in 10kOhm pull-up resistor. The problem is there are variations on the internet what the pins are for (pictures).

In your code you do not use a dht library. Did you know the dht is a one wire thingy and not an i2C thingy?

Show your wiring of the DHT.

Idahowalker:

I got it! Thanks.

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