DIY Smart Light With Raspberry Pi Zero




About: Hi, I am a student at university in Germany. I like developing projects related to new technologies and finding interesting ideas for new projects. Why not visit my site

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.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

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:

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 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: . 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.

Automation Contest 2017

Participated in the
Automation Contest 2017

Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    16 Discussions


    10 days ago

    Great work! i would realy love to build it, but i have only android devices and little to no programming ability, there is any way to get it work on a website?

    1 reply

    Reply 7 days ago

    Hi Icopetti,
    thanks for your interest in this project :). With some workarounds, it should be possible to get this working on a website so that Android users can alos control the light, but unfortunately I don't have the knowledge to do so myself.

    In case you're interested about this: The commands of controlling the lights can be found in the home directory inside a python file named For example:
    http://hostname(ip-address)/power/on will turn on the light. You have to add this url in the form of a button on a webpage to use it with a browser. Hope this helps :)


    Question 4 months ago

    Is there a GitHub repo with your code you could link to?

    1 answer

    Answer 4 months ago

    Hi DonaldB41.
    Thanks for your interest in this instructable :D
    At the time of publishing the instructable, I did not create a Github repo for this project. I did try to create a Github repo for this some months ago, but the installation would no longer work (on Raspbian Stretch), so I left it.
    It's a bit complicated to explain why, but to simplify, it's an incompatability between Raspbian Stretch and homebridge/avahi.
    That being said, you can still grab the python code from the OS-image-file, either by directly accessing the filesystem with Linux or using VNC after flashing and running the OS on a Raspberry Pi.
    Hope this helps :)


    4 months ago

    This is great. I found a similar project that used my home WiFi to control the unicorn pHat but it didn’t always work. I haven’t tested yours out yet but I will do later. When you connect your phone to the Pi, does this mean your phone is offline to the wider internet? I would like to be able to connect to control the light but also have my phone available to the internet.

    1 reply

    Reply 4 months ago

    Hi MrJoatmon, thanks for your interest in this project :)
    I'm glad you like the instructable. Do let me know if it still works as it has been a while since I published this intructable.
    By default, the OS-image is set to be an offline AP so connecting any device to it will make that device lose access to the www for as long as it's connected to the Raspberry Pi.
    But that is not a dead-end. If you want to be able to control the light with your phone and still have access to the www, you can do the following:
    * Get another Wifi-adater (ideally one for linux so no drivers have to be installed)
    * Connect the adapter to the Raspberry Pi and connect that Wi-Fi adapter to the network with internet acces (your router) via VNC/SSH.
    * Follow the instructions from the Raspberry Pi site (
    to set up the bridge (passing of data between 2 different Wifi adapters).

    If you then connect your phone to the Raspberry, you'll be able to access the www.
    Hope this helps :D


    Question 7 months ago on Step 4

    Hi there, this looks really great. I'm a little nervous about just flashing my Rasp Pi Zero with your disk image, then connecting it to my phone and then inside my network. I totally get you wanted to save everyone some time, and that's cool, but could you provide more information about what you're putting on this SD card image, and maybe provide more information about setting it up? Perhaps you followed some directions from somewhere else that you could just link to? Thank you!

    3 answers

    Answer 7 months ago

    Hi mkoistinen,
    thank You very much for your interest in this instructable and for your comment :)

    This image is based on Raspbian Stretch (upgraded from Jessie). It sets up the Raspberry as an AP (Access Point) and runs homebridge. With the plugin homebridge-better-http-rgb, it is possible to interface an rgb light (in this case the Pimoroni unicorn phat) via the Home app in iOS. The actual python script controlling the unicorn phat is an adaptation of Pimoroni‘s api for the mote (see here: (

    The functions from the unicorn api are nearly the same as the mote one, but there are two additional things which make this image file unique.

    1) With the Raspberry Pi being set up as an AP, it is not required to have a working network connection available since the Raspberry acts as a router. That being the case, you can take the light anywhere you like (hence the portability) and even use ssh or vnc. I‘ll update this instructables so that the login data for ssh and vnc is available.

    2) After Raspbian Stretch was released, I tried to set up homebridge on a fresh install several times but it failed each time (during pairing particularly). It seems as though this is quite common as a lot of other homebridge users have complained about the same issues with Raspbian Stretch. But this image is already fully set up and I can confirm it works.

    Unless you add a second wifi adapter, there is absolutely no exchange of data with the net (due to the AP mode). So you don‘t need to feel so nervous about flashing :)


    Reply 7 months ago

    Awesome and thanks for the super fast reply! Especially since this is a two year-old post!


    Reply 7 months ago

    You're welcome :)
    Although this instructable is 2 years old, it won't be outdated so easily as it contains a fully set-up OS file (.img) and therefore has (almost) no dependencies.


    7 months ago

    From the author
    It's been a while since I first launched this project so I wanted to share a few words with the more recent viewers. Usually, older instructrions tend not to work anymore as they are often outdated, but this instructable is a bit special. Since the core of this instructable is a full (OS) image file intended to be flashed on a microSD card, it does not really depend on other software and therefore does not get outdated easily. So you shouldn't have to worry about any outdated programms. But iff you encounter any bugs, feel free to report them to me.


    2 years ago

    What i need to edit to change the WiFi name? Btw nice project ;)

    2 replies

    Reply 2 years ago

    Hi MrD32,

    thanks for the compliment :)

    To change the Wifi name, simply open up the Terminal, enter this command:

    sudo leafpad /etc/hostapd/hostapd.conf

    Then navigate to the third line (ssid=abc) and replace 'abc' with your desired Wifi name.


    Reply 2 years ago

    Thanks a lot for the compliment :)