Static solar panels are leaving efficiency on the table. As the sun moves across the sky, a fixed panel loses up to 30% of its potential output. Sun trackers solve this, but building one could mean sourcing custom firmware, building custom hardware drivers, and writing a lot of glue code before you can actually program it.
We wanted to see how fast we could do it on Viam. The answer was: one day.
What We Built
Project Sunflower is a motorized solar panel on a pan-tilt servo mount that orients toward the sun (or any bright light source) using a USB camera and a closed-loop control algorithm. Everything on the parts list is off-the-shelf, orderable today, and totals under $260. The BeagleBone is the biggest line item; the panel itself is under $7.
- BeagleBone AI-64 ($189.35)
- Waveshare I2C Current/Power Sensor HAT ($19.99)
- Waveshare 2-DOF Pan-Tilt HAT ($17.99)
- 0.5W 5V Solar Panel Module ($6.99)
- 1080P USB UVC Camera ($18.99)
- 5mm LEDs (50-pack) ($4.59)
- M2.5 Screw, Nut & Washer Set ($6.98)
We only had to write a little code to make it work. Everything else was configurable in Viam.
How it Works
The sun-tracker module registers two cooperating services on your Viam machine.
The first, devrel:sun-tracker:sun-position, is a vision service. It takes a live camera feed and divides each frame into four quadrants, computing the mean brightness of each. That brightness data is what tells the system where the light is coming from.
The second, devrel:sun-tracker:sun-servo-tracker, is the control loop. It polls the vision service at a configurable rate, calculates the pan and tilt imbalance between quadrants, and drives the servos to correct it. A deadband prevents the servos from chasing small fluctuations; a brightness floor stops tracking entirely when there's no meaningful light source in frame. The result is a panel that finds the light and locks onto it.
Below is an example of the sun-servo-tracker configuration:
{
"vision_service": "sun_vision",
"camera": "my_camera",
"pan_servo": "pan_servo",
"tilt_servo": "tilt_servo"
}That's the minimum to get it running. From there, you can tune the PD gains, step limits, loop frequency, and servo ranges — or leave the defaults and it works out of the box.
The Part That Saved Us Time
The servo driver and the power sensor module already existed in the Viam Registry. We didn't write initialization code or worry about dependency management. We described our hardware in a config file, and Viam handled the rest.
The tracking logic — the part that's specific to this project — is all we actually built, not the plumbing.
And because Viam is hardware-agnostic, if we want to swap the BeagleBone for a Raspberry Pi, or upgrade to serial servos instead of GPIO, none of the tracking logic changes. The config changes; the code doesn't.
From One Panel to a Fleet
Once the machine is working, scaling is straightforward. Copy the config into a fragment, and you can spin up a second panel — or a hundred — without reconfiguring from scratch. Viam's data manager was already capturing power readings and servo state at 10 times per second with no additional code. Dashboards and monitoring come with the platform.
Prototype-to-production isn't usually this short a path. On Viam, it was.
Try It Yourself
The full module is available in the Viam Registry. Add it to any machine, wire up your servos and camera, and it should start working automatically.
- Module: app.viam.com/module/devrel/sun-tracker
- Source code: github.com/viam-devrel/sun-tracker
- Start building: app.viam.com

.png)