Here’s an interesting library submitted by Julien Ducret that uses augmented reality to track the position of the sun on your device called BRSunTracker.

BRSunTracker uses your gps location, date, and timezone to compute the location of the sun, and uses the gyroscope to decied where on the device screen the sun actually is. You can find further information on the algorithm used in the readme.

Here is an animation from the readme that shows BRSunTracker in action: