Hi All
Can anyone please help me get started with a program for a dual axis solar tracker. I have used the below code from the SolarPosition library and the Azimuth angle, Elevation and RTC are working perfectly.
I need to compare the "AZ" , "EL" position against my solar tracker position. So I can tell it to move or not.
How do I reference these two values inside a "if statement"
Appreciate any pointers.
// solarTimeRTC
#include <SolarPosition.h>
#include <DS1307RTC.h>
// number of decimal digits to print
const uint8_t digits = 3;
// some test positions:
SolarPosition Home(42.898551, -12.539774); // Home
void setup()
{
Serial.begin(9600);
// set the Time service as the time provider
SolarPosition::setTimeProvider(RTC.get);
}
void loop()
{
// now test the real time methods:
//
printTime(RTC.get());
Serial.print(F("Home:\t"));
printSolarPosition(Home.getSolarPosition(), digits);
Serial.println();
delay(15000);
}
// Print a solar position to serial
//
void printSolarPosition(SolarPosition_t pos, int numDigits)
{
Serial.print(F("el: "));
Serial.print(pos.elevation, numDigits);
Serial.print(F(" deg\t"));
Serial.print(F("az: "));
Serial.print(pos.azimuth, numDigits);
Serial.println(F(" deg"));
}
// Print a time to serial
//
void printTime(time_t t)
{
tmElements_t someTime;
breakTime(t, someTime);
Serial.print(someTime.Hour);
Serial.print(F(":"));
Serial.print(someTime.Minute);
Serial.print(F(":"));
Serial.print(someTime.Second);
Serial.print(F(" UTC on "));
Serial.print(dayStr(someTime.Wday));
Serial.print(F(", "));
Serial.print(monthStr(someTime.Month));
Serial.print(F(" "));
Serial.print(someTime.Day);
Serial.print(F(", "));
Serial.println(tmYearToCalendar(someTime.Year));
}