Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong Result #9

Open
Prabindas001 opened this issue Feb 2, 2021 · 2 comments
Open

Wrong Result #9

Prabindas001 opened this issue Feb 2, 2021 · 2 comments

Comments

@Prabindas001
Copy link

Prabindas001 commented Feb 2, 2021

#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

@sfrwmaker
Copy link
Owner

Perhaps, the coordinates are wrong.
https://en.wikipedia.org/wiki/All_India_Institute_of_Hygiene_and_Public_Health
22.5761885°N 88.3586926°E

@ulegan
Copy link

ulegan commented Feb 16, 2021

The exact times depend on a lot of things.
A common definition is when the sun is 10 arc-minutes below the horizon. This is what this library calculates.
But the sun is not a single point that is above or below the horizon.
It appears as a disc and the sun appears even larger near the horizon.
Height above sealevel makes also a difference.
It takes about two minutes from the first light until you can see the whole disc.
So when is the exact time? I think it doesn't really make sense to tell it to the exact second.
I found a german page that even considers the temperature:
https://www.arndt-bruenner.de/scripts/sonnenaufunduntergaenge.htm
Btw. if you use the API:
https://api.sunrise-sunset.org/json?lat=22.5726723&lng=88.3638815&date=2021-02-02
you get a different value...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants