Reactive Pixel Lamps

6,484

124

17

Introduction: Reactive Pixel Lamps

About: Mechanical Design Engineer

This Instructable details how to make a set of smart (wifi controlled) LED lamps. I created these pixel lamps as a way of creating ambient lighting and immersive gaming or film environments! Each pixel lamp is wifi connected and has the ability to react to the images being shown on the screen of your PC or TV as well as as being able to be controlled as part of a smart home!

I wanted to create the lamps to look like small pixels from an 8-bit style game so I opted for the cube style and made sure they were as cheap as possible so that many can be scattered around a room. Thanks to the wifi connectivity you only need a usb power source so theres no need to trail wires around your space.

In this Instructable I will walk you through how I created these lamps and give you all the files you need to recreate them yourselves! If you find anything that is unclear please let me know in the comments section.

Please note:

  • This project doesn't assume any prior knowledge of electronics or programming but a working understanding of your 3D printer and how to solder is useful to use these tools effectively and safely.
  • There are several risks that may be present when following this instructable from the 3D printer, soldering iron, hand tools, and glues. Please ensure you are working safely at all times.

Supplies

Electronics:

  • Soldering Iron
  • Solder
  • Fume Extractor
  • Snips
  • Breadboard for prototyping

3D Printing:

  • A 3D Printer (Or Access to one)
  • Material (I used PLA)

Server:

  • Raspberry Pi
  • Pi Power supply
  • SD Card for the Pi

Parts:

Step 1: CAD and 3D Printing

Before setting out on any practical work I like to have a good plan of what I am going to make. The best way to do this is by creating a 3D model in your favourite CAD software so that you can check that everything fits and you can play around with the design before you commit to anything.

The lamp is designed as two parts: A white cube shaped diffuser and a black base that holds the electronics in place.

Originally I set out to 3D print the diffuser in white plastic but I found that the diffusion was uneven and often caused refraction which affected the colour coming from the lamp. I was able to find a cheap LED night light on Aliexpress that had a white cube shape. Once they arrived I found I could easily unscrew the base and remove the diffuser allowing me to use my own electronics. I recreated the cube in CAD and adjusted my base to fit.

The base of the lamp was designed to fit the electronics in place. I found a model of the Wemos D1 on grabCAD and was able to export my PCB to a 3D model from my PCB software. This let me check that the LED was properly positioned and everything fit inside the diffusers I had bought. Since the WemoD1 doesn't have any mounting holes I chose to leave the pocket open so that I could fix the board down with some hot glue. That means I can avoid any complex mounting features which require tight tolerances making these bases printable on almost any printer.

While I didn’t use TinkerCAD for my design I have uploaded it and embedded it below so you can view it here in the intractable.

I have made available the STL file for the base of the pixel on thingiverse here: https://www.thingiverse.com/thing:4566672 and attached it to this step.

Hopefully these two filetypes will make it possible for you to print your own base piece and also for those of you who want to edit it to do so.

Step 2: Breadboard Model

The first stage of designing the circuit required to drive the LED was to build it onto a breadboard. The breadboard model allowed me to prove out the design in a way that was easily changeable and non-permeant.

I chose to use a 5 mm Common Anode RGB LED as the light source and a Wemos D1 to control it. The D1 is a great board for projects that need to fit in a small space and even includes wifi so that the lights can be commanded wirelessly. Initially I tried to drive the LED directly from the Wemos D1 digital pins but this didn’t work since the D1 wasn’t capable of fully turning off the LED. I instead opted to use a NPN transistor to drive each of the red, green, and blue channels which gave much better control. Each of the RGB channels has a 340 ohm resistor in series to protect the LED. It is important to use a separate resistor for each channel otherwise the brightness will be uneven. Typically a blue LED will require a higher resistance to match the brightness of the other LEDs but for simplicity I chose to use the same value and then adjust the brightness in software.

I have included a diagram of the breadboard (created in Fritzing) as its a bit easier to understand than the mess of jumper wires!

Once the breadboard was working it was time to make the circuit more permanent!

Step 3: PCBs

Once I had reached a final circuit design I decided to have it printed on a PCB and assembled on an automated SMT assembly line instead of trying to build it onto strip board. The PCB gives me access to smaller components (such as surface mounted resistors and transistors) and allows me to package the custom electronics in a neater way. The other key benefit is that the automated assembly means that its easy to make larger volumes of PCBs should I ever decide to make more!

The first stage was to translate the schematic into the PCB design software. I choose to use Diptrace as its a package I am familiar with and the pricing structure for hobbyists is very reasonable! Once I have a schematic I can convert it into a PCB. I opted to design the PCB as a “shield” type design so that it can sit over the top of the Wemos D1 in a really compact way. I also avoided adding a copper pour to the board to hopefully avoid blocking any of the wifi signal from the Wemos board.

Instead of using a standard LED footprint I chose to use 4 plated through holes spread out in a square so that the LED could be installed a bit like a pyramid giving it a rigid raised height perfect to put it in the centre of the diffuser.

I chose to use JLC PCB to fabricate the boards and complete assembly as they offered a competitive price and could handle both the board fabrication and assembly while also supplying the required parts. I kept all of the components on one side of the board and used a green solder mask as that is a constraint of the automated SMD assembly process. I also had to select components from the standard library of parts (although the library contains 30,000+ parts so wasn’t much of a limitation for the simple parts I needed!)

The schematics, GERBERS, and pick and place files can all be downloaded from this repo:

https://github.com/EdwardChamberlain/Pixel-Lamps/t...

Step 4: DIY Hue Server

To enable centralised control of the lights we will require a server to coordinate them. Since we will be using the Philips Hue framework we can make use of the DIYHue project which provides software to create an imitation hue bridge. We can then connect this hub to a large range of devices. Fortunately the DIY Hue server software can be run on almost any hardware from raspberry pi, to mac, or linux.

In this case I will be running DIY Hue on a Raspberry Pi 3B+ for its low power consumption and low cost but mostly because I have one to hand. Before we can install DIY Hue we need to setup our Pi.

First we need to flash the Raspberry Pi OS (formerly raspbian) which we can download from the Raspberry Pi website:

https://www.raspberrypi.org/downloads/raspberry-pi-os/

Once we have the ISO file we can use BalenaEtcher to easily flash it onto an SD card:

https://www.balena.io/etcher/

Before we eject the SD card and boot up our pi we may want to enable SSH by adding an empty file titled ssh (no file extension) to our boot directory. This means we wont need to plug a monitor and keyboard in to send commands.

With everything setup we can connect an ethernet cable and power up our pi and let the first boot process complete. Once complete, log in and open the terminal.

First update and upgrade apt-get:

sudo apt-get update
sudo apt-get upgrade

You can now use the raspberry pi configuration tool to set key raspberry pi settings. I recommend setting a new (and secure) password for the ‘pi’ user and expanding the file system to fill your SD card. That can be done with the command:

sudo raspi-config

Once complete, reboot the pi when prompted.

DIY Hue is easy to install with one command in the terminal:

docker run -d --name "diyHue" --restart="always" --network="host" -e MAC='XX:XX:XX:XX:XX:XX' -v '/mnt/hue-emulator/export/':'/opt/hue-emulator/export/':'rw' diyhue/core:latest

With the DIY Hue software installed and running we can now connect to the hub with our phone and the Philips Hue app. When prompted to “press the button” on the hub click the activate button at:

http://{IP_ADDRESS}/hue/linkbutton

We can now add bulbs and control them all from our phone! First we will need to flash them with some firmware and assemble them.

Step 5: Firmware

Before soldering the custom PCBs to the Wemos D1 I suggest flashing the firmware. Doing this before soldering them will let you find any boards that are dead out of the box! (of which I had 1!).

The DIY Hue project has a set of firmwares which come with a webGUI and all the required settings and code we need available for different types of devices. Since we are using a simple RGB LED we can make use of the “Generic_RGB_Light” firmware which can be found in the “Arduino” Folder. You can find the firmware here:

https://github.com/diyhue/Lights

To flash the firmware we will need a USB Type B cable to connect the board to our PC and the Arduino IDE which you can download here:

https://www.arduino.cc/en/Main/Software

Before we can upload code to the Wemos D1 board we need to install a board package to our Arduino IDE. Since the ESP Library isn’t a standard Arduino library we will first have to add an additional url to board manager which can be done in the preferences page. We need to add:

https://arduino.esp8266.com/stable/package_esp8266com_index.json</a>

Once we have added that url we search for and install the ESP board profile from the arduino boards manager. Set the board settings as per the image above and select the correct port. We are now ready to upload!

Download and open the firmware file. From here you can choose to enter your Wifi network credentials and LED pin outs so that the board automatically connects but we dont need to make any changes here as we can access all of these through the web UI and edit them during runtime!

Once you're ready, hit the upload button!

Note: Some Wemos D1 boards use a CH340 USB to serial converter which in later versions of macOS causes a kernel panic when plugged in! If you find you're having this issue you will need to update your drivers. More info can be found here: https://thingsmatic.com/2017/08/07/using-ch340-de…

Once the firmware is flashed you can connect to the wireless access point that the board creates to enter your wifi credentials and you can also set the correct pinouts for the board. These will vary depending on how you soldered your LED but they will always be a combination of pins 12, 13, and 16.

Step 6: Assembly

Now we have all the parts its time to assemble the boards into a finished lamp!

First solder the RGB LED to the custom PCBs. There should be a white dot on the silkscreen that indicates which hole the anode must be connected to. It doesn’t matter which hole the other legs go in since we can adjust the colour channels in the software. Being consistent will make it quick work though!

Next we need to solder header pins to the Wemos boards. A neat trick to help get the header pins straight in your PCBs is to press the headers into your breadboard and solder the board on the breadboard. This way you know that the mating part will fit on! With the header pins installed drop the LED PCB over the top making sure you get it the right way up and solder it on.

Since the Wemo D1 doesnt have any mounting holes I used hot glue to secure them into the printed piece. The hot glue will fill any gaps and hold the board firmly but dont go overboard as too much could cause the electronics to overheat!

Finally I glued the diffuser cube on the top using a small dab of hot glue in each corner. The hot glue holds the diffuser firmly but it can be broken off with a little force incase you need to adjust the angle at all (which I had to do a few times!). Just be careful not to damage the LED inside.

Step 7: Setup the Lights

With the lamps built, the firmware flashed, and a connection made to the wifi the final step is to add them to the server through the Philips hue app. This is easily done with the “add light” button and the server should automatically pick them up. You can now control the colour of the lamps through the app.

To enable Light syncing with our TV or PC we need to create an entertainment zone. To do that select:

Settings -> Entertainment Areas -> Create Entertainment Area.

In this screen we can tell the app which lamps to include and can also place them around the space using by dropping their light icon into the right place on the picture. Tapping the lamps changes the height at which they are set.

To connect your Philips TV you need to now select the entertainment zone under the ambilight+ settings.

To connect your PC download the hue sync app and click “Start Sync”

https://www.philips-hue.com/en-gb/entertainment/sy...

Step 8: Enjoy!

Thank you for reading my Instructable, I hope you enjoyed it! The lamps turned out much better than expected! Im really pleased with how they look and the light sync makes watching films and playing games immersive as the room lights up to set the scene. I would like develop the lamps further and remove dependance on the Philips hue protocol so that HDMI input to the pi to be used to drive the lamps. I would also like to introduce HomeKit control so that the lamps can be used as smart lamps when not light syncing.

I hope this Instructable has been interesting and inspired you to create your own lamps. I found the project to be a huge learning experience but one that I enjoyed, and I certainly picked up a lot of new skills along the way. If you build these lamps please leave a comment - I’d love to see what you make!

Lighting Challenge

Runner Up in the
Lighting Challenge

1 Person Made This Project!

Recommendations

  • Water Speed Challenge

    Water Speed Challenge
  • Colors of the Rainbow Contest

    Colors of the Rainbow Contest
  • DIY Summer Camp Contest

    DIY Summer Camp Contest

17 Comments

0
ftratar
ftratar

3 months ago

Where do I need to define the LED Pins in the Firmware ? D0,D6,D7//settingschar lightName[LIGHT_NAME_MAX_LENGTH] = "New Hue RGB light";uint8_t scene = 0, startup = false, onPin = 4, offPin = 5, pins[] = {12, 13, 14}; //red, green, blue

0
EdChamberlain
EdChamberlain

Reply 3 months ago

I think the Instructables formatting messed your post up a little! You can define your pins in the firmware prior to flashing but this isn't necessary as you can (once the firmware is flashed) adjust the pin mapping though the web gui at runtime.

0
ftratar
ftratar

Reply 3 months ago

How does this web gui look like ? Is it this the one attached ? I cant find the Pin setting..

PIC.jpg
0
EdChamberlain
EdChamberlain

Reply 3 months ago

That is somewhat correct. It looks like you are in the captive portal to configure the network settings. It has been a while since I did this but I believe you need to connect it to your network before you can access the full webGUI to edit settings. Select configure Wifi and connect it to your wifi first. Then visit the webgui through your router.

0
ftratar
ftratar

Reply 3 months ago

Thanks, I can connect to my WiFi so far with captive portal, but what is the adress to access the WebGUI? I try to access over the access point 192.168.4.1 over a pc browser, given from the captive portal, but does not work.

0
EdChamberlain
EdChamberlain

Reply 3 months ago

I'm not able to help you with that I'm afraid as the IP address will depend entirely on your network setup and is likely allocated through DHCP so will not stay the same. The IP will be different to that which you see on the captive portal.

The first option to try is logging into your router/hub and seeing if that can tell you what IP has been allocated. Your hub is most likely at 192.168.1.1 or 192.168.1.255 or will be noted on the hub itself.

Failing that you can try scanning for it from your PC using `arp -a` in terminal or powershell (the windows output is less useful). This will list all of the IPs on your network, from which you can find the one you want.

The Hue light will show up with some reference to hue or ESP in its hostname.

0
ftratar
ftratar

Reply 3 months ago

Big thanks , now by logging into the router I could identify the IP and all works with the WebGUI.!! Best regards Filip

0
RobsyRocket
RobsyRocket

10 months ago

The link to the LED diffuser seems to be not working. Nothing happen when I click on it. It would be great to see what you used.

1
snorlaxprime
snorlaxprime

10 months ago

Thank you for posting this. Awesome way to light up your lounge room.

0
EdChamberlain
EdChamberlain

Reply 10 months ago

They really turned out a lot better than expected! They make film nights or late night gaming much more enjoyable! Im about to order a second batch of boards to make some more!

0
PerryC4
PerryC4

10 months ago

What ip is used for http://{ip address}/hue/linkbutton? Is this the ip of the raspberry pi or the ip of the wemos? Or the ip 192.168.4.1?

0
EdChamberlain
EdChamberlain

Reply 10 months ago

Thats the IP of the raspberry pi! You can access the settings for the individual lights at the wemos IP.

0
moltcraft
moltcraft

10 months ago

That is amazing!

0
EdChamberlain
EdChamberlain

Reply 10 months ago

Thanks! Im glad you liked it!

0
wilberger.daniel
wilberger.daniel

10 months ago

This is so impressive! Congrats on this awesome project! I imagine it took a lot of time.
Very recently, I've also developed a very siilar lamp (and they share the same name lol) https://www.instructables.com/id/Pixel-Smart-Lamp/

I didn't know about this Wemos board, and it seems a lot more apropriate for my project. Thanks for the inspiration.

A question though: I'm using Bluetooth on my project, do you know if the Wemos 1 would be the best for me? I understand I would have to get a Bluetooth module, just like for the arduino. Does Arduino modules work with Wemos?

Thank you in advance,
Daniel

0
EdChamberlain
EdChamberlain

Reply 10 months ago

Hi Daniel!
Im glad you liked the project! I saw your project just after posting mine and really like what you've done with the app.

I really like the Wemos boards, they’re really versatile and so small but they dont support bluetooth on their own so you're right that you would need to have a bluetooth module to go with it. I would imagine that your bluetooth module would work with the Wemos and it should be pretty straightforward to port your code since they are also programmed in the Arduino IDE but I haven't tried it.

Unless you are going to make use of the wifi capabilities I would stick with the Nano for simplicity. While the ESP based wemos board look similar to the nano there are some caveats when it comes to using the GPIO pins which makes it a little more tricky than the nano. If youre looking for a slightly larger board with more GPIO you could also have a look at the NodeMCU which I have used before with a lot of success!

I went down the route of using the Wemos as I was set on using wifi instead of bluetooth since you get a slightly better range and can control it from the network which opens it up to Siri, Alexa, Google Assistant and control anywhere in the world! The other advantage I see is you could do away with your RTC module and collect time from a time server so you wouldn't have to worry about the clock drift at all!

Let me know how you get on!