# LDR light sensor reads strange values: build a voltage divider

> Use an LDR with Arduino or ESP32: it needs a fixed resistor to form a voltage divider, and the reading falls or rises depending on the layout.

Canonical: https://roboticsengineering.in/fix/ldr-analog-readings-voltage-divider/ | Published: 2026-11-03 | Updated: 2026-11-03

**An LDR is a variable resistor, so it must be paired with a fixed resistor to make a voltage the board can read.**

## What the message means

The analog pin reads voltage, not resistance. A divider turns the changing resistance into a changing voltage.

## Fix it in this order

1. Connect the LDR from the supply to the analog pin, and a fixed resistor of about 10 kohm from the pin to ground.
2. Swap the two parts if you want the reading to rise with light instead of falling.
3. Use the supply voltage of your board. On an ESP32 keep it at 3.3 V.
4. Choose the fixed resistor near the LDR resistance at the light level you care about.
5. Average several readings to reduce noise, and calibrate with your own light levels.

## If you see this, do this

| You see | Do this |
| --- | --- |
| Reading never changes | Divider missing or wired wrongly. |
| Reading noisy | Average and add a capacitor. |

## Related

[floating analog pin](https://roboticsengineering.in/fix/arduino-analogread-random-values-unconnected-pin/), [voltage divider calculator](https://roboticsengineering.in/led-resistor-voltage-divider-calculator/).

Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.
