0

ok, im having problems with my bh1750, here is all info i got:

board: esp32s nodeMCU v. 1.1

Pins: Pins:

Wiring: (the 2 reds go to pin 21 and 22) enter image description here

code:

#include <BH1750.h>
#include <Wire.h>

BH1750 lightMeter;

void setup(){

Wire.begin();
Serial.begin(115200);
lightMeter.begin();
if (lightMeter.begin()) {
Serial.println(F("BH1750 initialised"));
}
else {
Serial.println(F("Error initialising BH1750"));
}
}

void loop() {
uint16_t lux = lightMeter.readLightLevel();
Serial.println(lux);
delay(500);
}

Sorry for bad formating

Serial output:

13:01:41.926 -> [BH1750] ERROR: received NACK on transmit of address

13:01:41.926 -> [BH1750] ERROR: received NACK on transmit of address

13:01:41.926 -> Error initialising BH1750

13:01:41.926 -> [BH1750] Device is not configured!

13:01:41.926 -> 65534

13:01:42.430 -> [BH1750] Device is not configured!

13:01:42.430 -> 65534

13:01:42.932 -> [BH1750] Device is not configured!

13:01:42.932 -> 65534

and that goes on forever

Hope someone got an answer :D

  • hrello still needs help – user216002 Apr 1 at 16:24
0

Your code looks good. I2C configuration is default which depends on your board manager. Then your wiring may be wrong.

  1. Using a multimeter to check supply voltage on the BH1750 module. It should be 3.3V
  2. Using a multimeter to check the connection between the BH1750 module with ESP32.
  3. Difference ESP32 vendor may provide a difference I2C pinout. Make sure you connect everything correctly.
  4. Using an oscilloscope or logic analyzer to capture data on an I2C bus.
  5. If everything good, try to use another module.

From your log, I guessed, the power supply is good. I2C connection is your problem. More, you should use the different color wire for the difference signal. It helps prevent unexpected connections.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.