Introduction: ESP8266 Wireless RGB Headlights (Genesis Coupe)
Are you looking to add multi-color RGB LEDs to your headlights? For most people an over the counter kit can probably check the necessary boxes. From the brand names you can get a tested, proven system with some level of a warranty. But what else does it come with? A cheap easy to lose remote? Bulky wiring? Brand ecosystem lockin? If you have the DIY chops read further to learn how to get started with making your own custom RGB LED kit. Please make sure to read the laws in your area regarding vehicle lighting requirements. I will not take or assume any liability or responsibility for your actions!
This guide starts with a few assumptions so please cover these points before proceeding:
- be familiar with the ESP8266 and how to program it
- be able to disassemble your car's headlights
- be able to solder without burning yourself... R.I.P. my finger tips
- be aware anything here may be different for your vehicle so adjust accordingly
- make sure to read the laws in your area regarding vehicle lighting requirements
Step 1: Headlight Controller Board - Collect the Supplies
For the two headlight microcontroller boards you'll need to collect the following parts
- 2 x ESP-01 boards
- 2 x Prototyping boards (2.54 mm / 0.1" / 100 mil pitch holes)
- 4 x 2N7000 small signal mosfets (TO-92 package)
- 4 x 1N4001 rectifier diodes
- 4 x 0.1uF capacitors
- 2 x open drain pull up resistors - 2k Ohm to 4k Ohm
- 2 x resistor divider top resistors - about 8.2k Ohm
- 2 x resistor divider bottom resistors - about 2k Ohm to 4K Ohm
- 2 x buck converter module - output set to 5 V
- 2 x LDO module - output set to 3.3 V
- optional: 2x screw terminal blocks
- optional: 2x ESP-01 breadboard adapters
- optional: 2x TVS surge protection diodes (~18V-21V)
- optional: 2x 22uF capacitors (25V min)
- optional: 2x 22uF capacitors (6.3V min)
I sourced nearly everything in this guide from eBay (or China Bay as I call it). This is because I am not worried about counterfeits or low quality when it comes to things like screw terminals, resistors, boards, or low power mosfets. I'm not driving them to their limits. However I did spend good money on the TVS diodes and the capacitors by ordering them through DigiKey. I only did this to guarantee what I received is what I ordered.
Step 2: Controller Board - Power Input Protection
To protect your electronics from reverse voltage the rectifier diode comes into play. I got 1N4004 diodes from my local electronics store. They're only meant to carry one amp max. You can see in my prototype on the next step I used one rectifier diode but to be safe I used two parallel on my final board. For protection from voltage spikes we use TVS diodes. They are like zener diodes but unlike zeners they can actually survive a few tens of amps without a sweat. You may be able to get away without using TVS diodes but I didn't want to risk it. I also used a capacitor at the input but that was only needed to prevent a brown-out anytime the halo rings were powered on.
Step 3: Controller Board - Power Supplies
After your input power passes the protection circuit you want to start making it usable for the components on your board. This is the duty of your buck converter and LDO. The buck converter can efficiently step down your car's 14V supply down to 4.5V at the output. The WS2818B LEDs and the LDO will be connected to the buck. The LDO further regulates the voltage to 3.3V for use by the ESP8266 and the input switches.
Note: The buck is set to 4.5V because the digital signal from the MCU to the LEDs is only 3.3V. If the LEDs are running at 5.0V then sometimes the incorrect data is received by the LEDs and the wrong color is displayed. Lowering the buck converter to 4.5V reduces this chance. Alternatively use a voltage level converter between the MCU and the LEDs.
Step 4: Controller Board - Input Switches
Let's talk about the input switches now. Say we want our controller board to detect when the turn signal is flashing and whether the low-beam is running. Some mechanism of detecting the presence of power is needed. We have a problem though, the power signals within your car are too high voltage to connect directly into your ESP8266. There are very few chips out there that can interface with a 16V signal and live to tell about it. Because of this we implement a layer of isolation between the power lines in the headlights and the inputs on the ESP8266. With just 3 resistors, a capacitor, and a small signal mosfet we can put together a high voltage capable switch that solves our needs and has debounce capability!
The theory of operation here is to use the mosfet as an open-drain buffer. Refer to the picture for how to build your circuit. The IN signal will come from the +12V power of your headlight's turn signal, low-beam, or high-beam. The OUT signal goes to your ESP-01 pin. Which pin to use will be covered in the software section.
Step 5: Controller Board - Some Assembly Required
Layout is up to you! It certainly helped me to sketch the layout on a piece of paper before placing components down. It also helps to avoid soldering until after everything is placed and finalized. On my very first board I just scrapped it instead of trying to move components around after the fact.
Overview of the previous steps:
Car Power => Input Protection => 5V Power => 3.3V Power => Processor
I recommend investing in the screw terminal block. The added convenience is priceless and it makes the board look much more professional. Using the ESP-01 breadboard adapter also lets you remove and replace the ESP-01 at any time should it break or need to be reprogrammed.
Step 6: Controller Board - Software
Your development environment will consist of the latest Arduino IDE (arduino.cc) and the NeoPixelBus library by Makuna that you can download using the Arduino built in library manager. To add ESP8266 support to the Arduino IDE follow these instructions: https://learn.sparkfun.com/tutorials/esp8266-thing...
The source code for my project is attached
ESP-01 pinout is as follows:
- GPIO 0 - low beam input
- GPIO 1 - turn signal input
- GPIO 2 - strip 2 output
- GPIO 3 - corner strip output
You are free to use any ESP8266 module you want with more available I/O pins.
The demo software is programmed to flash the corner strip amber in conjunction with the turn signal. This is just a simple example of how you can take this controller board way beyond an over the counter kit. After the turn signal stops for 1.25 seconds it returns to always-on / DRL. It is already programmed to keep the turn signal amber while keeping the DRL in memory as the last color you set. This means you can use your phone to set a default DRL color while retaining the amber turn signal feature.
Please be aware of the vehicle lighting laws in your area.
On your network the ESP8266 should appear as http://headlight-left.local or http://headlight-right.local. From there you can call the URL "http://headlight-left.local/help" to see the help menu and to learn about sending hex color values as arguments within HTTP requests.
Step 7: Corner LED Strip ("Parking Light") - Components
You can buy these LEDs in sheets of 100 for pretty cheap online. They come on round PCB pads that are easy to solder. With rigid wires you can solder these together and make all sorts of shapes. Or with loose wires you can sew these into clothing.
Step 8: Corner LED Strip ("Parking Light")
It's straightforward: power, ground, and data all follow one direction. I used up 18 LEDs on each side. The length of LED strip you can make is programmable and practically limitless.
Step 9: Headlight Installation
Removing the headlights is different for every vehicle. On the 2013 Genesis Coupe the headlights can't be removed without taking off the car's front bumper first! Opening the headlights is thankfully simple. All you need to do is bake the headlights in an oven at 205 to 215 degrees F for about 15 minutes. That will make the seal weak enough for you to pull the headlights apart. Definitely stop by YouTube for an endless trove of how to videos on this subject.
Putting the headlights back together just requires you to sandwich the parts back together and optionally heat them up again.
Pro Tip: Before putting your headlights in the oven you should remove bulbs, screws, and anything else that will get in the way. When the headlights come out of the oven you want your only concern to be pulling it apart.