# Solar Tracking

Hi guys!

I'm recently involved in a project that consists on a series of panels (not solar) that rotate according to the sun's postition (1 axis). They will only rotate 180º degrees and the axis of rotation is perpendicular to the ground.

The mechanical part is more and less well defined.

My main concern right now is how to control the motor in order for the panels to follow the sun.
I've looked through a number of solar tracking projects, but most of them are based on LDR sensors and I need this to be more precise than that.

I understand that using GPS coordinates in order to calculate the solar position is much more precise, as well as more complicated. From what I've read this solar position library does the calculations for that position taking into consideration the coordinates and the time read from a RTC. The panels have to be metallic, so I can't use a compass.

Do you think that using luminosity sensors is viable by trying to correct possible "noise" on the sensors on cloudy days ? In that case what do you think are the most reliable sensor modules?

In case of using GPS coordinates, how do I translate the obtained azimuth values into the precise motor rotation, knowing that I can't use a compass?

Can I use a stepper motor or does it help to be a servo?

If you guys have any more additional tips, or need any information, please let me know.

Thank you!

just use the solar position library, it won't get better with any sensors.

Why can't you use a compass? There are IC's that do that.

joaomiranda2:
but most of them are based on LDR sensors and I need this to be more precise than that.

Have you actually measured how accurate the LDRs can be? Have you them arranged in the ideal configuration?

I understand that using GPS coordinates
[....]
metallic, so I can't use a compass.

GPS and a compass are intended for tracking things on the earth. How could they possibly track the sun?

...R

Robin2:
GPS and a compass are intended for tracking things on the earth. How could they possibly track the sun?

I think that the solar tracking library needs GPS position and facing direction to calculate the sun’s position in the sky relative to the panels.

wildbill:
I think that the solar tracking library needs GPS position and facing direction to calculate the sun's position in the sky relative to the panels.

Presumably you can read the position from a hand-held GPS or from a phone with GPS and then hard-code it into the program?

...R

You could also use google earth for that. And in addition you could identify an object at a known heading and aim for it.

If this device is mobile, it could use GPS and a magnetic compass IC to obtain location and bearing. If not, of course the values could be entered manually, one time. EEPROM makes sense for that.

how do I translate the obtained azimuth values into the precise motor rotation

No need to do so. Just align the panel to some reference orientation (like the sun) during installation, and track from there. The Earth’s rate of rotation is for all practical purposes a constant.

First of all, thank you guys for the tips.
I will try to answer everyone.

aarg:
Why can't you use a compass? There are IC's that do that.

This installation will contain a lot of metal, maybe even iron, won't that affect its reading?

Robin2:
Have you actually measured how accurate the LDRs can be? Have you them arranged in the ideal configuration?
GPS and a compass are intended for tracking things on the earth. How could they possibly track the sun?

...R

I haven't measured the accuracy of LDR nor arrenged them in any configuration. But, since the sensor will have to track direct sunight, from what I've read they're not the best option and are mainly used to detect big luminosity changes, not subtle variations of light intensity. But please correct me if I'm wrong.

I understand using two LDR's and basically check the difference between their values and update the motor position would be a lot easier, I just don't know if it's accurate enough under direct sunlight or more cloudy days.

aarg:
If this device is mobile, it could use GPS and a magnetic compass IC to obtain location and bearing. If not, of course the values could be entered manually, one time. EEPROM makes sense for that.

The device is static. I did not explain myself properly but when I talked about GPS, I meant GPS coordinates, my bad. I can just enter them in the program.

jremington:
No need to do so. Just align the panel to some reference orientation (like the sun) during installation, and track from there. The Earth's rate of rotation is for all practical purposes a constant.

So what you are saying is basically "manually" operate the motor without feedback from the sun position? For example, 1h has passed, rotate the motor x times, so on?

Won't this be affected with summer/winter time change?

“manually” operate the motor without feedback from the sun position

Correct. The motor need only drive in carefully selected steps (constant 0.25 degrees per minute if the axis of rotation is polar) to accurately track the sun position, if the initial orientation is correct. Use the azimuth angle from the sun position library as your guide.

How do you plan to reset the panel position overnight?

Note: the sun does not follow daylight savings timekeeping conventions.

Edit: add simple Arduino program to create a table of solar positions for one day.

``````/*
This program calculates solar positions as a function of location, date, and time.
The equations are from Jean Meeus, Astronomical Algorithms, Willmann-Bell, Inc., Richmond, VA
(C) 2015, David Brooks, Institute for Earth Science Research and Education.
http://www.instesre.org/
*/
#define PI 3.141592654
#define TWOPI 6.28318531

// local date and time zone
int month = 4, day = 27, year = 2020, zone = 8;
// local GPS coordinates
float Lon = -123.00, Lat = 43.00;

void setup() {

Serial.begin(9600);
Serial.print("Sun position table ");
Serial.print("at lat/lon location ");

Serial.print(Lat);
Serial.print("/");
Serial.println(Lon);

Serial.print("Date (y/m/d): ");
Serial.print(year);
Serial.print("/");
Serial.print(month);
Serial.print("/");
Serial.println(day);
Serial.println();

Serial.println("Local hour, minute, elevation, azimuth");

int hour, minute = 0, second = 0;
float T, JD_frac, L0, M, e, C, L_true, f, R, GrHrAngle, Obl;
float RA, Decl, HrAngle, elev, azimuth;
long JD_whole, JDx;

// Changes required in for… loop to get complete
// daylight coverage
// Time is UTC time!

// make a table by hours

for (hour = 12; hour <= 24; hour++) {
JD_whole = JulianDate(year, month, day); //4 digit year > 1582
JD_frac = (hour + minute / 60. + second / 3600.) / 24. - .5;
T = JD_whole - 2451545;
T = (T + JD_frac) / 36525.;
L0 = DEG_TO_RAD * fmod(280.46645 + 36000.76983 * T, 360);
M = DEG_TO_RAD * fmod(357.5291 + 35999.0503 * T, 360);
e = 0.016708617 - 0.000042037 * T;
C = DEG_TO_RAD * ((1.9146 - 0.004847 * T) * sin(M) + (0.019993 - 0.000101 * T) * sin(2 * M) + 0.00029 * sin(3 * M));
f = M + C;
Obl = DEG_TO_RAD * (23 + 26 / 60. + 21.448 / 3600. - 46.815 / 3600 * T);
JDx = JD_whole - 2451545;
GrHrAngle = 280.46061837 + (360 * JDx) % 360 + .98564736629 * JDx + 360.98564736629 * JD_frac;
GrHrAngle = fmod(GrHrAngle, 360.);
L_true = fmod(C + L0, TWOPI);
//        R = 1.000001018 * (1 - e * e) / (1 + e * cos(f));
R = 0.000001018 * (1 - e * e) / (1 + e * cos(f));
R = R + (1 - e * e) / (1 + e * cos(f));
RA = atan2(sin(L_true) * cos(Obl), cos(L_true));
Decl = asin(sin(Obl) * sin(L_true));
HrAngle = DEG_TO_RAD * GrHrAngle + Lon - RA;
elev = asin(sin(Lat) * sin(Decl) + cos(Lat) * (cos(Decl) * cos(HrAngle)));
// Azimuth measured eastward from north.
azimuth = PI + atan2(sin(HrAngle), cos(HrAngle) * sin(Lat) - tan(Decl) * cos(Lat));

Serial.print(hour - zone);  //local hour from UTC
Serial.print(",");
Serial.print(minute);
Serial.print(",");
Serial.print(",");
Serial.println();
}
}

void loop() {}

long JulianDate(int year, int month, int day) {
// not correct for year < 1583 (Gregorian calendar)
long JD_whole;
int A, B;
if (month <= 2) {
year--;
month += 12;
}
A = year / 100;
B = 2 - A + A / 4;
JD_whole = (long)(365.25 * (year + 4716)) + (int)(30.6001 * (month + 1)) + day + B - 1524;
return JD_whole;
}
``````

joaomiranda2:
I understand using two LDR's and basically check the difference between their values and update the motor position would be a lot easier, I just don't know if it's accurate enough under direct sunlight or more cloudy days.

Considering their simplicity if they do work and their low cost for doing an experiment it seems to me that testing would be well worthwhile before considering a more complex / expensive solution.

I suspect that if the LDRs are separated by a suitable black shield to cause a shadow on one when the sun moves (more accurately, when the earth moves) they will be perfectly adequate. I would expect a longer shield to give greater sensitivity.

You say your device is not solar panels but you have not told us what it is so I have no idea whether it would be better to track the brightest part of the sky on a cloudy day (which might mean moving backwards) or whether it would be more appropriate to write the code so the panel would not move backwards.

It is much easier to give useful advice when you provide a full description of your project.

...R

If the device is static, it's pointless to add a compass, just as it's pointless to add a GPS.

Hi,
How precise do you need to be?
LDR system seeks and points to the BRIGHTEST part of the sky, if its cloudy it will still point to the BRIGHTEST part of the sky, because they detect SOLAR RADIATION.
If it is partially cloudy and obscuring the sun, the direction of the sun may not be the BRIGHTEST part of the sky.

With sun sensor type systems you don't need a compass or a GPS or a clock, the system even adjusts itself for daylight saving.
You can conserve power by sleeping for 15minutes then wakeup and sample and move, then back to sleep.

Tom...

TomGeorge:
With sun sensor type systems you don't need a compass or a GPS or a clock, the system even adjusts itself for daylight saving.

There is no need to use daylight savings or local time for tracking. UTC is all you need. If the system location is fixed, there is only a one time Google Maps or Google Earth lookup for lat/long and bearing information.

jremington:
Correct. The motor need only drive in carefully selected steps (constant 0.25 degrees per minute if the axis of rotation is polar) to accurately track the sun position, if the initial orientation is correct. Use the azimuth angle from the sun position library as your guide.

How do you plan to reset the panel position overnight?

Note: the sun does not follow daylight savings timekeeping conventions.

Edit: add simple Arduino program to create a table of solar positions for one day.

Thanks for the code! I will soon test this option!

My plan to reset the panel is either to define a hour on which it resets, or using a luminosity sensor, that below a certain value (corresponding to night time) also could reset it.

Robin2:
Considering their simplicity if they do work and their low cost for doing an experiment it seems to me that testing would be well worthwhile before considering a more complex / expensive solution.

I suspect that if the LDRs are separated by a suitable black shield to cause a shadow on one when the sun moves (more accurately, when the earth moves) they will be perfectly adequate. I would expect a longer shield to give greater sensitivity.

My concern about the LDRs are the fact that the maximum lux level at which they saturate (meaning the light level at which they reach their minimum resistance) is around 10 000 lux according to this. So, even with that barrier between them, which is something I've thought about, I'm afraid that at bright daylight they can saturate even if not facing the sun, considering refraction of the light. But is certainly something that I should test.

Robin2:
You say your device is not solar panels but you have not told us what it is so I have no idea whether it would be better to track the brightest part of the sky on a cloudy day (which might mean moving backwards) or whether it would be more appropriate to write the code so the panel would not move backwards.

It is much easier to give useful advice when you provide a full description of your project.

...R

I'm sorry, these panels will work as sort of a replacement of a window. There are some other mechanical predicaments, but in terms of control it's basically making the panels follow the sun in order to prevent the maximum amount light from going in.

aarg:
If the device is static, it's pointless to add a compass, just as it's pointless to add a GPS.

Yes, the GPS is pointless, the coordinates are all I would need. But wouldn't a compass be helpful in order to provide a reference of the north from which to measure the azimuth (based on solar calculations of the coordinates) and make the panels face that exact azimuth? How would I translate the solar calculations into precise orders for the motor rotation?

TomGeorge:
Hi,
How precise do you need to be?
LDR system seeks and points to the BRIGHTEST part of the sky, if its cloudy it will still point to the BRIGHTEST part of the sky, because they detect SOLAR RADIATION.
If it is partially cloudy and obscuring the sun, the direction of the sun may not be the BRIGHTEST part of the sky.

With sun sensor type systems you don't need a compass or a GPS or a clock, the system even adjusts itself for daylight saving.
You can conserve power by sleeping for 15minutes then wakeup and sample and move, then back to sleep.

Tom...

I don't need to be super precise, if they are facing the general direction of the sun, even with some disalignement, it's ok. I just don't want the panels to drift off and track a completely part of the sky. Yes, I know that it's either using sun sensor or the coordinates, I'm just debating which one to pursuit. My concern about the LDR is what I've stated above.

joaomiranda2:
I'm sorry, these panels will work as sort of a replacement of a window.

I'm always intrigued when people are reluctant to provide a clear description of the project they are hoping to get help for.

Why not just tell us what the panels actually are rather than wasting time telling us what they are "sort of".

...R

Oh, don't be so picky! You surely know what a sort of replacement for a window is! It's called "wall"

Robin2:
I'm always intrigued when people are reluctant to provide a clear description of the project they are hoping to get help for.

Why not just tell us what the panels actually are rather than wasting time telling us what they are "sort of".

...R

Look, I'm really thankful for all the help you guys are providing.

From all that I've said, don't really see the need to focus on that and not say anything about the rest.

I'm not hiding anything, it's not like I'm developing the next big thing, there is nothing special or proprietary about this, just gave the information I thought was essential.

Imagine you have a balcony, and your access to that balcony is through a moving window. Replace the window with these rotating panels. And these panels rotate according to the position of the sun. There is a manual override and other control stuff involved, but I think I'm able to do that on my own, what I'm asking for help is the solar tracking part.

Again, thank you!

Sorry, everybody* thought you want to build somthing that requires precise solar tracking. Now it turns out you want to move shades. What's the point in not telling that in your initial posting?