Tracker Solar

Hello!

Does anyone have code for the solar tracker project (consisting of 4 SWDS, which will rotate the servo motor in order to capture more light)??

Let me Google that for you.

“solar tracker arduino”

Oh yes. Here it is.

Well, that wasn’t so hard was it :wink:

And here is the code

/* this code is written by geobruce
for more info check my site http://xprobe.net
*/
#include <Servo.h> // include Servo library 

Servo horizontal; // horizontal servo
int servoh = 90; // stand horizontal servo

Servo vertical; // vertical servo 
int servov = 90; // stand vertical servo

// LDR pin connections
// name = analogpin;
int ldrlt = 0; //LDR top left
int ldrrt = 1; //LDR top rigt
int ldrld = 2; //LDR down left
int ldrrd = 3; //ldr down rigt

void setup()
{
  Serial.begin(9600);
// servo connections
// name.attacht(pin);
  horizontal.attach(9); 
  vertical.attach(10);
}

void loop() 
{
  int lt = analogRead(ldrlt); // top left
  int rt = analogRead(ldrrt); // top right
  int ld = analogRead(ldrld); // down left
  int rd = analogRead(ldrrd); // down rigt

  int dtime = analogRead(4)/20; // read potentiometers
int tol = analogRead(5)/4;

int avt = (lt + rt) / 2; // average value top
int avd = (ld + rd) / 2; // average value down
int avl = (lt + ld) / 2; // average value left
int avr = (rt + rd) / 2; // average value right

int dvert = avt - avd; // check the diffirence of up and down
int dhoriz = avl - avr;// check the diffirence og left and rigt

if (-1*tol > dvert || dvert > tol) // check if the diffirence is in the tolerance else change vertical angle
{
if (avt > avd)
{
servov = ++servov;
if (servov > 180)
{
servov = 180;
}
}
else if (avt < avd)
{
servov= --servov;
if (servov < 0)
{
servov = 0;
}
}
vertical.write(servov);
}

if (-1*tol > dhoriz || dhoriz > tol) // check if the diffirence is in the tolerance else change horizontal angle
{
if (avl > avr)
{
servoh = --servoh;
if (servoh < 0)
{
servoh = 0;
}
}
else if (avl < avr)
{
servoh = ++servoh;
if (servoh > 180)
{
servoh = 180;
}
}
else if (avl == avr)
{
// nothing
}
horizontal.write(servoh);
}
delay(dtime);
}

well, since you asked for 4 swds and I have no idea what that means, I can offer you a couple places.

I checked out SWDS http://swds.org/ but could not find any information about solar tracking. " unique habitat for birds, bugs and other little creature...."

for what I know about solar tracking...first Dwyane over at Redrok invented the application of using 4 LED's as the sensors. it has been copied many times, so I would start there.

that site offers a non-arduino solution as it uses the sensors to move the motor. the problem is that without the smarts, it has a few areas that it cannot handle. such as it will not follow with clouds and does not have either a night return or a flat setting to eliminate the effects of wind.

the guy is brilliant, but not great on web page design.

the other place is the guy who is brilliant with arduino code for the same application. not sure if he uses 4swds though.

http://www.cerebralmeltdown.com/

this is a calculated postioner that uses your location on the planet, the alignment of the sun along with the rotation of the earth and will point the array at the sun. it does not use feedback so if your alignment is off, your tracking is off.

both are very viable technologies and the blending of the two would make a great final project. heck, you might be able to install one at SWDS !

... and there have been several Threads on the same subject in the last few months. Some even have a similar title.

...R

dave-in-nj: both are very viable technologies and the blending of the two would make a great final project. heck, you might be able to install one at SWDS !

Having a tracker based purely on realtime brightness feedback strikes me as a very crude approach, but using it to refine a cumulative estimate of lat/long and season to configure a polar aligned tracker seems very elegant.

the code works correctly?

sent me this code for a solar tracker, but it does to me, does not work!
someone could help me

sketch_jun14a.ino (1.68 KB)

That 1.68k file is small. If it does not work then you are better off starting from a clean page. Write down your specification of what yours must do, should do, may do, could do, and then write small programs at first to test each part of that.

By the way, in your writeup you might get nil marks if you don't spell it as the Oxford Dictionary does.

If you want help from this forum, read this and follow directions before posting: http://forum.arduino.cc/index.php/topic,148850.0.html

Their have been several Threads about solar trackers in recent months. Google will help you find them.

...R

If you take the trouble to search for previous Threads about solar tracking you should quickly find that all you need is 4 Light Dependent Resistors and 20 or 30 lines of code.

if you are prepared to adjust the tilt manually once a month you only need 2 LDRs.

...R

Hi, at the top of this page is a window that says "search the Arduino Forum", I suggest you use it by inputting

solar tracker

The forum is littered with this subject, it has been done so many times before.

Tom........ :)

pc5_costa: sent me this code for a solar tracker, but it does to me, does not work! someone could help me

you need to get the schematic for that sketch and also make sure the servo's you are using are working with the signals being sent.

There are equations that very accurately estimate the position of the sun based upon the tear, month, day, time and your location, by accurate I think the max error is under 0.5° probably better than a tracker will do.

With these well known equations why not put in an RTC so you know the time, and use a handheld GPS to get the location of the collector (a one time measurement). Calculate the position of the sun and then just point to the sun, adjust every 5-10 minutes and sleep the rest of the time. The lag time could be calculated beforee it "went to sleep" by

This method will provide at least as much accuracy and since the system is not always searching for the best situation the driving motors will last longer.

Regarding RTC and algorithm.

This method will provide at least as much accuracy and since the system is not always searching for the best situation the driving motors will last longer.

It is because the light sensor system is always searching for the best situation, that makes it better in my opinion to relying on an RTC.

[soapbox] About light sensor better than RTC, no can't be bothered, It will be in another thread somewhere on the forum[/soapbox]

Tom....... :)

The sun is better at keeping time than any RTC - that's why we need leap-years.

If a position system using LDRs seems to be causing the motors to work too often the solution is very simple - just check the position every 15 or 30 minutes.

...R

Good Sirs,

A point of decorum.

if a poster says I have "X" and want to make it work. is it proper that we should offer that "Y" is better and not try to help the poster get his "X" to work ?

dave-in-nj: Good Sirs,

A point of decorum.

if a poster says I have "X" and want to make it work. is it proper that we should offer that "Y" is better and not try to help the poster get his "X" to work ?

It's reasonable to discuss alternative approaches. There is a significant proportion of questions where people ask for help making a difficult solution work and ignoring easier solutions, usually IMO because they aren't aware of the easier solutions.

wwbrown: There are equations that very accurately estimate the position of the sun based upon the tear, month, day, time and your location, by accurate I think the max error is under 0.5° probably better than a tracker will do.

With these well known equations why not put in an RTC so you know the time, and use a handheld GPS to get the location of the collector (a one time measurement). Calculate the position of the sun and then just point to the sun, adjust every 5-10 minutes and sleep the rest of the time. The lag time could be calculated beforee it "went to sleep" by

This method will provide at least as much accuracy and since the system is not always searching for the best situation the driving motors will last longer.

This is how the pros do it. BTW if you put your panel on a polar aligned axis, you only need one servo (and a seasonal tilt adjustment).

So if you have GPS, you have the time, right? The clock signal being broadcast by the satellite is atomic-based if I'm not mistaken, and will likely be way more accurate than your RTC. Each satellite has been calibrated to the same time, and all they do is transmit an ID and the time continuously... I think? Then the GPS receiver compares the time it took for each of the clock signals to come in and uses some trigonometry to determine your latitude and longitude. I'm probably oversimplifying, but that's at least how I thought I understood how they work.