Arduino Uno BH1750 Light Sensor: Precision Illuminance Monitor

Professional Rohm BH1750FVI I2C digital light sensor measures 0.11-100,000 lux through dual photodiodes (visible + IR filtered) with 1 lux resolution across 16-bit dynamic range. Spectral response mimics human eye V(λ) curve enabling accurate CRI lighting measurements.

Two-wire I2C interface (address 0x23/0x5C) supports continuous (H/L) and one-shot modes with 120ms-120s integration periods. Power consumption 0.13mA measuring, 0.06μA standby. Operates 2.4-3.6V with ±20% accuracy 1-65535 lx.

How It Works

A light-dependent resistor is a strip of cadmium sulphide whose resistance falls as light intensity rises. In darkness it measures in the megohms; in bright light it can drop to a few hundred ohms. That is an enormous range, which is why an LDR is such a forgiving first analog sensor.

Since a microcontroller reads voltage, not resistance, the LDR forms a voltage divider with a fixed resistor. With the LDR on the supply side and a 10 kΩ resistor to ground, the measured voltage rises with light. Swap the two and it falls instead — both arrangements are valid, and knowing which you built determines how to interpret the number.

The Arduino Uno samples with a 10-bit ADC, so analogRead() returns 0–1023 across 5 V. The response is logarithmic, roughly matching how human vision works, which makes an LDR good for "is it bright or dark" decisions and poor for measuring absolute illuminance in lux.

LDRs are also slow. Response time is measured in tens of milliseconds, and recovery from bright light to darkness can take a second or more — too slow for anything optical that changes quickly.

Components Needed

  • Arduino Uno
  • BH1750FVI GY-302 Light Sensor Module
  • 4.7kΩ I2C pull-up resistors (module built-in)
  • Male-to-male jumper wires (4 pieces)
  • Arduino Uno
  • Arduino Uno

Wiring to the Arduino Uno

Wire one LDR leg to the 5 V rail and the other to A0, then a 10 kΩ resistor from A0 down to GND. With this arrangement the reading rises as light increases. LDRs are not polarised, so the two legs are interchangeable.

Any of A0–A5 (six channels) works equally well.

Pick the fixed resistor to centre the range you care about. 10 kΩ suits ordinary indoor lighting; for discriminating between levels of darkness, 100 kΩ gives better resolution at the dim end.

ConnectionArduino Uno pinFunction
LDR leg 15VSupply
LDR leg 2A0Divider midpoint — the measured node
10 kΩ resistorA0 to GNDFixed half of the divider

Example Code

Light level reading with hysteresis so the output does not chatter at the threshold. Upload it with the board set to Arduino Uno and open the Serial Monitor at 9600 baud.

Light level reading with hysteresis so the output does not chatter at the threshold
const int LDR_PIN = A0;
const int DARK_BELOW  = 256;
const int LIGHT_ABOVE = 358;   // gap = hysteresis

bool isDark = false;

void setup() { Serial.begin(9600); }

void loop() {
  int level = analogRead(LDR_PIN);

  // Two thresholds, not one — stops flicker at dusk
  if (!isDark && level < DARK_BELOW)       { isDark = true;  Serial.println("DARK — lights on"); }
  else if (isDark && level > LIGHT_ABOVE)  { isDark = false; Serial.println("LIGHT — lights off"); }

  Serial.print("level=");
  Serial.print(level);
  Serial.print("  (");
  Serial.print(level * 100L / 1023);
  Serial.println("%)");
  delay(500);
}

Applications

A light sensors turns up in a wide range of projects. These are the uses where it is the right choice rather than a compromise:

  • Automatic street and garden lighting that switches at dusk
  • Display backlight adjustment to ambient brightness
  • Line-following robots distinguishing dark from light surfaces
  • Detecting whether an enclosure has been opened
  • Daylight logging for greenhouses and plant monitoring

Working with the Arduino Uno

The Arduino Uno is built around the ATmega328P and runs on 5 V logic with 2 KB of SRAM and 32 KB of program flash. These details change how this circuit is wired and what the sketch can do, so they are worth stating plainly before you build.

The Uno runs at 5 V, so most hobby sensor modules connect directly with no level shifting.

With only 2 KB of SRAM, avoid large buffers and prefer the F() macro for constant strings.

The single hardware UART is shared with the USB connection, so heavy Serial printing competes with uploads.

Arduino Uno characteristicValueWhy it matters here
Logic voltage5 VMatches most hobby modules directly
ADC resolution10-bit (0–1023)Sets how finely an analog reading can be resolved
Analog inputsA0–A5 (six channels)Determines how many analog sensors can share the board
PWM outputsD3, D5, D6, D9, D10 and D11Needed for brightness, speed and tone control
I²C pinsA4 (SDA) and A5 (SCL)Fixed by hardware — wiring copied from another board may not match
Interrupt pinsD2 and D3 onlyRequired for counting fast or asynchronous events
Seriala single hardware UART shared with USBMonitor runs at 9600 baud by default

Troubleshooting

Most problems with this module fall into a handful of categories. Work through these before suspecting the part itself:

  • The reading is stuck near 0 or full scale — the divider resistor is missing or the LDR is open circuit.
  • The value moves the opposite way to expectation — the LDR and fixed resistor are swapped in the divider. Either rewire or invert in software.
  • The output flickers at dusk — use two thresholds with a gap between them, as in the sketch.
  • Readings pulse rapidly indoors — mains-powered lighting flickers at 100/120 Hz. Average several samples over at least 20 ms.
  • Two identical builds read differently — LDR tolerance is very wide. Calibrate each unit.
  • Code written for an ESP board gives odd analog values — the Arduino Uno uses a 10-bit ADC returning 0–1023; rescale any constant taken from a 12-bit example.
  • An I²C sensor is not found after copying wiring from another Arduino — on the Arduino Uno I²C is on A4 (SDA) and A5 (SCL).

Taking It Further on the Arduino Uno

Once the basic reading works, where you go next depends very much on which board you are using. These are the directions that suit the Arduino Uno specifically:

The Uno’s shield ecosystem is its real advantage. Once the circuit works on a breadboard, a prototyping shield turns it into something permanent that still stacks with a data-logging or Ethernet shield without rewiring.

Logging to an SD card via a shield is the natural next step, since the Uno has no onboard storage and no network. Timestamp each reading with a DS3231 real-time clock so the log survives power cuts with correct times.

Because SRAM is limited to 2 KB, keep logged strings short and write them out immediately rather than buffering. Building a long String in memory is the most common cause of an Uno sketch that runs for hours and then freezes.

Notes and Practical Limits

LDRs contain cadmium, which is restricted under RoHS. They remain common in hobby kits but are absent from commercial designs; phototransistors and digital sensors such as the BH1750 are the modern replacements.

If you need light measured in lux rather than arbitrary counts, use a BH1750 or TSL2561 over I²C. They are calibrated, linear and temperature-stable — none of which an LDR divider can claim.