Open access peer-reviewed chapter

Analysis of the Solar Tracking System for a Mobile Robot Prototype

Written By

Dario Guilherme Toginho, Alex Archela and Leonimer Flávio de Melo

Submitted: 19 February 2019 Reviewed: 11 November 2019 Published: 08 January 2020

DOI: 10.5772/intechopen.90436

From the Edited Volume

Reliability and Ecological Aspects of Photovoltaic Modules

Edited by Abdülkerim Gok

Chapter metrics overview

818 Chapter Downloads

View Full Metrics


Methods to detect the position of the sun and orientate a solar panel to its position are used in order to optimize the power generated. Two possible approaches are using light depending resistor (LDR) sensors, or using a GPS and equations that model the geometry between the Earth and the Sun. The main objective of this work is the proposal of a prototype system to optimize the harvesting of solar energy on photovoltaic panels. In this chapter, a mobile robot powered by a solar panel orientated by a LDR matrix and a GPS device was developed. The LDRs were used as the representation of vectors normal to a surface, where its sum resulted in the most lighted point. The GPS, in turn, provided location, date and time data, which were used in the calculations of the Sun?s azimuth and zenith, used to orientate the panel. The obtained results show that an orientated photovoltaic panel has a better performance when compared to a static panel. Possibilities and opportunities of research tend to grow for the next years with many possible works to be done in the future, both in mobile robotics and in other systems powered by photovoltaic panels.


  • photovoltaics
  • embedded
  • robotics
  • tracking
  • optimization

1. Introduction

The use of photovoltaic energy is one of the most promising alternative energy resources. Given the high fossil fuel consumption and economic and environmental impact of other sources, solar energy has become one of the most viable alternatives, given its low impact and the fact that it is renewable.

The sun provides both thermal and light energies, and in order to convert its light energy to electrical energy, photovoltaic cells are used. The cells of the panel used in this work are made of silicon. According to [1], the efficiency of large-area commercial cells is about 24%, and the upper limit of the silicon solar cell efficiency is 29%. In order to optimize the energy generated by a photovoltaic panel, instead of using it in a fixed position, methods of tracking the position of the sun and adjusting the panel accordingly are used, so the sun’s rays are perpendicular to the photosensitive surface [2].

The works of [3, 4] show systems that use light-dependent resistor (LDR) as a way to obtain the sun’s position [5]. On the other hand, the work of [6] shows an approach that allows the control of a photovoltaic cell based on its temperature, and the work of [7] shows a different design to the motors that control the position of photovoltaic panels, in order to decrease the energy used by the drivers [8].

In this chapter a method that uses both GPS and a LDR matrix is described, with the solar panel attached to a mobile robot, using ARM microcontroller device (STM32F407). Also there is a comparison of both approaches, in order to find the most efficient position for the panel and the possible applications both in the field of mobile robots and in others.

2. Solar tracking approaches

Similar to the work of [9], in this paper a solar panel powers a mobile robot, but the main difference is that the panel on the robot of [9] has two motors to move it in the x-axis and y-axis [10]. The robot used in this work has a panel that moves in the φ-axis (spherical coordinates), and the adjustment of the panel position consists in operating this φ-axis motor and adjusting the position of the robot [11, 12].

2.1 LDR approach

The LDR matrix consists of a Styrofoam half-sphere with 20 LDRs attached on its surface, each one representing a coordinate of the three-dimensional space. Figure 1 shows a 3D model representing the LDR positions.

Figure 1.

LDR surface 3D model, where the black arrows represent the position of the LDRs.

The LDRs have a voltage divider, and the microcontroller’s A/D converter reads its value. As light reaches the LDR, its resistance decreases. The design of the voltage divider was done in a way that its output voltage increases, so the more light reaches on the LDR, the higher the readings will be on the A/D converter.

However, the LDRs are sensitive not just to sunlight but also the environment’s reflected lights, and the A/D converter reads these lights with a small difference between them. In order to find which reading corresponds to the direct sunlight, a series of mathematical operations are performed, in a way that increases this difference.

When representing the LDRs in spherical coordinates ρ θ φ , we may change ρ to the A/D converter read value. So, we can write the coordinates as L θ φ θ φ , where L θ φ is the LDR A/D reading on the corresponding θ and φ coordinates. Since the microcontroller A/D converter has a 12 bit resolution, its value range is seen on Eq. (1):

0 L θ φ 4095 E1

In order to find the most relevant readings, all of them are divided by the average and then squared. In this way, it is possible to obtain the most significant readings. These readings are represented by W θ φ , as seen on Eq. (2), where L θ φ ´ represents the average of the readings of all LDRs:

W θ φ = L θ φ L θ φ ´ E2

The next step to obtain the position of the sun via the LDRs is to convert the spherical coordinates W θ φ θ φ to the Cartesian coordinate system x y z and then sum all elements. As a result, we obtain the coordinates of the position on the Styrofoam surface that represents a vector pointing towards the sunlight. The spherical coordinates to Cartesian equations can be seen on Eqs. (3)(5):

x = W θ φ sin φ cos θ E3
y = W θ φ sin φ sin θ E4
z = W θ φ cos φ E5

Then, the result in spherical coordinates ρ final θ final φ final is given by Eqs. (6)(8), where Σx , Σy , and Σz are the sum of the respective Cartesian coordinates of all LDRs:

ρ final = Σx 2 + Σy 2 + Σz 2 E6
θ final = cos 1 Σy Σx E7
φ final = sin 1 Σz Σx 2 + Σy 2 + Σz 2 E8

Having the θ final and φ final coordinates, it is possible to adjust the position of the panel in such way it is perpendicular do the direct sunlight, using θ final to adjust the position of the robot and φ final to adjust the servomotor.

2.2 GPS approach

The use of the GPS device to obtain the position of the sun is based on a set of equations that return the coordinates of the sun in the horizontal coordinate system. These coordinates are the zenith angle, the altitude angle, and the azimuth angle, and all of them are seen in Figure 2.

Figure 2.

Azimuth and altitude angle of the sun (adapted from [6]).

In this work, Eqs. (9)(11) are the same from [9]:

θ z = cos 1 sin δ sin φ + cos δ cos φ cos ω E9
α = 90 o θ Zn E10
A = cos 1 sin α sin φ sin δ cos α cos φ E11

where θz: incidence angle (or zenith angle); δ: declination angle; α: altitude angle; φ: local latitude; ω: hour angle; A: Azimuth angle.

The declination angle δ is the angle between the equator and a line connecting the earth and the sun, and it varies according to the current date. The hour angle ω is the angle that depends on the current time, representing the position of the sun above the observer.

The GPS device used is shown in Figure 3, and it provides the current time and location and, with these data, is possible to calculate the solar angles and correct the panel position accordingly.

Figure 3.

Picture of GPS device used.

It sends data on an interval of 1 second. The data received is a string that uses National Marine Electronics Association (NMEA) specification. The string contains coded phrases, and each phrase contains a specific set of information. Among the phrases, there is information containing the current location, time, and date. Figure 4 shows an example of all phrases received.

Figure 4.

NMEA specification data received through serial monitor.

The first phrase, being the one with the code $GPRMC, contains all the information required to obtain the current position of the sun. Commas separate each part of the data. After the code, the first number is 134759.00, which represents the time 13h47min59s. The second number is 2319.68361 followed by the letter S, which represents south latitude 23°1,968,361′. After that is the number representing the longitude followed by the letter W, which stands for west, so the longitude is 51°1215109’West. The next piece of information, which is 0.019, is the current speed over the surface in knots, followed by the number 170518, which stands for the date, in this case meaning May 17th of 2018.

3. Implementation

A set of PWM signals drive the motors of the robot, and its speed is proportional to the duty cycle used. The duty cycle in turn is proportional to the difference between the direction of the robot and the direction of the sun. A picture of the robot is seen in Figure 5.

Figure 5.

Picture of the mobile robot.

This difference is obtained calculating the Euclidian distance between the obtained position of the sun and the direction of either the front or the back of the robot (whichever is the nearest one) and minimizing it. As this difference is calculated using unit vectors, its range, as seen on Eq. (12), is never higher than 2:

0 d 2 E12

So d is the maximum possible distance between the position of the robot and the position of the sun; therefore, d = 2 implies a maximum use of the motors to correct the position of the robot, and d = 0 means the robot is at the desired position.

However, as a control method, d = 0 is not used as a parameter to determine if the desired position is achieved, for it is an ideal situation. Instead, a value close to 0 is used. So, for example, a possible condition to consider that the robot is in the correct position is to consider d < 0.01 .

Sections 3.1 and 3.2 have a detailed description of each approach used to detect the direction of the sun, and Figure 6 contains a block diagram of the system.

Figure 6.

Block diagram of the system.

3.1 LDR implementation

A half-sphere of Styrofoam was used to arrange the LDRs symmetrically, and the position of each LDR was chosen based on the manufacturing marks on its surface, having a total of 20 positions. All LDRs had a common terminal connected to a voltage source, and the other ends were connected to a multiplexer circuit. This multiplexer circuit is connected to the microcontroller, which selects the LDR and also reads its analogic value.

After the microcontroller calculates the position of the sun, it sends a signal to the motors of the mobile robot, to adjust its position in a way that its front or its back faces the sun and to the servomotor to adjust it to the proper inclination. The decision of if it is either the front or the back of the robot that should face the sun is based on which of these sides are closer to sunlight, in order to minimize the motion of the robot.

The signal sent to the motors of the robot, as said in the beginning of Section 3, is a PWM signal, proportional to the Euclidian distance in the x-y plane of the position of the sun and the front, or back, of the robot, which is seen in Eq. (13):

d ldr = cos 2 θ final + sin θ final y robot 2 E13

The value of y robot is either 1, if the sun is closer to the front of the robot, or − 1, if the sun is closer to the back of the robot. As d ldr gets closer to 0, it means the robot is getting closer to the direction of the sun.

3.2 GPS implementation

An electronic GPS device was used to obtain the required data to calculate the position of the sun, these data being latitude, longitude, day, month, year, hour, and minute. In addition, an electronic compass was used to obtain the angle the front of the robot formed with the north direction.

In order to keep the same reference as the LDR approach, the compass returns 90° when the front of the robot faces north and −90° when its back faces north. The value of the zenith angle is used as a signal in the servomotor to adjust the inclination of the solar panel. To make the robot face the sun, the Euclidian distance between its front or its back, depending on which one is closer, and the azimuth of the sun must be minimized. Eq. (14) returns this distance, where θn is the angle of the north direction and the robot:

d gps = cos 2 θ n A + sin θ n A y robot 2 E14

As in Section 3.1, the value of y robot is either 1, if the sun is closer to the front of the robot, or − 1, if the sun is closer to the back of the robot. As d gps gets closer to 0, it means the direction of the robot is getting closer to the direction of the sun.

4. Results

4.1 LDR results

The preliminary tests on the LDR matrix were done in a darkroom with a flashlight. Figure 7 shows a picture of the position that was tested.

Figure 7.

Photo of the first LDR sample with the coordinate of each LDR.

Then, with each LDR connected to the A/D converter, the data were collected and processed in order to obtain the light position on the surface. In Table 1, written in the color red are the values read by the A/D converter, with the range mentioned on Eq. (1), for each LDR on its respective position in Figure 7, and NA (not applicable) represents the positions where there are no LDRs.

L θ φ
LDR spherical coordinates φ = 22.5 φ = 45 φ = 67.5
θ = 0 ° 2580 NA 840
θ = 22.5 ° NA 481 NA
θ = 45 ° NA NA 429
θ = 67.5 ° NA 361 NA
θ = 90 ° 914 NA 281
θ = 112.5 ° NA 292 NA
θ = 135 ° NA NA 154
θ = 157.5 ° NA 1673 NA
θ = 180 ° 2647 NA 1151
θ = 202.5 ° NA 3080 NA
θ = 225 ° NA NA 2478
θ = 247.5 ° NA 3674 NA
θ = 270 ° 3616 NA 3433
θ = 292.5 ° NA 3668 NA
θ = 315 ° NA NA 2371
θ = 337.5 ° NA 1667 NA

Table 1.

Raw readings of the a/D converters with range from 0 to 4095.

Then, the values from Table 1 are used as argument to Eq. (2), and as the next step, Eqs. (3)(8) are used.

Using the data of Table 1, the average is calculated, and the value L θ φ ´ = 1789.5 is obtained. So, all values in Table 1 below 1789.5 will become 0, and the remaining ones will be subtracted and then squared.

The sum of these values as vectors equals the resulting position ( ρ final θ final φ final ), which is seen as the blue arrow in Figure 8. The spherical coordinates obtained are (24.952508o, 38.555257o, 97.442222o). However, in Figure 8, the ρ coordinate was reduced in order to fit in the figure.

Figure 8.

3D model of the collected data and its result on the surface.

Table 2 shows a set of 10 samples of Figure 7 on a 1 second interval, in which n = 1 is the sample plotted in Figure 8. The table also includes the mean value of the samples and the standard deviation.

Sample time (seconds) φ coordinate [o] θ coordinate [o]
1 38.555257 −97.442222
2 38.422000 −99.008884
3 38.570818 −97.637040
4 38.551388 −97.037137
5 38.575064 −98.695924
6 38.503982 −98.473986
7 38.545190 −100.300662
8 38.470601 −96.550539
9 38.586206 −97.503065
10 38.445780 −98.427292
Mean φ [o] 38.524916
Std. deviation of φ [o] 0.068990
Mean θ [o] −97.781321
Std. deviation of θ [o] 0.855672

Table 2.

LDR samples over 10 s.

4.2 GPS results

The GPS was tested under the following conditions:

  • Local: Londrina State University

  • Time: 13h48min

  • Sample time: 1 s

The GPS device received its fix data in the default interval of 1 second, and for each sample, an altitude angle and an azimuth angle were calculated. Table 3 shows the solar angle data and its mean values and standard deviations.

Sample time (seconds) Altitude α [o] Azimuth A [o]
1 42.092760 −28.719862
2 42.095466 −28.704564
3 42.098172 −28.689464
4 42.100877 −28.674137
5 42.101605 −28.714010
6 42.090841 −28.697598
7 42.096462 −28.700248
8 42.095976 −28.684667
9 42.097934 −28.675514
10 42.097912 −28.675200
Mean α [o] 42.096819
std. deviation of α [o] 0.003493
Mean A [o] −28.697007
std. deviation of A [o] 0.019659

Table 3.

GPS samples over 10 seconds.

4.3 Power results

Three test scenarios were executed. One is where the solar panel is fixed and the other two where the sun is tracked, one using LDR and the other using the GPS. The sampling period was 5 minutes.

In Figure 9 it is possible to observe the power generated by the panel on each scenario. The LDR and the GPS approaches have shown a very similar performance compared to each other, and both of them demonstrated to be much better than a fixed panel, having a gain of approximately 30%. The yellow line in the figure represents what would be the ideal maximum generated power by the panel, considering the average solar irradiation nearby the site and the surface area of the panel. The LDR approach as the GPS has shown an efficiency of 80% compared to the ideal maximum power.

Figure 9.

Power samples of the three tested scenarios.

5. Conclusion

During the data collection, the LDR matrix has showed to be very sensitive to noise, so it presented a higher deviation. On the other hand, the GPS data had a much lower deviation. However, during the data collection, it took a certain amount of time to get a fix and obtain the current date, time, and location.

Besides the solar panel orientation, i.e., for applications in the mobile robotics, the GPS device provides navigation data that may be useful, which is an advantage. However, if the device takes too long to get a fix or loses the fix, the data will be null or delayed. So, in order for a mobile robot to obtain full-time orientation, both the GPS and LDR approaches may be used together.

For other applications, such as a panel on a fixed position, the latitude and longitude are fixed, so there is no need for a GPS device, just a real-time clock (RTC) device, which eliminates the GPS fix time issue and also has a lower cost compared to the LDR approach.

Having all things considered, the LDR is a low-cost method to track the position of the sun; however, it is more affected by noise. The sun-earth equations have shown problems only when depending of a GPS device to provide data; otherwise, it is the most precise approach.


  1. 1. Blakers A, Zin N, McIntosh KR, Fong K. High efficiency silicon solar cells. Energy Procedia. 2013;33:1-10
  2. 2. Fedor P, Perduková D. Use of fuzzy logic for design and control of nonlinear MIMO systems. In: Ramakrishnan S, editor. Modern Fuzzy Control Systems and Its Applications. London, UK: IntechOpen; 2017. DOI: 10.5772/68050
  3. 3. Mustafa FI, Al-Ammri AS, Ahmad FF. Direct and indirect sensing two-axis solar tracking system. In: 8th International Renewable Energy Congress (IREC). 2017. pp. 1-4
  4. 4. Mustafa FI, Shakir S, Mustafa FF, Naiyf AT. Simple design and implementation of solar tracking system two axis with four sensors for Baghdad city. In: 9th International Renewable Energy Congress (IREC). 2018. pp. 1-5
  5. 5. Ikedi C. Experimental study of current-voltage characteristics for fixed and solar tracking photovoltaics systems. In: Prabaharan N, Rosen MA, Campana PE, editors. Recent Developments in Photovoltaic Materials and Devices. London, UK: IntechOpen; 2019. DOI: 10.5772/intechopen.79710
  6. 6. da Rocha NMM, Passos JC. MPPT method based on temperature control of the photovoltaic cells. In: 12th IEEE International Conference on Industry Applications (INDUSCON). 2016. pp. 1-8
  7. 7. Kuhn VN, Gonzatti F, Franchi D, Miotto M, Camargo MN, Farret FA. Hybrid motor driver for solar tracking system. In: 12th IEEE International Conference on Industry Applications (INDUSCON). 2016. pp. 1-6
  8. 8. Chin CS. Model-based simulation of an intelligent microprocessor-based standalone solar tracking system. In: Katsikis VN, editor. MATLAB–A Fundamental Tool for Scientific Computing and Engineering Applications. Vol. 3. London, UK: IntechOpen; 2012. DOI: 10.5772/46458
  9. 9. Fei Y, Lv H. Design of the solar-driven module on modular mobile robot. In: 19th International Conference on Mechatronics and Machine Vision in Practice (M2VIP). 2012. pp. 470-473
  10. 10. Milea L, Zafiu A, Oltu O, Dascalu M. Theory, algorithms and applications for solar panel MPP tracking. In: Manyala R, editor. Solar Collectors and Panels, Theory and Applications. London, UK: IntechOpen; 2010. DOI: 10.5772/10337
  11. 11. Zhan TS, Lin WM, Tsai MH, Wang GS. Design and implementation of the dual-axis solar tracking system. In: IEEE 37th Annual Computer Software and Applications Conference. 2013. pp. 276-277
  12. 12. Engin D, Engin M. Sensors and digital signal conditioning in mechatronic systems. In: Yildirim S, editor. Design, Control and Applications of Mechatronic Systems in Engineering. London, UK: IntechOpen; 2017. DOI: 10.5772/67986

Written By

Dario Guilherme Toginho, Alex Archela and Leonimer Flávio de Melo

Submitted: 19 February 2019 Reviewed: 11 November 2019 Published: 08 January 2020