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
- Connect the LDR from the supply to the analog pin, and a fixed resistor of about 10 kohm from the pin to ground.
- Swap the two parts if you want the reading to rise with light instead of falling.
- Use the supply voltage of your board. On an ESP32 keep it at 3.3 V.
- Choose the fixed resistor near the LDR resistance at the light level you care about.
- 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, 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.