Dual Axis Solar Tracker

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));

  
}

Most people simply command the tracker to orient toward the desired AZ and EL positions at suitable time intervals. The tracker must be set up and properly aligned at your geographic location.

Hi Thank you.
Sorry probably not explained my problem well. "AZ" for instance is printed to the serial monitor at 306 degrees for instance. I need to be able to use that number "306" to compare to the angle of my tracker.
Thanks
Mick

You haven't explained how your tracker is controlled.

In any case, instead of this command to print the desired azimuth angle:

  Serial.print(pos.azimuth, numDigits);

You might use a command something like this to set the tracker azimuth angle:

  set_tracker_azimuth(pos.azimuth);

Hi Thank You
The program will look at the current Azimuth angle and if the tracker angle is less move until it is at the same position. I am using linear actuators and there would be a delay of around 15minutes between cycles.
I have tried using an if statement using (pos.azimuth) and get an error.
EG just for testing . `if (pos.azimuth)>100) {do something}

Thanks
Mick

Sorry, not enough information.

That works thank you.
Appreciate your time.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.