Building the SunRover navigation system

Sun Tracking Software

Tracking the sun can increase solar power generation by 20-30 percent. I could use feedback from photocell to locate the sun, or at least the brightest part of the sky, and turn the robot towards the bright point, but since the SunRover has a compass and a good realtime clock, it can locate the sun based on predefined information. See the SunCalc website for more on tracking where the sun is going to be [11].

Sunlight has two components, the "direct beam" that carries about 90 percent of the solar energy, and the "diffuse sunlight" that carries the remainder – the diffuse portion is the blue sky on a clear day and increases proportionately on cloudy days. As the majority of the energy is in the direct beam, maximizing collection requires the sun to be visible to the panels as long as possible.

At any fixed location, the visible sun travels across 180 degrees during an average one-half day period (more in spring and summer; less, in fall and winter). Local horizon effects reduce this somewhat, making the effective motion about 150 degrees. A solar panel in a fixed orientation between the dawn and sunset extremes will see a motion of 75 degrees to either side and will lose roughly 75 percent of the energy in the morning and evening. Rotating the panels to the east and west can help recapture those losses. The angle of the panels is also important, but I will just assume that 45 degrees is about right for the SunRover's latitude.

I'll put the Arduino into SunTracking mode (either from the Raspberry Pi or the time of the local sunrise), and the SunRover will act according to the following assumptions:

  • 10-hour day (600 minutes)
  • Sun rises at 90 degrees at sunrise (07:00 local time – UTC of 14:00)
  • Sun sets at 270 degrees at sunset (17:00 local time, UTC of 00:00 next day)
  • Break the 180 degrees into 20 steps move every 30 minutes

The solar panels turn to face the rising sun (90 degrees – due east), then they turn 9 degrees toward the west (positive degrees to the right) every 30 minutes. When the unit finishes at 270 degrees, the next step is to turn back to meet the rising sun.

I have tested this process by allowing the SunRover to turn about every 10 seconds instead of 30 minutes, and it is really funny to watch [12]. I am looking forward to some sun breaks here during winter to test the sun tracking outside. Figure 7 shows the SunRover sporting its stylish SunWings.

Figure 7: SunRover with the SunWings.


The biggest issue to this point has been with the Compass subsystem. Now that I have the compass working, though, I will start writing paths for the robot to take and finish the sun tracking code. SunRover is alive. The basics are done. SunRover can now move, see things, sense some things, and tell which way it is pointing.

Next, I will be putting in the rest of the sensors, taking the first attempt at a diagnostic system, and adding a ESP8266 WiFi module to the box, which will talk to the Arduino for a backup WiFi system so I can ask questions and give orders even while the Raspberry Pi 2 is sleeping.

Next up? The PiCamera, the SunRover I2C sensor suite, and the control and the diagnostic system – along with more driving videos.


  1. "Build a Bot: SunRover Part 1" by John C. Shovic, Raspberry Pi Geek #13, page 68
  2. "Build a Bot: SunRover Part 2" by John C. Shovic, Raspberry Pi Geek #14, page 60
  3. 6-Axis Acceleromter at Robot Mesh:
  4. "Lightning Detector" by John C. Shovic, Raspberry Pi Geek #12, page 54
  5. Faraday Cage:
  6. Bistable Latching Relay Kit at Wireless Things:
  7. Robot Encoder at Society of Robots:
  8. Wheel Encoder at SparkFun:
  9. Project Curacao:
  10. Robotic Operating System:
  11. SunCalc:
  12. SwitchDoc Labs Instagram Channel:

Buy this article as PDF

Express-Checkout as PDF

Pages: 8

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content