claws / BH1750

An Arduino library for the digital light sensor breakout boards containing the BH1750FVI IC
MIT License
248 stars 107 forks source link

Hello, the library dont really want to work with my esp32s, anyone? #56

Open marius240 opened 5 years ago

marius240 commented 5 years ago

my code:

#include <Wire.h>

BH1750 lightMeter(0x5C);

void setup() {
  // put your setup code here, to run once:
  Wire.begin();
  Serial.begin(115200);
  lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE);
  delay(2000);

}

void loop() {
  // put your main code here, to run repeatedly:

  uint16_t lux = lightMeter.readLightLevel();
  Serial.print("Light level: ");
  Serial.println(lux);

  delay(5000);

}

The cabling:

D21 -> SDA D22 -> SCL GND & ADDR -> gnd VCC -> 3.3V

coelner commented 5 years ago
IoTThinks commented 4 years ago

You may need to pull up the SDA and SCL before Wire.begin(SDA, SCL); pinMode(SDA, INPUT_PULLUP); pinMode(SCL, INPUT_PULLUP);

And make sure the BH1750 is...physically connected. My board is ESP32 and works fine.

I hit the same error when my sensor looses the pin contact.