LDR versus lux sensor comparison lab
Build it step by step
0 of 6 doneWire both sensors
Build the LDR divider and connect the BH1750 on I2C.
Print both
Open the Serial Monitor and see lux and ADC together.
Collect data
Move a lamp in steps from far to near and note 15 or 20 pairs.
Plot
Paste into a spreadsheet and draw lux against ADC.
Fit a power curve
Add a trendline of the form lux = A × adc^B and note A and B.
Test the fit
Put A and B in the sketch and compare the estimate with the BH1750.
How do you build an LDR versus lux sensor comparison lab?
Measure the same light with a cheap LDR and a calibrated BH1750 lux sensor and plot why LDRs are non-linear. You need Arduino Uno R3, LDR Photoresistor, Resistor 10 kΩ, BH1750 light sensor, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 6 steps and about 60 minutes.
- Level
- Beginner
- Time
- About 60 min
- Parts
- 6
Parts list
- Development BoardsBuyArduino Uno R3 × 1
- SensorsBuy
- PassivesBuyResistor 10 kΩ × 1
- SensorsBuy
- PrototypingBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| 5V | LDR leg 1 | Top of the divider |
| LDR leg 2 | Uno A0 and 10 kΩ resistor to GND | Analog reading |
| BH1750 VCC, GND | Uno 5V, GND | Power |
| BH1750 SDA, SCL | Uno A4, A5 | I2C |
Code
Arduino IDE, board "Arduino Uno". Install "BH1750" by Christopher Laws. Put the LDR and the BH1750 side by side facing the same lamp, and change only the lamp's distance. The CSV can be pasted into a spreadsheet: plot lux on one axis against ADC on the other, then add a power trendline. The LDR resistance falls with light in roughly a power-law, so a log-log plot of the divider reading looks nearly straight.
Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
#include <Wire.h>
#include <BH1750.h>
BH1750 meter;
const byte LDR = A0;
// After you have fitted lux = A * adc^B in a spreadsheet, put your numbers here:
const float A = 0.0, B = 1.0;
void setup() {
Serial.begin(9600);
Wire.begin();
meter.begin();
Serial.println("lux,adc,estimate");
}
void loop() {
long s = 0;
for (byte i = 0; i < 16; i++) { s += analogRead(LDR); delay(5); }
float adc = s / 16.0;
float lux = meter.readLightLevel(); // the reference
float estimate = A * pow(adc, B); // what the LDR alone would say
Serial.print(lux, 1); Serial.print(',');
Serial.print(adc, 1); Serial.print(',');
Serial.println(estimate, 1);
delay(500);
}What the serial monitor should show
Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Uno with its sensors at their default values. Your numbers will follow your real readings, but the format should match.
lux,adc,estimate 0.0,511.9,0.0 0.0,512.0,0.0 0.0,512.1,0.0 0.0,511.9,0.0 0.0,511.7,0.0
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Dark room | Low lux and low ADC |
| Lamp closer | Both rise |
| Spreadsheet curve | Bends strongly rather than being a straight line |
| Fitted estimate | Close to the BH1750 within about 20 percent in the range tested |
If it does not work
BH1750 reads 0
Check the I2C wiring and address.
ADC saturates
The room is too bright for the 10 kΩ resistor. Try a different value.
Fit is poor
Use more points and keep the lamp type the same.
Readings jump
Keep other light sources constant.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the LDR versus lux sensor comparison lab?
Arduino Uno R3, LDR Photoresistor, Resistor 10 kΩ, BH1750 light sensor, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm).
How long does the LDR versus lux sensor comparison lab take to build?
About 60 minutes for a beginner maker, in 6 steps.
How do I know the LDR versus lux sensor comparison lab works?
Dark room: Low lux and low ADC. Lamp closer: Both rise. Spreadsheet curve: Bends strongly rather than being a straight line.
BH1750 reads 0: what should I check?
Check the I2C wiring and address.
ADC saturates: what should I check?
The room is too bright for the 10 kΩ resistor. Try a different value.
Fit is poor: what should I check?
Use more points and keep the lamp type the same.
Readings jump: what should I check?
Keep other light sources constant.
