BH1750
BH1750 copied to clipboard
Hello, the library dont really want to work with my esp32s, anyone?
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
btw my it gives me error: [BH1750] ERROR: received NACK on transmit of address in the start and then for the rest of the time just: Device is not configured! Light level: 65534
the board is NodeMCU ESP32S
i2cdetect just gives me
Need help ASAP! @claws @wridgers @goebish @NuTTeR
thanks <3
try with Wire.begin(21, 22);
@goebish nope aint working
still same error, just ERROR: received NACK on transmit of address
Have you tried to add pull up resistors between SDA<->3.3V and SCL<->3.3V ? I'm not sure Wire.begin takes care of that. If that doesn't work, then I don't know, have you tried with another i2c device such as a small oled display ?
nope dont have another ic2 device, and dont think i got a pull up resister,
but im pretty sure there is no need for a pull up resistor
just use any 1k-30k resistors, that should be fine, you need 2
so a resistor between D21 -> SDA and D22 -> SCL ?
why should a resistor change anything? just asking :D
no, between SDA -> 3.3V & SCL -> 3.3V
because i2c lines need to be pulled up https://rheingoldheavy.com/i2c-pull-resistors/ It could be done in software in the i2c lib, but I'm not sure that's the case, just check with pull up resistors, you've nothing to lose ;)
not sure what you mean, there is no between SDA and 3.3v i think photo otw
well, just connect a 10k or so resistor between +3.3V and SDA ... same for SCL
im trying to say, i connect direct from the board to scl, there is no connection to 3v between i can interact with

i have a 3v pin ofc, but i sounds weird if i should hook the up to them
btw the blue line is ground and the red is 3.3v
@goebish
yes, just connect this 3.3V line to SDA through a resistor ... same for SCL, don't change anything else
lul ok,
don't worry, you can't get the magic smoke out just by adding pull up resistors ;)
hmmm it didnt work just hooking 3.3v onto scl and sda
without resister tho
... don't do that, that could damage the esp! resistors are important!
oh something changed, when i unplug both 3.3v it says ERORR: received NACK on transmit of address but if i connect 3.3v to either one or both i get ERROR: received NACK on transmit of data
@goebish