Sunrise and Sunset

Hi i am building a automatet ligth for outside. I have tried different librarys as TimeLord, but i found these to be not so accurate. UP to 1 hour wrong. I have set the latitude and longitude and timezone to +1 also tried just 1. This is in norway. Anybody have any tips to get this working? Another library / code. I am using an RTC to get time for the UNO.

Regards

You must be doing something wrong. I've tried several sunrise/set programs, and they are all within one minute or two of being correct. How about "daylight savings time"?

Here is an Arduino sun position calculator that is accurate to a few arc minutes.

Thanks. i will look into this link. As an example. for today i get these values:

Sunrise: 07:14
Sunset: 20:10

But according to: timeanddate.com it should be:
Sunrise: 07:02
Sunset: 19:53

With These settings:

Date 27/03/2016
LONGITUDE = -9.59;
LATITUDE = 59.25;
TIMEZONE = 1;

if someone can test and see if they get the same values or if am doing something wrong.

if someone can test and see if they get the same values

Post the code, using code tags.

It is very unlikely that your longitude is -9.59 degrees (West of the Prime Meridian), which is somewhere in the ocean. Oslo would be about 10.5 degrees.

#include "TimeLord.h"

const int PROGMEM TIMEZONE = 1;
const double PROGMEM LONGITUDE = -9.59;
const double PROGMEM LATITUDE = 59.25;

TimeLord myLord;

void setup()
{
Serial.begin(9600);
myLord.TimeZone(TIMEZONE * 60);
myLord.Position(LATITUDE, LONGITUDE);
}

void loop()
{

byte day[] = {0, 0, 0, 27, 3, 2016};

myLord.SunRise(day);
Serial.print("Sunrise: ");
Serial.print((int) day[tl_hour]);
Serial.print(":");
Serial.println((int) day[tl_minute]);

myLord.SunSet(day);
Serial.print("Sunset: ");
Serial.print((int) day[tl_hour]);
Serial.print(":");
Serial.println((int) day[tl_minute]);

delay(5000);
}

const double PROGMEM LONGITUDE = -9.59;Try 9.59

WOW. now its accurate to within a couple of minutes :slight_smile: ( if i add 1 Hour sinse we entered DST last nigth )

I just have to ask. Why does this happend? Becuase according to Google the GPS coordinates here was with a minus (-) in front of LONGITUDE

There is no universal convention for the sign of longitude, but Google Maps in the U.S. uses positive for east longitude, and so does that program.