The key part of this project is determining location through known date/time and light levels.
Determining geographical longitude from light levels data is relatively straightforward. Take the time of solar noon and compare it to 12:00 of Greenwich time. If it's 12:00, then you are (approximately though) at Greenwich, if not, you are 15 degrees farther to East for each hour.
Calculating the latitude is somehow different matter. The relation between day length (at particular solar zenith angle), solar declination and geographical latitude is called sunrise equation, in general form looking like this
where A is solar zenith angle
L is geographical latitude
D is solar declination
O is hour angle
I played with it a bit, discovering relations between the variables. At first I was curious how does look the relationship between latitude and day length at different solar declinations, as those are the the main variables that come into game.
Expectedly, I can see strong relationship of day length and latitude when solar declination hits its extremes (winter and summer solstices) and very weak relationship at zero declination (spring/autumn equinoxes).
Change of day length over the changes of solar declination (= throughout the year) is almost linear, for -48, -22, 0, 22 and 48 degrees of latitude.
I was interested also how much the day length is changing when taking into account different solar zenith angles; the previous ones being at -0,83 degrees; being standard for sunrise/sunset tables. Though my detection algorithm triggers at slightly different angle, shifting the measured day length to somehow longer times. Here are day lengths at different sun zenith angles, for three different latitudes (48, 0, -48 degrees)
and here are just the differences
The differences are almost linear, with change rate slightly being dependent on latitude.
My problem with this equation is it's reverse of what I need - it gives me length of day from latitude, while I have the day length known, with latitude unknown. It looks like there isn't analytical solution to this equation. For now I have plan of having huge precomputed tables in FLASH memory of MCU and doing lookup, but I can't say I'm happy with it, though it can be quite effective when it comes to power consumption.