Timelord library question

Over the past few years I’ve been playing around with Arduino and aquarium related projects. The Photon will be my first IoT. I was wondering if I could still use this library to calculate sunrise/sunset times for a certain geographical location using longitude and latitude for start and stop times.

Thanks for any info.

That is a nice simple library. It is imported into the Particle cloud. Search for it as TimeLord@0.0.1. Let me know if you have any problems.

$ particle serial monitor --follow
Polling for available serial device...
Opening serial monitor for com port: "/dev/cu.usbmodem1421"
Serial monitor opened successfully:
Serial connection closed.  Attempting to reconnect...
Serial monitor opened successfully:
Sunrise: 5:20
Sunset: 18:47
1 Like

Thank you so much for the help.

I am try to use this library…I have at least, for the moment, one question. In the example SunriseSunset.ino I don’t understand the format in the statement:
byte today[] = { 0, 0, 12, 27, 10, 2012 }; // store today’s date (at noon) in an array for TimeLord to use.

it won’t compile as is , since 2012 is not byte sized. what are the array locations meanings?

Thanks

This statement defines a byte array with (originally) unknown extent but then initialises it with the values given in the curly braces hence setting its extent to six bytes - but you are right 2012 won’t fit into byte, so either change the data type (e.g uint16_t)or use 12 instead of 2012.

Here are field indices as defined here https://build.particle.io/libs/TimeLord/0.0.1/tab/TimeLord.h

#define tl_second 0
#define tl_minute 1
#define tl_hour 2
#define tl_day 3
#define tl_month 4
#define tl_year 5

Thanks much.

I managed to get SunriseSunset.ino to function using a 2 digit year of 19 and making the appropriate changes to the date to 2-22-19. It did return the sunset time within a few minutes of what I found on a website. This is close enough for my application.

I do have two questions though:

I am really puzzled over the comment in this statement:
tardis.TimeZone(-5 * 60); // tell TimeLord what timezone your RTC is synchronized to. You can ignore DST
// as long as the RTC never changes back and forth between DST and non-DST
(the -5 is my local time zone)
Any help in clarifying the meaning would be appreciated!

Thanks in advance

David G.

I guess I have that question sorted out:

If the RTC does set DST then you must also change to a DST time zone in this statement…simple.

David G.

1 Like