I am using ESP32 with BH1750 light sensor.
I connected:
VCC → 3.3V
GND → GND
SDA → GPIO 21
SCL → GPIO 22
ADD->GND
Problem:
The sensor is not detected.
I2C scanner shows "No devices found".
even the ina219 sensor also does not connect.Some problem with the i2c devices only
I have already tried:
- Changed I2C pins
- Checked wiring
- Tried different code
- Reduced I2C speed
below is the i2c scanner code i am using
#include <Wire.h>
void setup() {
Serial.begin(115200);
Wire.begin();
Serial.println("\nI2C Scanner");
}
void loop() {
byte error, address;
int nDevices = 0;
Serial.println("Scanning...");
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("Unknown 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); // Wait 5 seconds for next scan
}
the bh1750 sensor module already has inbuilt pull up resistors


