Using Arduino Uno to Measure Lux

Hi everyone,

I have been trying to use an Arduino UNO in concert with a GY-30 BH7150FVI Light Intensity Sensor to measure lux for as part of a school project, essentially following the instructions of this video: TUTORIAL: How to Wire & Code GY-30 BH1750 Light Sensor (GY30 / GY302) - Easy - Arduino Module! - YouTube connections that I made were

VCC--> 3.3 V
SCL--> A5
SDA -->A4
ADD--> Ground
GND--> Ground

and the code that I uploaded my Arduino was:

#include <Wire.h>
#include <BH1750.h>
BH1750 lightMeter(0x23);

void setup(){


// Initialize the I2C bus (BH1750 library doesn't do this automatically)

//Setting the mode
// begin returns a boolean that can be used to detect setup problems
if (lightMeter.begin(BH1750::CONTINUOUS_HIGH_RES_MODE)) {
Serial.println("BH1750 Advanced begin");
else {
Serial.println("Error initialising BH1750");


void loop() {

uint16_t lux = lightMeter.readLightLevel();
Serial.print("Test: "+lux);


When uploading the above using Arduino 1.8.3, my serial monitor outputs:

ERROR: received NACK on transmit of address
ERROR: received NACK on transmit of data

[BH1750] ERROR: other error
[BH1750] ERROR: undefined error
ERROR initializing device

Test : [BH1750] not configured!
Test : [BH1750] not configured!
Test : [BH1750] not configured!
Test : [BH1750] not configured!
Test : [BH1750] not configured!

where the last line "Test : [BH1750] not configured!" repeats indefinitely as a result of the void loop.

I would really be grateful if someone could explain to me why my program is not working as intended (i.e. lux values are not being displayed in the serial monitor), and what steps I should take to debug my work. Thanks in advance.

Use the I2C address scanner program to make sure communications are working.

You MUST add 4.7K pullup resistors on SDA and SCL to 3.3V, if they aren't already on the sensor module.

I utilized the I2C address scanner program, and it came up with:

Scanning ...
no I2C devices found.

So this is a step towards solving my problem. Looking at the schematic diagram for the bh1750fvi module that can be seen here:, it seems that a 4.7 K pullup resistor is already included.

Considering that is the case, could you shed any light as to why my I2C communication is not working, and no devices are detected?

Can you give a link to where you bought your BH1750 module ? Some modules have level shifters for I2C, other modules don't have level shifters but they do have a voltage regulator.

When you have that module that is shown in that video and in that link you gave, then I suggest to connect the Arduino 5V pin to VCC of the module. Then it should work. You don't have to connect the ADD pin and you don't have to add extra pullup resistors.
Do you use a breadboard ? They often have bad contacts.

Always start with the I2C Scanner. When the I2C Scanner can not see the sensor, then you don't even have to try a library or a sketch.

I bought my module from my local electronics shop, so I don't know this link will be useful to you, but here it is anyway: In response to your other questions/suggestions:

  • yes, I am using a breadboard, and this time, I connected all my jumper wires directly to the GY-30 module.

  • I connected VCC to the Arduino's 5V

  • I disconnected the modules ADD pin

  • I ran the I2C scanner again

Despite doing all of the above, this time, when I ran the I2C scanner, I got the following error message:

avrdude: ser_open(): can't set com-state for \.\COM3
An error occurred while uploading the sketch

Just so you know, my baud rate is correct.

Considering all of the above, could anyone tell me what I am doing wrong?

At this moment your computer can not see your Arduino Uno board.
Remove everything from the Arduino Uno, and try to select the right com port in the Arduino IDE. Restart the computer, try to retrieve the board info (that is in the menu), see if the led blinks if you press the reset button.

Where you able to run the I2C Scanner before you lost connection to your Arduino Uno board ?

Yeah, I managed to run the I2C scanner before hand.

Was the sensor detected ?
Do you use a cheap power supply ? Is there something that could damage the sensor and the Arduino board ?