## 2 SGP System Description
### Celestial Model  
This paper presents a new algorithm to localize outdoor objects using only sunlight intensity data for a given location. With this information, it is possible to obtain the sunrise and sunset times for that location. Only with these two values, the celestial model determines the coordinates (both longitude and latitude). Thus, the coordinates can be expressed as a function of the sunrise and sunset times as shown in Figure 3.  
There is an accurate, well-known algorithm based on Julian Day which allows to find out the sunrise and sunset times for a specific place by only knowing the coordinates of that place and also the date [23]. However, it is not possible to obtain the _inverse_ of the algorithm since some formulas of this algorithm depend on both latitude and longitude, and when they are tried to be separated the result is that the latitude depends on the longitude and _vice-versa_.  
Figure 2: Hardware implementation based on Arduino Mega: power source, SD storage, clock and light dependent resistor (LDR) sensor. The simplest SGPS implementation costs less than US $40 in components.  
Then, the method described herein can be reduced to the problem of identifying the sunset and sunrise times for a given day. Given an accurate measurement of the sunrise time \(t_{sunrise}\) and sunset time \(t_{sunset}\), the solar noon \(t_{midday}\) is simply:  
\[t_{midday}=\frac{t_{sunrise}+t_{sunset}}{2} \tag{2}\]  
The UTC representation of time assumes that sunrise occurs before sunset. If the sunset occurs before the sunrise within the 24 h UTC time window then it means that it is a fractional day, since the sunrise happens the day before (in UTC format) that sunset. This has to be taken into account when applying this equation, since if the equation is applied directly with a sunset time earlier than the sunrise time, the noon time will not be correct (in fact, the result would be the _midnight_ time). Section 3.1 details how to overcome this issue when applying Equation (2).  
As stated in Section 2.1 the times have to be expressed in UTC and in decimal format (from 0 to 24). For the next formulas all the times will be expressed in this format and the angles in radians. The angular sunset can be computed as follows:  
\[a_{sunset}=\frac{\pi}{12}|t_{sunset}-t_{midday}| \tag{3}\]  
and the declination of the sun \(\delta\) can be approximated by the following Fourier series [24]:  
\[\delta = 0.006918-0.399912\cos(\beta)+0.070257\sin(\beta) \tag{4}\] \[-0.006758\cos(2\beta)+0.000907\sin(2\beta)\] \[-0.002697\cos(3\beta)+0.00148\sin(3\beta)\]  
where \(\beta\) is the fractional year expressed in radians given by:  
\[\beta=\frac{2\pi}{365}d \tag{5}\]  
and \(d\) is the day from 1 to 365. In the case of a leap-year, where \(d\) can be 366 the value for \(\beta\) is close to \(2\pi\), which gives the same result in the equation for \(\delta\) as when \(d\) is 1 and \(\beta\) is equal to \(2\pi/365\).  
Finally, the coordinates can be obtained. For the longitude \(\lambda\) (in radians), where positive values represent east and negative values represent west, the next equation is employed:  
\[\lambda=2\pi\frac{12-t_{midday}}{24} \tag{6}\]  
Figure 3: Daylight parameters influenced by latitude and longitude.  
and the latitude \(\varphi\) (in radians) of the objects location can be found by numerically solving for latitude using the following equation, where positive values represent north and negative values represent south:  
\[\cos(a_{sunset})=\frac{\sin(-0.0145)-\sin(\delta)\sin(\varphi)}{\cos(\delta) \cos(\varphi)} \tag{7}\]  
The equations provided in this sections allows to find out the coordinates for outdoor objects by means of the times of the sunrise and the sunset for a given day.