DIY Outdoor Landscape Lighting

by JasonUMD77 in Circuits > Raspberry Pi

10184 Views, 62 Favorites, 0 Comments

DIY Outdoor Landscape Lighting

DSC_0026.JPG

I have had issues with landscape lighting companies since I purchased my first townhouse in 2003. The transformers are low powered with non-intuitive push button interfaces and cheap screens where wattage seems to be more precious than platinum. Unless you enter a really high price point, the lights are extremely poor quality with scarce-to-nonexistent replacement parts (spikes). The connectors are frustrating and finicky. I have been playing with Raspberry Pi's for a few years and thought it had to be a good basis for a lighting controller. I really wanted to roll my own solution and this became my Spring 2019 passion project for home improvement.

Supplies

Inspiration & Acknowledgement

Preliminary searches led me to two separate online instructions that I felt could be combined and updated to create what I was looking for.

~Colin Miles, aka onehourcleaner on Instructables, inspired me with this post. He explained the power supply wiring perfectly so I'm not going to rewrite his work, rather I'll add some updates.

~Matyscabreras on YouTube created a great video on DIY LED lights.

Methodology

Based on the inspirational posts my goals were as follows:

~Utilize a PC power supply which will power both the lights and a Raspberry Pi.

~Write custom Python code which would control turning the lights on and off.

~Utilize a web service to determine sunrise/sunset times as a basis for controlling the lights.

~Construct my own lights so that replacements can be easily produced.

~Publish solution for others to utilize/improve/enjoy.

Sunrise/Sunset Web Service

As mentioned in "Step 11: Improvements In-progress & Wrapping Up" of one of the inspirational posts, Colin mentions using Weather Underground by obtaining an API key. Unfortunately, WU's API has reached end of service. I did find another service called Sunrise Sunset that utilizes a simple REST API. You can form the appropriate URL incorporating your latitude and longitude coordinates in decimal degrees. When called, the API will return JSON with the sunrise and sunset at that location in UTC time.

An example URL and response is as follows:

URL

https://api.sunrise-sunset.org/json?lat=36.7201600...

Response

{
	"results":
	{
		"sunrise":"6:31:48 AM",
		"sunset":"5:32:25 PM",
		"solar_noon":"12:02:07 PM",
		"day_length":"11:00:37",
		"civil_twilight_begin":"6:05:35 AM",
		"civil_twilight_end":"5:58:39 PM",
		"nautical_twilight_begin":"5:35:23 AM",
		"nautical_twilight_end":"6:28:50 PM",
		"astronomical_twilight_begin":"5:05:23 AM",
		"astronomical_twilight_end":"6:58:50 PM"
	},
	"status":"OK"
}

When writing my Python code, I struggled a great deal in dealing with and converting between timezones. I believe my code is working as I intend. A good test will be when the clocks change for daylight savings time. In hindsight, a future improvement may be to set my Raspberry Pi to operate in UTC and perform no conversions at all. If I decide to do that, I will update these instructions.

Python Code

I added my Python code to the "OutdoorLighting" repository of my GitHub. I absolutely welcome input on my Python code. The README.md is as follows:

Python scripts used to automatically turn outdoor lighting on/off from a Raspberry Pi. Utilizes the Sunrise Sunset REST API to return times in JSON (https://sunrise-sunset.org/).

Uses the following packges:

python 3
pip3
python-requests
python-dateutil

Using the following cron to run this script at 1 am everyday and on system reboot (crontab -e):
0 1 * * * /home/pi/OutdoorLighting/OutdoorLighting.py
@reboot /home/pi/OutdoorLighting/OutdoorLighting.py

Controller Assembly

DSC_0007.JPG
DSC_0006.JPG
DSC_0008.JPG
e2d822f79c6074a96e22ccb02a4c97b8.png
DSC_0009.JPG
DSC_0006 (2).JPG
DSC_0008 (2).JPG
DSC_0010.JPG
DSC_0012.JPG

The photos are labeled with all the connections needed to operate the controller.

Light Construction

DSC_0002.JPG
DSC_0015.JPG
DSC_0017.JPG
DSC_0016.JPG
DSC_0018.JPG
DSC_0019.JPG
DSC_0020.JPG
DSC_0051.JPG
DSC_0001.JPG
DSC_0049.JPG
DSC_0050.JPG

After some trial and error, this is the light design I settle on which I'm pleased with. The photos are labeled with specific instructions.

Conclusion

DSC_0026.JPG
DSC_0024.JPG

This project was slightly challenging, sporadically frustrating, and very rewarding. I wasted some money during my personal R&D, but not much. I spent more than I needed to on the ATX power supply in order to offer future expand-ability. The plan is to run lighting completely around the house. The lights themselves turned out very modern and attractive. Some may prefer a tiered light and I'm sure a plug-and-play solution can be sourced on Amazon.