-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
#include <sunMoon.h>
#include <Time.h>
#include <TimeLib.h>
#define OUR_latitude 22.5726723 // Moscow cordinates
#define OUR_longtitude 88.3638815
#define OUR_timezone 330 // localtime with UTC difference in minutes
sunMoon sm;
void setup() {
tmElements_t tm; // specific time
tm.Second = 0;
tm.Minute = 12;
tm.Hour = 12;
tm.Day = 2;
tm.Month = 2;
tm.Year = 2021 - 1970;
time_t s_date = makeTime(tm);
Serial.begin(9600);
sm.init(OUR_timezone, OUR_latitude, OUR_longtitude);
time_t sRise = sm.sunRise(s_date);
time_t sSet = sm.sunSet(s_date);
Serial.print("Specific date sunrise and sunset was: ");
printDate(sRise); Serial.print("; ");
printDate(sSet); Serial.println("");
}
void loop() {
// put your main code here, to run repeatedly:
}
void printDate(time_t date) {
char buff[20];
// sprintf(buff, "%2d-%02d-%4d %02d:%02d:%02d",
// day(date), month(date), year(date), hour(date), minute(date), second(date));
sprintf(buff, "%02d:%02d:%02d",
hour(date), minute(date), second(date));
Serial.print(buff);
}
for
Kolkata, West Bengal, 700 073, India
Latitude: 22.5726723
Longitude: 88.3638815
Time zone: 330 (5:30)
According to https://sunrise-sunset.org/search?location=kolkata
Sunrise time:
6:14:56 AM
Sunset time:
5:25:34 PM
Getting Output
Specific date sunrise and sunset was: 06:15:36; 17:25:13
Any help will be `appreciated
Metadata
Metadata
Assignees
Labels
No labels