An automated dual-axis sun-tracking system that keeps a solar panel pointed at the sun for maximum energy capture, using four LDRs and two servo motors in a simple closed loop.
Four LDRs sit in a "+" shaped holder with opaque walls between them, so each light sensor only sees light from its own quadrant. When the panel drifts off-axis, the walls shadow one side and the four readings diverge — the controller then nudges the servos until opposing sensors read equal (i.e. the panel faces the sun head-on).
TOP
TL | TR
-----+----- <- opaque "+" dividers
BL | BR
BOTTOM
Azimuth (base servo) : LEFT (TL+BL) vs RIGHT (TR+BR)
Elevation (panel servo) : TOP (TL+TR) vs BOTTOM (BL+BR)
- Base servo (azimuth) rotates the whole assembly left/right, comparing the two left LDRs against the two right LDRs.
- Panel servo (elevation) tilts the panel up/down, comparing the two top LDRs against the two bottom LDRs.
- A deadband (
TOLERANCE) stops the servos hunting/jittering once the panel is roughly aligned, and at night the tracker stops chasing noise and eases back to a home position for the next sunrise.
| Qty | Part |
|---|---|
| 1 | Arduino Uno / Nano (or any AVR board) |
| 2 | Servo motors — one for the base (azimuth), one for the panel tilt (elevation) |
| 4 | LDRs (photoresistors) |
| 4 | 10 kΩ resistors (one per LDR, voltage divider) |
| 1 | "+" LDR holder with opaque dividers (3D-printed or card/foam) |
| 1 | External 5 V supply for the servos (recommended) |
| — | Small solar panel + mount/holder, jumper wires |
LDRs — each as a voltage divider (more light → higher reading):
5V ── LDR ──┬── A0..A3 (analog in)
└── 10kΩ ── GND
| LDR | Analog pin |
|---|---|
| Top-left (TL) | A0 |
| Top-right (TR) | A1 |
| Bottom-left (BL) | A2 |
| Bottom-right (BR) | A3 |
Servos — signal to D9 (base/azimuth) and D10 (panel/elevation). Power both servos from an external 5 V supply, not the Arduino's 5 V pin (two servos can draw enough stall current to brown out the board). Tie the servo supply ground to the Arduino ground (common ground).
- Open
Solar_Tracker/Solar_Tracker.inoin the Arduino IDE. - Upload to your board, then open the Serial Monitor at 9600 baud to watch the four LDR readings and servo angles.
| Constant | What it does |
|---|---|
TOLERANCE |
Deadband — raise it if the servos jitter, lower for tighter tracking. |
STEP / UPDATE_MS |
How fast/smooth it moves. |
SAMPLES |
Analog reads averaged per LDR (noise smoothing). |
AZ_MIN/MAX, EL_MIN/MAX |
Servo travel limits — set to your servo's real range. |
AZ_DIR, EL_DIR |
Flip +1→-1 if an axis tracks the wrong way. |
LDR_BRIGHT_IS_HIGH |
Set false if your dividers are wired the opposite way. |
NIGHT_LEVEL, RETURN_HOME_AT_NIGHT |
Night behaviour + home pose. |
First run: if a servo drives away from the light, flip that axis's
*_DIR. If it never settles, increaseTOLERANCE.
Part of @ramuroy's embedded systems work.