Dual-Axis Solar Tracker with Light Sensors
Four light sensors and two servos keep a small solar panel pointed at the Sun all day — then measure how much extra energy you gain.
A panel facing the Sun directly collects more energy than a fixed one. Four light-dependent resistors separated by a small cross-shaped divider see different amounts of light until the panel points straight at the Sun.
Mission steps
Build the sensor cross
Mount four LDRs in a 2×2 pattern with a small opaque cross between them, on the same plate as the panel.
Wire the dividers
Each LDR with a 10 kΩ resistor forms a divider from 3.3 V; the four midpoints go to ADS1115 inputs A0–A3.
Connect the servos
Pan and tilt servos to PCA9685 channels 0 and 1, powered from a separate 5 V UBEC with grounds joined.
Run the loop
Compare top vs. bottom and left vs. right, and nudge each servo a degree toward the brighter side every second.
Measure the gain
Log the panel's output with an INA219 for a tracking day and a fixed day, and compare.
Code
import time, board
import adafruit_ads1x15.ads1115 as ADS
from adafruit_ads1x15.analog_in import AnalogIn
from adafruit_servokit import ServoKit
i2c = board.I2C()
ads = ADS.ADS1115(i2c)
tl, tr, bl, br = (AnalogIn(ads, ch) for ch in range(4))
kit = ServoKit(channels=16)
pan, tilt = 90.0, 45.0
DEAD = 0.05 # volts of difference to ignore
while True:
top, bot = tl.voltage + tr.voltage, bl.voltage + br.voltage
left, right = tl.voltage + bl.voltage, tr.voltage + br.voltage
if abs(top - bot) > DEAD:
tilt += 1 if top > bot else -1
if abs(left - right) > DEAD:
pan += 1 if left > right else -1
pan, tilt = max(0, min(180, pan)), max(0, min(90, tilt))
kit.servo[0].angle, kit.servo[1].angle = pan, tilt
time.sleep(1)Tip: test every script on the bench before installing it in a moving machine.
Questions
Is tracking worth it for a home system?
For big rooftop systems, usually not — panels are cheap and moving parts need maintenance. For small portable panels and learning, it is a great experiment.