Hi, I'm trying to make a GPS based solar tracker and want to use the hour angle at sunrise to trigger the tracker. This is what I've got till now:
#include <Dusk2Dawn.h>
#include <Servo.h>
#include <DS1307RTC.h>
#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
Servo servo1; //controls altitude
int Mins=0,Lastmin=0;
int lon, lat, diff,i,r,s,y,m,d;
SoftwareSerial mySerial(3, 2);
Adafruit_GPS GPS(&mySerial);
//conversion of degrees and minutes to decimal degrees
double convertDegMinToDecDeg (float degMin)
{
double min = 0.0;
double decDeg = 0.0;
min = fmod((double)degMin, 100.0);
degMin = (int) ( degMin / 100 );
decDeg = degMin + ( min / 60 );
return decDeg;
}
void setup()
{
Serial.begin(115200);
GPS.begin(9600);
tmElements_t tm;// specific time from RTC is initialized
tm.Minute ;
tm.Hour ;
tm.Day ;
tm.Month ;
tm.Year ;
time_t s_date = makeTime(tm);
y = GPS.year;
m = GPS.month;
d = GPS.day;
lon = convertDegMinToDecDeg(GPS.longitude);
lat= convertDegMinToDecDeg(GPS.latitude);
float diff = 5.30;
//calculation of sunrise and sunset as per data from GPS
Dusk2Dawn place(lon, lat, diff);
int placeSunrise = place.sunrise(y, m, d, false);
int placeSunset = place.sunset(y, m , d, false);
char time1[6];
Dusk2Dawn::min2str(time1, placeSunrise);
Serial.println(time1);
char time2[6];
Dusk2Dawn::min2str(time2, placeSunset);
Serial.println(time2);
placeSunrise = r;
placeSunset = s;
servo1.attach(4);
servo1.write(180);
delay(500);
}
void loop()
{
tmElements_t tm;
for (i=r; i<=s ; i+=5)
{
if(RTC.read(tm))
{
//controlled movement of motor and panel
Mins = tm.Minute;
delay(500);
//9 am to 9:20 am
if(Mins==200) servo1.write(5);
if(Mins==220) servo1.write(10);
if(Mins==240) servo1.write(15);
if(Mins==260) servo1.write(20);
if(Mins==280) servo1.write(25);
if(Mins==300) servo1.write(30);
if(Mins==320) servo1.write(35);
if(Mins==340) servo1.write(40);
if(Mins==360) servo1.write(45);
if(Mins==380) servo1.write(50);
if(Mins==400) servo1.write(55);
if(Mins==420) servo1.write(60);
if(Mins==440) servo1.write(65);
if(Mins==460) servo1.write(70);
if(Mins==480) servo1.write(75);
if(Mins==500) servo1.write(80);
if(Mins==520) servo1.write(85);
if(Mins==540) servo1.write(90);
//3 am to 3:20 am
}
if(i=s)
{
servo1.write(0);//move back to initial position
}
}
}
The Dusk2Dawn library is the one found here
I'm trying to include the hourAngleSunrise function in my setup and assign it to 'hour',to use in the loop.
I checked the .h file and it shows hourAngleSunrise is in the private part of the class; would that affect being able to add it in?
Any suggestions on how I can go about this are appreciated.