0

I am trying to run a simple example of bh1750 on my nodemcu, code is

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

*/
BH1750 lightMeter(0x23);

void setup(){

  Serial.begin(9600);


  Wire.begin(D4,D3);


  if (lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE)) {
    Serial.println(F("BH1750 Advanced begin"));
  }
  else {
    Serial.println(F("Error initialising BH1750"));
  }

}


void loop() {

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

}

and the output I am receiving is enter image description here P.S I have also changed hardware but problem still exists :(

  • How did you connect the sensor with the board? A picture of your setup would be helpful. Changing the hardware does not help if the wiring is wrong. Perhaps you setup I2C address 0x5c on the sensor, but use 0x23 in your program. The wiring could also be incorrect. But you only showed a program that is known to work. ( platformio.org/lib/show/439/BH1750 ). The error means the program transmits the address to all connected receivers, but none of them answered with an ACK. That can be because none is connected or the address of the board isn't set to the value you send. – Peter Paul Kiefer Nov 13 at 15:57

Your Answer

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

Browse other questions tagged or ask your own question.