I'm trying to add I2C sensors to my esp cam but it doesn't work in either way. I followed some tutorials about it and have working code but scanning the bus shows no devices. Here is the sketch:
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#define I2C_SDA 2
#define I2C_SCL 14
//Adafruit_BME280 bme;
void setup() {
Serial.begin(115200);
Serial.println("Setting up I2C bus");
Wire1.begin(I2C_SDA, I2C_SCL, 100000);
delay(100);
// bool status1 = bme.begin(0x76, &Wire1);
// if (!status1) {
// Serial.println("Could not find a valid BME280 sensor, check wiring!");
// } else {
// Serial.println("bus created.");
// }
}
void loop() {
byte error, address;
int nDevices;
Serial.println("Scanning...");
nDevices = 0;
for(address = 1; address < 127; address++ ) {
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire1.beginTransmission(address);
error = Wire1.endTransmission();
if (error == 0) {
Serial.print("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
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
}
I tried both Wire and Wire1 objects but the effect is the same:
Scanning... No I2C devices found
I also tied a couple of different ports with the same effect.
So my question is what is wrong here or what I possibly forgot if any. I've read that ESP32-CAM have 2 I2C buses from which second should free to use. I ave BME280 wired up so it should be found when the bus is there but it's not found when comment out corresponding piece of setup function.