Introduction: DIY Smart Light With Raspberry Pi Zero
Smart lights are becoming more and more popular. Such lights are usually LED lights that can be controlled over WiFi or Bluetooth. The colours, saturation and brightness can be changed using a smartphone. One thing I realised is, that often smart lights are pretty expensive and are hard to set up. While WiFi controlled lights rely on a working internet connection, Bluetooth smart lights require a close distance to the device you want to control. Often a certain app or a website has to be opened to control smart lights, which can be a bit of a hassle.
My aim was to make a WiFi-controlled smart light that would be cheaper than most smart lights, yet have full functionality (control of brightness, saturation and colour) . To make the Light more user-friendly and easy to set up, I've thought about a way to connect and control the light without having to open a website or downloading any (additional) app.
Unfortunately, the only option to make such a smart light is to rely on Apple devices only since Apple has a default 'Home' App which allows users to control certain smart devices in their home. So far, I've looked for a solution to get this up and running on Android too, but I've not come to any working solution. Sorry, Android fans, maybe next time...
My smart light is made up of two components, the Raspberry Pi Zero W and the Unicorn phat from Pimoroni. The pill-like 'case' is actually a 3D-printed cover and diffusor. The Raspberry Pi Zero W will act as an wifi network that users can connect to using a password. Anyone connected to that network can control the light using the 'Home' App. To keep things simple, all programs are set to run automatically on the Pi Zero W as soon as power is supplied.
If you have a Raspberry Pi Zero W and a unicorn phat lying around somewhere and if you are an Apple user, why not take this opportunity to make yourself a low-cost, yet fully functional smart light?
An unusual but interesting feature of this light is that you can take it anywhere you like and still use it with your iPhone. Due to it's portability, it makes it ideal as a portable companion on your journeys.
Step 1: What's Needed?
Access to a laptop or pc
A Raspberry Pi Zero W
Pimoroni's unicorn phat
An mirco SD card (min 8GB) for the operating system
An micro SD to SD card adapter or a USB with a micro sd card slot
An micro USB cable to power the Zero W
Access to a 3D printer for the case / diffusor. If you don't have one, you may contact a 3D printing service to print out and send you the 3D printed parts.
Transparent printing material. Anything works as long as light can travel through. I used transparent PLA.
An soldering iron and some solder
An 20x2 male header for the Pi Zero
Step 2: Complete Setup
Instead of writing about 50 steps or more to set this project up on your Raspberry Pi zero w, I chose to simply publish the image file instead, which needs to be burnt on a blank micro SD card. The image file in it's compressed state is about 0,9 GB. You don't have to actually unzip the file if you follow the instruction below. Here's the link to the image file:
The image has be burnt on a blank SD card (min. 8GB). To do so, first format the micro SD card using the software 'SDFormatter' (can be downloaded from https://www.sdcard.org/downloads/formatter_4/). After plugging your micro SD card in, select options and activate 'Format-Size-Adjustment'. After formatting, the image can be burnt on the micro sd card. I personally prefer using Etcher to burn images, since it's simple to use and doesn't require you to unzip the image files. Etcher can be downloaded from here: https://www.sdcard.org/downloads/formatter_4/inde... . After selecting the drive with your micro SD card on etcher, select to the PiLight image and click on flash. When the process is complete, the micro SD card is set up.
Now, your soldering skills are required to make the unicorn phat work. Solder the male header to the Raspberry pi. The longer side of the pins should be facing upwards. Then, solder the female header to the unicorn phat. The longer side of the header should be facing downwards. Plug the Unicorn phat to the Raspberry. If you need some extra tips regarding the soldering, just follow this guide:
At this stage, you can download these 2 PiLight.stl files and print them out with your 3D printer using an transparent printing material. I used 20% infill since this is enough. Here's the link to the 2 files:
Step 3: Testing the Light on Your IOS Device
Now that the micro SD card is set up, plug the micro SD card in the slot on the pi zero w. Power the raspberry with the micro USB cable. After about 2 minutes, you should be able to see 'PiLight' as a new network. Try connecting to it using any Apple device. The default password for the network is 'password'. You should be connected to be wifi from the raspberry pi, but internet should not be available. If the network 'kicks' you out, it just means that you should wait a minute or two since the system is still loading.
When you are finally connected, open the 'Home' App or install it if you don't have it anymore. Alternatively, you can also use 'Hesperus', which does the same job. Then, give your house a name (maybe 'home') and try adding a device. You should be able to see a device called 'homebridge'. Tap on 'homebridge' and wait for it to connect. You will be prompted to enter a 6-digit pin. Use this pin to connect:
You have now set up everything and can move on to test the light.
To do so, click on the PiLight Icon in the Home app. Your smart light should light up. Try out all options to change the brightness, colour and power.
Step 4: Going Further
Now that your smart lamp is working and has been tested, you can automate it as well. The only prerequisite is that your phone should be connected to the smart lamp over WiFi. To use this feature, you have to get the 'Hesperus' App from App Store.
You could set up the lamp as a reminder for a specific time. I use mine as an alarm or rather wake-up-light. But you could make it change colours at specific times like red in the morning, orange at sunrise and blue when it's time to get up.
I'd love to see if someone else has made this as well by clicking 'I made it' and posting picturest. On the other hand, if there is something you think is lacking or could be improved, I'm ready to hear it. Just post the issue in the comment box and I'll help.