solar tracker using gps and sun position

hi , i'm trying to make a solar tracking system using gps [GY-NEO6MV2] and Astronomical equations to get (Latitude , Longitude year ,month ,day, local hour, minute, second ) from the {gps} and use these data in the Astronomical equations.
The problem is that i'm VERY new to arduino , so i'm looking for help , because i'm facing many problems.

first :
I'm trying to change the time zone to that of my location , and i've looked everywhere for an answer
but i couldn't find the solution.

Here is the GPS code :

#include <TinyGPS++.h>
#include <SoftwareSerial.h>

static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

void setup(){
 Serial.begin(9600);
 ss.begin(GPSBaud);
}

void loop(){
 while (ss.available() > 0){
   gps.encode(ss.read());
   if (gps.location.isUpdated()){
     // Latitude in degrees (double)
     Serial.print("Latitude= "); 
     Serial.print(gps.location.lat(), 6);      
     // Longitude in degrees (double)
     Serial.print(" Longitude= "); 
     Serial.println(gps.location.lng(), 6); 
      
     // Raw latitude in whole degrees
     Serial.print("Raw latitude = "); 
     Serial.print(gps.location.rawLat().negative ? "-" : "+");
     Serial.println(gps.location.rawLat().deg); 
     // ... and billionths (u16/u32)
     Serial.println(gps.location.rawLat().billionths);
     
     // Raw longitude in whole degrees
     Serial.print("Raw longitude = "); 
     Serial.print(gps.location.rawLng().negative ? "-" : "+");
     Serial.println(gps.location.rawLng().deg); 
     // ... and billionths (u16/u32)
     Serial.println(gps.location.rawLng().billionths);

     // Raw date in DDMMYY format (u32)
     Serial.print("Raw date DDMMYY = ");
     Serial.println(gps.date.value()); 

     // Year (2000+) (u16)
     Serial.print("Year = "); 
     Serial.println(gps.date.year()); 
     // Month (1-12) (u8)
     Serial.print("Month = "); 
     Serial.println(gps.date.month()); 
     // Day (1-31) (u8)
     Serial.print("Day = "); 
     Serial.println(gps.date.day()); 

     // Raw time in HHMMSSCC format (u32)
     Serial.print("Raw time in HHMMSSCC = "); 
     Serial.println(gps.time.value()); 

     Serial.print("Hour = "); 
     Serial.println(gps.time.hour()); 
     Serial.print("Minute = "); 
     Serial.println(gps.time.minute()); 
     Serial.print("Second = "); 
     Serial.println(gps.time.second()); 
   }
 }
}

second :
I'm trying to use the data that i get from the gps in the sun position equations , but i couldn't find a prob way to do it.

Here is the sun position code :

#define DEG_TO_RAD 0.01745329
#define PI 3.141592654
#define TWOPI 6.28318531
void setup() {
int hour,minute=0,second=0,month=6,day=21,year,zone=5;
float Lon=-75*DEG_TO_RAD, Lat=40*DEG_TO_RAD;
float T,JD_frac,L0,M,e,C,L_true,f,R,GrHrAngle,Obl,RA,Decl,HrAngle,elev,azimuth;
long JD_whole,JDx;
Serial.begin(9600);
Serial.print("Longitude and latitude "); Serial.print(Lon/DEG_TO_RAD,3);
Serial.print(" "); Serial.println(Lat/DEG_TO_RAD,3);
Serial.println("year,month,day,local hour,minute,second,elevation,azimuth");
for (hour=10; hour<=24; hour++) {
JD_whole=JulianDate(year,month,day);
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));
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=PI+atan2(sin(HrAngle),cos(HrAngle)*sin(Lat)-tan(Decl)*cos(Lat));
Serial.print(year); Serial.print(","); Serial.print(month);
Serial.print(","); Serial.print(day); Serial.print(", ");
Serial.print(hour-zone); Serial.print(",");
Serial.print(minute); Serial.print(","); Serial.print(second);
Serial.print(","); Serial.print(elev/DEG_TO_RAD,3);
Serial.print(","); Serial.print(azimuth/DEG_TO_RAD,3);
Serial.println();
}
}
void loop() {}
long JulianDate(int year, int month, int day) {
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;
}

Thanks in advance

Please edit your post to add code tags, as described in How to use this forum.

I suggest to use the excellent Solar Position library for Arduino. It works very well.

Thanks

Read "How To Use This Forum"

in particular, 7. If you are posting code or error messages, use "code" tags

This is what happens when you do not

if you have a module that is not working, do not say "A GPS" or "the fingerprint sensor". Show us a link to the particular sensor, and a link to the datasheet if available

^^ that was generic advice that gets reposted about a dozen times a week

search term: W8BH clock. it has a design flaw, it is not as accurate as he claims it is. in the second PDF he explains why GPS clocks are always a second off. he also shows how to convert GPS UTC time to local time, deal with spring forward and fall back

I have an improved version of the clock, and a solar tracker based on that clock, but neither one works right at the moment.

find these libraries:

EPHEMERIS
TIME

NON FUNCTIONAL SOLAR TRACKER BASED ON EPHEMERIS AND TIME

This absolutely requires a Mega. It's too big for anything with less memory

/*
 * derived from ephemeris_full.ino
 * 
 * Copyright (c) 2017 by Sebastien MARCHAND (Web:www.marscaper.com, Email:sebastien@marscaper.com)
 */
    
#include <Ephemeris.h>  // https://github.com/MarScaper/ephemeris
#include <TimeLib.h>
#include <DS1307RTC.h>

void printDateAndTime(int day, int month, int year, int hour, int minute, int second ) ////////////////////////////////////////////////////
{
  Serial.print(day);    Serial.print("/"); Serial.print(month); Serial.print("/");
  Serial.print(year);   Serial.print(" "); Serial.print(hour);  Serial.print(":");
  Serial.print(minute); Serial.print(":"); Serial.print(second);
} /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void equatorialCoordinatesToString(EquatorialCoordinates coord, char raCoord[14] , char decCoord[14])
{
  int raHour,raMinute;
  float raSecond;
  Ephemeris::floatingHoursToHoursMinutesSeconds(coord.ra, &raHour, &raMinute, &raSecond);
    
  sprintf(raCoord," %02dh%02dm%02ds.%02d",raHour,raMinute,(int)raSecond,(int)round(((float)(raSecond-(int)raSecond)*pow(10,2))));
    
  int decDegree,decMinute;
  float decSecond;
  Ephemeris::floatingDegreesToDegreesMinutesSeconds(coord.dec, &decDegree, &decMinute, &decSecond);
    
  if(decDegree<0)
  {
    sprintf(decCoord,"%02dd%02d'%02d\".%02d",(int)decDegree,decMinute,(int)decSecond,(int)round(((float)(decSecond-(int)decSecond)*pow(10,2))));
  }
  else
  {
    sprintf(decCoord," %02dd%02d'%02d\".%02d",(int)decDegree,decMinute,(int)decSecond,(int)round(((float)(decSecond-(int)decSecond)*pow(10,2))));
  }
}

void printEquatorialCoordinates(EquatorialCoordinates coord) ////////////////////////////////////////////////////////////////////////////
{
  if( isnan(coord.ra) ||  isnan(coord.dec))
  {
    // Do not work for Earth of course...
    Serial.println("R.A: -");
    Serial.println("Dec: -");
        
    return;
  } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
  char raCoord[14];
  char decCoord[14];
  equatorialCoordinatesToString(coord,raCoord,decCoord);

  Serial.print(" R.A: ");
  Serial.println(raCoord);

  Serial.print(" Dec: ");
  Serial.println(decCoord);

  return;
} ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void printHorizontalCoordinates(HorizontalCoordinates coord) /////////////////////////////////////////////////////////////////////////////
{
  if( isnan(coord.azi) ||  isnan(coord.alt))
  {
    // Do not work for Earth of course...
    Serial.println("  Az: -");
    Serial.println("  El: -");
        
    return;
  }

  Serial.print("  Az:  ");
  Serial.print(coord.azi,2);
  Serial.println("d");

  Serial.print("  El:  ");
  Serial.print(coord.alt,2);
  Serial.println("d");
} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void printSolarSystemObjects(int day, int month, int year, int hour, int minute, int second) ///////////////////////////////////////////////
{
  Serial.println("-----------------------------");
  printPlanet("Sun",          Sun,     day, month, year, hour, minute, second); // do not remove the spaces
}

void printPlanet( const char *solarSystemObjectName, SolarSystemObjectIndex index, int day, int month, int year, int hour, int minute, int second )
{
  SolarSystemObject solarSystemObject = Ephemeris::solarSystemObjectAtDateAndTime(index, day, month, year, hour, minute, second);
  
  Serial.println(solarSystemObjectName);
  printEquatorialCoordinates(solarSystemObject.equaCoordinates);
  printHorizontalCoordinates(solarSystemObject.horiCoordinates);

  if( solarSystemObject.riseAndSetState == RiseAndSetOk )
  {
    int hour,minute;
    float second;
    
    Ephemeris::floatingHoursToHoursMinutesSeconds(solarSystemObject.rise, &hour, &minute, &second);
    Serial.print("Rise: ");
    Serial.print(hour);
    Serial.print(":");
    Serial.print(minute);
    Serial.print(":");
    Serial.print(second);
    Serial.println(" UTC");

    Ephemeris::floatingHoursToHoursMinutesSeconds(solarSystemObject.set, &hour, &minute, &second);
    Serial.print(" Set:  ");
    Serial.print(hour);
    Serial.print(":");
    Serial.print(minute);
    Serial.print(":");
    Serial.print(second);
    Serial.println(" UTC");
  }
}

void setup() 
{
  Serial.begin(9600);
  // Set location on earth for horizontal coordinates transformations
  Ephemeris::setLocationOnEarth( 35,06,12,  // Lat: 35°06'12"
                               -106,34,06); // Lon: -106°34'06"

  // West is negative and East is positive
  Ephemeris::flipLongitude(false);
    
  // Set altitude to improve rise and set precision
  Ephemeris::setAltitude(1395); //elevation in meters
                                
  // Choose a date and time UTC Time not local /////////////////////////////////////////////////////////////////////////////////////////
  int day=6,month=13,year=2019,hour=15,minute=45,second=0;
  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  
  // Compute and print solar system objects
  Serial.print("SolarTracker: (");
  printDateAndTime(day,month,year,hour,minute,second);
  Serial.println(")");
  printSolarSystemObjects(day, month, year, hour, minute, second);
}

void loop() {}

I can't get the time elements from the clock to work in the solar tracker. if you manually enter the time in the solar tracker and compare it to

it works exactly right.

anent the clock: as noted above , W8BH shows why GPS clocks are always a second late. bottom line: the pulse occurs, then the info related to the moment of the pulse is transmitted. you do not get "at the pulse the time will be..." you get "at the pulse the time was...." You need to run an accurate RTC, and use the leading edge of the pulse and an interrupt to set the RTC to GPS time plus one second, then use RTC as syncProvider

my clock is in the process of being hard mounted. it got to the point where any movement on the workbench popped a pin out of a header. when that's done I can get back to work on these projects.

Thank you (Geek Emeritus) that was very helpful