I only need to read the light once, before the camera is initialized. My code looks like so:
Code: Select all
#define I2C_SDA 16
#define I2C_SCL 15
BH1750 lightMeter (0x23);
//TwoWire I2Clightmeter= TwoWire(1);
TwoWire *I2Clightmeter;
void setup()
{
int auto_mode=0;
//WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
setCpuFrequencyMhz(240);
//setCpuFrequencyMhz(160);
Serial.begin(115200);
Serial.println();
Serial.println("Booting... at ");
Serial.println(millis());
//I2Clightmeter.begin(I2C_SDA, I2C_SCL);
//lightMeter.begin(BH1750::ONE_TIME_HIGH_RES_MODE,0x23,&I2Clightmeter);
I2Clightmeter = new TwoWire(1);
I2Clightmeter->begin(I2C_SDA, I2C_SCL);
lightMeter.begin(BH1750::ONE_TIME_HIGH_RES_MODE,0x23,I2Clightmeter);
delay(1000);
uint16_t lux = lightMeter.readLightLevel();
//delete I2Clightmeter;
So, is there any way to make the esp32 forget I2Clightmeter->begin(I2C_SDA, I2C_SCL); ?