Arduino Temperature controlled LED strip lighting for runners

Problem:  Runners need to know how to dress before heading out.  The longer the run, the more important it becomes.

I have long enjoyed the inexpensive 5050 LED strip lights attached to my deck for simple decorative lighting.  Since playing with microcontrollers, I decided to make it more purposeful.

This details the steps required to have your own NON-CONNECTED but functional temperature sensitive lighting system.  On a basic level, it turns on at predefined intervals such as with an LDR or even better, the power supply plugged into a commercial phototimer relay switch.

The advantage of an astronomical clock over an LDR, is that it can turn on before the conditions change.  Sure an LDR can turn on the light when it’s dark, but what if you want the lights to come on before sunrise or turn off for a while after sunset so you can see it better?

But that just wasn’t good enough.  Being a perpetual tinkerer, I added a RTC chip (DS1307) to the board, MOSFETs to control the LED strip and the latest addition is a sunset-sunrise timer courtesy of the deprecated but functional TimeLord library.

N.B. : It’s necessary to modify the cpp and .h files to include math, not “Math.h” which is how it’s written in the repository I used.

Original Data from the timelord libary:

Sunrise: 5:20
Sunset: 18:47

 

Modified Data with corrected GPS position:

Sunrise: 7:7
Sunset: 19:39

Note that DST throws it off from the RTC sync from a PC so, you’ll have to adjust the time zone accordingly.

This Jives well with Web data:

Sunrise Today: 7:09 am 85° East

Sunset Today: 7:38 pm 275° West

I’ll post the code eventually but I wanted to give a quick look at the approach, heavily borrowing from this project.

I owe a debt of gratitude for a number of coding style points gleaned from this project, more than a few of which involve the “if DEBUG == 1” compiler exclusion code that really shrinks the size of the program down when not in debug mode.  Being a noob, I had not used this before but found it highly effective.

Another huge advance was correct implementation of the <DS1307RTC.h> and <Time.h> libraries for periodic sync of arduino time and RTC time.  I was originally using Adafruits tutorial but found this library easier to use.

The absence of human readable times for sunrise and sunset is conspicuous and these are easily included but not relevant for the code to do the counting that it needs to do.

 

************************************** 
SYS TIME = 16:02:30 
RTC TIME = 16:02:31 Date = 2017/04/01 
Minutes into the current Day: 962 
SunriseMin: 424 
SunsetMin: 1181 
Min of daylight today: 757 
Min until Sunset: 219 
% of daylight left: 28 
**************************************

 

I’ll continue this more in another post.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s