Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BH1750 does not work on ESP32 #77

Open
sergioarjona5 opened this issue Apr 28, 2021 · 3 comments
Open

BH1750 does not work on ESP32 #77

sergioarjona5 opened this issue Apr 28, 2021 · 3 comments

Comments

@sergioarjona5
Copy link

Hi guys,

First of all sorry for my English. I have a problem with the BH1750, it tells me that it is not well in fact with the i2cdetec, it does not detect it and I no longer know what to do. I have tried everything, pullup resistors as well. I have also tried different BH1750 sensors. I have tested de pins and work. The only thing that I

Here is my code:
#include <Wire.h>
#include <BH1750.h>
#include <i2cdetect.h>

BH1750 lightMeter;

void setup() {

Serial.begin(115200);

// Initialize the I2C bus (BH1750 library doesn't do this automatically)
Wire.begin();
// On esp8266 you can select SCL and SDA pins using Wire.begin(D4, D3);
i2cdetect();
if (lightMeter.begin()) {
Serial.println(F("BH1750 Test begin"));
}
else {
Serial.println(F("BH1750 Initialization FAILED"));
}

}

void loop() {

float lux = lightMeter.readLightLevel();
Serial.print("Light: ");
Serial.print(lux);
Serial.println(" lx");

delay(1000);

}

Here I show de wiring.
bh1750

Thanks.

@lefty01
Copy link

lefty01 commented Aug 7, 2022

is this still an issue? works for me (now) with esp32.

@ryancasler
Copy link

With the ESP32, depending on what board you are using the SDA and SCL default pins might be different. If that's an ESP32 WROOM dev kit, then your SDA pin is 21 and your SCL pin is 22 by default. Or you can simply use:
Wire.setPins(, );
and substitute whatever pin numbers you are using for SDA and SCL. You just have to do this before the Wire.begin() command.

@petobe
Copy link

petobe commented Nov 8, 2023

@lefty01 Yep, for me its still an issue....but i just started with ESP32 :) and cant get it to work. I have an D1 Mini ESP32 from AZ-Delivery. Do you want t share how you got it to work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants