Creating a standing LED light with Home Assistant and NodeMCU — Part 1
By: Glenn Ruysschaert
Tags: Lighting, Home Automation, Home Assistant, Nodemcu, Led

The goal is to create a minimal standing light that we can easily place anywhere. In the end, you will be able to use Home Assistant to control the devices. This is a step by step guide on how to achieve this. For newcomers to Home Assistant and LED lights, this might seem like a daunting task. But do not worry, we’ve all been there and I will do my best to provide detailed instructions so this will be a breeze.

The idea comes from the Philips Hue Signe and MINIMALAMP.

Of course these are way too expensive. So why not do it ourselves for a fraction of the price, with the added benefit of being able to customize it however we like. In the end it cost me about €50 per lamp (not including the hardware for Home Assistant and Zigbee).

What we’ll be making

Requirements

There are a few things we’ll need to create this lamp. Make sure you have downloaded and installed the required software.

Hardware

To control the LEDs we will use a ESP8266 board. This is a cheap WiFi enabled board. You can get one for about €5 on Amazon.com. Next we’ll need the actual LEDs. These are individually addressable LEDs, not regular LED strips. This will cost you about €15/meter, depending on where you buy them and how many LEDs there are per meter. A micro USB power supply is required to power the ESP8266 board (this board also powers the LEDs). The output needs to be 2.4A. Something like this one will do (make sure to buy the correct plug for where you live). You likely already have one at home. If you can solder, great. Otherwise you’ll need a breadboard and some jumper cables (which is what I’ll be using in this guide for demonstration purposes). For the final product I will solder the LEDs to the ESP8266.

Software

Make sure Home Assistant is already working, this guide will not go over how to install Home Assistant. I will only discuss how to get these lights working in Home Assistant. At the time of writing this is supervisor 222 and HassOS 3.13 (production). On the ESP8266 board we will flash WLED by Aircookie, this firmware has everything we need to control the LEDs. I used WLED version 0.10.0, feel free to use a newer release. Download *_ESP8266.bin, so in my case this was WLED_0.10.0_ESP8266.bin. Install NodeMCU PyFlasher on your computer. PyFlasher will be used to flash the required software on the ESP8266 board (available for Mac and Windows). I’m using version 4.0 on a Mac. WLED app on iOS or Android.

Once you have all the hardware and installed the required software, we‘re ready to begin!

Flashing WLED onto the ESP8266 board

Requirements for this step

You have downloaded the WLED bin

You have installed NodeMCU PyFlasher

A Micro USB cable (make sure it can transfer data, and is not just a charging cable)

The ESP8266 board

Let’s start with opening NodeMCU PyFlasher. You will be greeted with this view.

Connect the ESP8266 board to your computer with the Micro USB cable.

Select usbserial as Serial Port and browse to the downloaded bin file. Leave the other settings to their defaults.

Press the Flash NodeMCU button.

Note that I had to disable Bluetooth on my laptop, otherwise Flash NodeMCU would fail. So if you press Flash NodeMCU and it fails, disable bluetooth and hit the scan button on the top right (the two arrows). Now try pressing Flash NodeMCU again.

Logs will start appearing, the flashing is done once you see Firmware successfully flashed.

You can now unplug the board from your computer.

That’s it for this step! The firmware is flashed to the board and ready to use.

Connecting LEDs to the board

Requirements for this step

Breadboard and jumper cables (if you solder, look at how the cables are connected on the breadboard and solder them the same way)

ESP8266 board

LED strip

Let’s have a look at the LED strip first. The colors on the cables may vary, but usually black is Ground and red is 5V. The other color (in my case blue) is the cable that will tell the LEDs what to do. You can see my strip has 2 Ground cables.

Now I’ve placed the ESP8266 board onto the breadboard. Note that I have split the breadboard to easily place the board onto it.

Time to connect the strip and LEDs!

On the chip you will find VIN, G (or GND)and D4. VIN is the power supply, D4 is the pin we will use to send the data.

Connect the cables to the corresponding pins on the breadboard.

Red: VIN (or VU pin, see below if VIN doesn’t work)

Black: G

Blue: D4

And we’re done! That was pretty easy, right?

Plug in the the Micro USB power supply to a wall socket and connect it to your ESP8266 board, it should power on (you will see a small LED light). Your LED lights should turn on now as well.

What if your lights are not turning on?

Your board might not be providing power through the VIN pin. See if you have a VU pin . If so, unplug the Micro USB cable, and connect the red cable to the VU pin. Plug the Micro USB cable back in. Now it should work.

. If so, unplug the Micro USB cable, and connect the red cable to the VU pin. Plug the Micro USB cable back in. Now it should work. Check if your wires are properly plugged in.

Check if the LED on the board is on, if not the power supply is probably faulty or the flashing failed. Try a different power supply and reflashing the board.

What if not all lights are on?

You can set the amount of LEDs to turn on later, we will cover that in the next section.

Setting up WLED

Requirements for this step

ESP8266 board with WLED connected to the LED strip

Micro USB cable with power supply

A phone or laptop with WiFi

The WLED app

Go to your phone/laptop and look for WiFi access points. You will see WLED-AP, connect to it with the password wled1234

Your device will ask you to sign in to the WiFi network. Do so to go to the portal.

Tap on WiFi Settings. A the top, fill in the network name and password of the network you want the device to be connected to.

You can also rename and change the password of the AP the ESP8266 board is broadcasting at the bottom of the page.

Save these settings to connect the ESP8266 to your WiFi. You can now also disconnect from the ESP8266 AP and connect to your regular WiFi.

Just to be sure, you can unplug the ESP8266 from the power supply and plug it back in so it reboots.

Open the WLED app. Tap on the + on the top right, and start discovery. It should find your WLED. (if not, you will have to look up the IP address of the WLED in your router). Go back once it found the WLED.

Tap on WLED with its IP under it, you’re now in the control panel. Awesome, you can now play with the LEDs!

Wait, what if not all of your lights are on?

For me, I have 30 LEDs per meter. If you head over to the segments tab in the detail of a WLED in the app, you will see that you can set the amount if lights.

Calculate how many LEDs you have and set that as the STOP LED value. Click on the checkmark, now all your lights should be on.

Adding WLED to Home Assistant

Requirements for this step

Home Assistant

Go to Home Assistant, it will have probably discovered WLED already.

If not, restart Home Assistant as discovery will run on boot.

Still not found? Click on the + button on the Integrations page (bottom right), search for WLED and select it. Now enter the IP you can see in the WLED app.

Now it should be configured and ready to use.

In Part 2 we will assemble the standing light.

Sources: