Source | Minority
Here’s the story: In September 2021, I saw a video on Bilibili by a friend @Electric Star (another version of me) sharing his experience with the Philips Hue Play ambient light. I was captivated by the synchronized lighting effects and HomeKit support, but when I checked on JD, the nearly 2000 Yuan price tag completely deterred me.
Screenshot from @Electric Star’s video
I thought that would be the end of it, but later, Big Ear TV also shared their experience using the Philips Hue Sync Box and Hue ambient light strip, reigniting my desire for such a product.
Screenshot from @Big Ear TV’s video
However, the 2000 Yuan price tag was too much for me to handle. So I wondered if there was a cheaper solution that could achieve similar effects. Thus began my year-long journey of tinkering.
▍Requirements and Early Tinkering Process
Before we dive into the article, we need to introduce a concept: Bias Lighting.
Bias lighting is a concept in video editing and home theater, referring to a low-level light source located behind a screen or monitor to illuminate the wall behind it. The purpose of bias lighting is to reduce the perceived brightness of the display and minimize eye strain when viewing a bright screen in a very dark environment.
It’s easy to see that both the Philips Hue ambient light set and other lighting solutions behind monitors or TVs fall under the category of bias lighting. With this concept in mind, we can continue.
What are the requirements?
Before opening Taobao, the first step is to clarify what my bias lighting needs are. For me, my main functional requirements are as follows:
Ready-made Product Solutions
Once I clarified my needs, I actually found similar products on Taobao, even though the price slightly exceeded my budget, it was still a bargain compared to the Philips’s 2000 Yuan price.
After inquiring with the seller, they said this bias lighting solution could meet most of my needs, but it did not support HomeKit. At that time, I thought this issue was not too big, as I could directly add a HomeKit-compatible socket to the light strip’s power supply, which would also solve the problem indirectly.
So, I spent 143 Yuan to purchase this “cheap dynamic lighting strip.” Soon after, I received a control box, a 2-meter light strip, a 5V 8A power supply, and a USB-A to USB-B data cable to connect to the computer—similar to the Hue Play set. I followed the tutorial to stick the light strip and connect the computer and control box, but when powering it up, there was an issue: I mistakenly connected the monitor’s 24V power supply to the light strip, which directly caused the light strip to become inoperable.
Helpless, I spent another amount to repurchase a 2-meter light strip. A few days later, after carefully checking everything was correct, I powered it up and set up the drivers and software on my Mac according to the tutorial, finally successfully lighting it up and starting the dynamic color-changing effect synchronized with the screen display.
But as someone who has been through this, I must tell you that it’s better not to choose these solutions from Taobao merchants in the future. Not only are the prices high, but their hardware and software are not self-developed; they merely took ideas from the open-source community to create their products. Therefore, they do not understand the principles, and the level of after-sales service is very average (eventually, I even had to teach the seller how to set it up, and he could only reply with three ellipses). If possible, it’s advisable to either go directly with Philips Hue or DIY it yourself.
Integrating HomeKit
The next step is figuring out how to integrate them into HomeKit.
At first, I did consider directly adding a HomeKit socket, but that would indeed be a compromise: it would protrude awkwardly and wouldn’t allow control over the light strip’s color and brightness, only a switch function, which felt inelegant.
At this point, the power of the internet came into play. After some searching, I found that the software I used to control the light strip, “Prismatik,” already had a HomeAssistant plugin developed for it. This way, I could integrate the light strip into HomeAssistant and connect it to HomeKit through the HomeKit bridge.
This plugin is also relatively easy to use. After installing the plugin (which can be added via the custom repository in the HACS store or manually), restart, and then add the following configuration in the HomeAssistant’s configuration.yaml file:
light:
- platform: prismatik
host: Mac's IP address
name: "Light strip name"
After restarting again, the light strip was added to HomeAssistant. Although the plugin had not been updated for over a year, the core functions were already in place, allowing adjustments to the light strip’s power, color, color temperature, and brightness.
Existing Issues
The value of this solution lies in providing a quick fix for the pain points I faced without understanding the related technical principles at that time. However, I have been enduring various issues since then.
First, the home-assistant-prismatik plugin’s collaboration with the Prismatik software is very unstable; sometimes the plugin cannot control the light strip, requiring a restart of the software on the computer. There were even instances where the light strip would inexplicably turn off by itself, needing a restart of both the plugin and software to establish a connection.
Secondly, mobility is limited. Since the light strip’s control data is connected via USB to the computer, and the home-assistant-prismatik connects to the computer through the local network, when I need to go out or use the laptop alone, after unplugging the Thunderbolt cable from the MacBook and dock, the plugin can no longer communicate with the light strip control box, and HomeAssistant and the Home app will directly indicate “no response” for the device.
Most frustratingly, the WCH serial chip in the light strip control box changes the port number after reconnecting to the Mac. Since Prismatik requires reinitializing the light strip when the connection device’s serial port number changes, and due to work reasons, I had to carry my computer to work every day, the first thing I did when I got home was to rerun the light strip’s initialization settings from scratch…
However, after resigning in May this year, I spent a long time living in Hainan, temporarily putting these issues with the light strip aside. Until the end of September, when I returned to Guangzhou, sorted out the HomeKit standing desk, and finally could tackle this problem.
▍Solution: Redesigning the Light Strip Control Module
To solve the above issues, I first needed to understand how this system works, so I thoroughly dismantled and researched the hardware.
Upon opening the control box, I discovered that it was essentially a DIY solution shared by someone on Reddit, which some Taobao merchants copied and sold. The core is an Arduino UNO development board, flashed with open-source Ambilight firmware, while the light strip uses the well-known WS2812B. This external system combined with the Prismatik software on the computer achieves the dynamic lighting effect.
Spoiler image: Size comparison between Arduino UNO and subsequent modules
With that in mind, where can we start making modifications?
WS2812B light strip? The answer is no need. The WS2812B light strip has good quality, supporting 16 million colors, and only requires a single signal line for data reception and decoding between the light beads.
What about the power supply? The seller provided a 5V 8A power supply; can the power supply module be downsized? No. According to the WS2812B light strip’s specifications, the driving current for a single WS2812B is 60mA, and to surround my 32-inch screen, at least 2 meters in length is required, totaling 120 WS2812B LEDs. Thus, the minimum current requirement is 0.06 × 120 = 7.2A; otherwise, it won’t provide enough current to light up the light strip.
So, the only place we can modify is the control box.
Which Control Scheme to Choose?
To enable the light strip to connect directly to Apple HomeKit and support switching, brightness, color temperature, and color adjustments, I decided to abandon the original Arduino UNO control box and design a new control scheme for WS2812B that does not require a computer as an intermediary.
Referring to the article by @EstrellaXD on “How the HomeKit Smart Standing Desk was Made” on WeChat, I learned that there are three commonly used open-source SDKs to start building a HomeKit module from scratch:
ESP Apple HomeKit SDK: This is a custom SDK for ESP32 and ESP8266 sold by Espressif based on HAP. Its advantages are comprehensive functions and many definable parameters, but it requires some embedded development knowledge.
Arduino HomeKit ESP8266: This is code customized for ESP8266 in Arduino by third-party developers. Compared to the official ESP SDK, Arduino is significantly easier to use and offers many customization options.
HomeKit Accessories Architect (HAA): This is also a third-party developed kit based on the ESP8266 chip. Compared to the above two solutions, HAA’s advantage is that it does not require writing code; you can easily configure DIY HomeKit accessory types and functions through JSON files, making it the most user-friendly and convenient.
After searching and considering, unfortunately, I found that there is currently no control scheme for dynamic lighting strips that can connect directly to HomeKit. However, a glimmer of hope emerged during my search when I discovered another open-source project: WLED.
The story will change with the emergence of the WLED project.
About the WLED Project
WLED is an open-source project developed by German developer Christian Schwinne based on ESP8266 or ESP32, allowing WS2812B, WS2811, and other LED lights or strips to connect to the internet for control, providing a graphical interface, iOS and Android apps, and rich customization options.
The biggest highlight is that it natively supports integration with HomeAssistant. This means we can perform the integration of WLED into HomeAssistant and bridge it to HomeKit without writing a single line of code, directly through the graphical interface.
However, WLED’s surprises don’t end there; it also supports synchronization with Philips Hue, Alexa voice control, and MQTT features. If you’re interested in tinkering with another open-source project, DiyHue, you can even map WLED as a Philips Hue Strip Plus light strip and use it in conjunction with Hue Sync (the official Philips dynamic lighting kit)—consider that a 2-meter WS2812B light strip costs around 30 Yuan, while the same length Hue Strip Plus light strip costs a staggering 729 Yuan.
Hyperion: A New Wireless Recording Solution
Simply getting the LED light strip driver and HomeKit connection is only half of the requirements; the dynamic lighting part still hasn’t been addressed. However, within the WLED project, there’s another feature support mentioned: Hyperion.
Hyperion is an open-source bias lighting software solution similar to Prismatik, but it has several advantages over Prismatik, including:
-
Low CPU load, allowing even a Raspberry Pi to run smoothly;
-
Supports a Chinese web interface for configuration and use;
-
Supports remote control.
Choosing Suitable Hardware and Thinking About Connection Methods
With software and hardware support in place, the next step is to set up a testing environment to verify the feasibility of the solution.
First, we need to choose an ESP8266 development board or module. However, with so many ESP8266-based hardware options available, how do we choose? Don’t worry, let’s go back to the WLED project’s official page, scroll down, and you’ll see a link to the “Supported Hardware” page provided by the author. Clicking on it gives a detailed list of LED light strip types and voltages, supported WLED control modules or development boards, and other hardware that may be needed.
Since the WS2812B light strip only needs one control signal to drive, theoretically, any control chip with an IO interface will suffice. To minimize size, I discarded development boards like NodeMCU, ultimately settling on the ESP-01S. The ESP-01S is a tiny IoT module based on ESP8266 developed by AiThinker, only the size of half a thumb, providing two IO interfaces, making it perfect for our needs.
However, it’s important to note that the WLED author advises against using the ESP-01S as a WLED controller for three reasons:
However, considering that I already had a USB-to-serial module to flash the firmware, and if the firmware can operate stably, there isn’t much need for updates. Additionally, the ESP-01S’s power supply can be solved using an AMS1117-3.3 chip, so the small drawbacks mentioned by the author don’t significantly impact me.
USB-to-serial modules generally look like this
As for the remaining power supply and light strip parts, I decided to continue using the original solution without any modifications. This way, I wouldn’t have to re-stick the WS2812B light strip behind the monitor or deal with the wiring under the desk; I just need to replace the original control box.
However, there is one difference: the original Taobao solution was dual-powered, meaning the 5V8A power supply only powered the light strip, while the Arduino was powered via USB from the computer while also transmitting recording data, with both power supplies sharing a ground. In the redesigned solution, I decided to cut out the USB cable, allowing the ESP-01S to wirelessly obtain recording data from Hyperion and draw power directly from the light strip power supply, solving the power issue through the aforementioned AMS1117-3.3 chip.
Building the System and Testing
After waiting some time, all the necessary hardware has arrived, and we can set up the circuit on a breadboard and conduct tests.
But before that, we need to flash the firmware onto the ESP-01S using the USB-to-serial module. The firmware can be downloaded from the WLED Release page; select the file “WLED_0.13.3_ESP01.bin.”
Next, we install the ESP flashing program Tasmotizer and the USB-to-serial module’s driver on the computer, then connect the USB-to-serial module to the ESP-01S according to the following circuit, and insert the module into the computer’s USB port:
Note: Never connect the 5V power supply of the serial module directly; otherwise, the ESP-01S will burn out. Some serial modules may not work with the 3.3V power supply, in which case an AMS1117-3.3 LDO module is needed to lower the voltage to 3.3V.
One crucial point to note is that in download mode, the ESP-01S’s IO0 needs to be pulled down, so an extra wire is required to connect IO0 to ground; otherwise, the firmware cannot be flashed.
Finally, in Tasmotizer, select the corresponding serial port and import the firmware, then click the “Tasmotize!” button in the lower left corner to automatically flash the firmware onto the ESP-01S.
After successfully flashing the firmware, connect the circuit according to the following schematic, then power the entire system to begin testing.
Be sure to prepare some 1KΩ resistors in advance.
On first power-up, HIA will require setting the Wi-Fi connection for WLED. Connect to the WLED-AP Wi-Fi on your computer or phone, with the password wled1234, then input your Wi-Fi SSID and password on the pop-up page and click “Save” at the top.
Next, find the WLED IP address in your router and enter it into your browser to configure it. Here, we won’t make too many changes to other projects; we’ll go straight to “Config > LED Preferences” to change the number of LEDs to 120 (generally, there are 60 LEDs per meter).
You can decide whether to turn off the brightness limit based on your situation; I tested it with two meters without issues. If the current is too high, it may damage the ESP-01S.
After saving the settings, if there are no other errors, all 120 LEDs should now be lit and can be controlled via the web interface.
The next step is to automatically integrate the LED into HomeAssistant. Go to HomeAssistant’s “Configuration > Devices & Services” page, and HomeAssistant will prompt that a new WLED integration has been discovered. Follow the instructions to add it to HomeAssistant.
If it doesn’t auto-discover, you can click the “Add Integration” button at the bottom right.
At this point, we can control WLED through HomeAssistant. Additionally, you can view many control options and status parameters in HomeAssistant; if you’re interested, you can continue to explore this, but we will temporarily skip it and continue with our main task.
At this moment, we can connect WLED to HomeKit through HASS Bridge. Click the options button on the HASS Bridge card (if it’s not there, you need to add a HASS Bridge integration first), then set it up accordingly. However, since each person’s bridging method may vary, you can refer to the “Connecting to HomeKit” section in this article for explanations on “Domain,” “Include Mode,” and “Select Entities to Exclude” to add based on your needs. After completing, click the three dots at the bottom right of the card to reload the integration, and shortly you will see that WLED has been successfully added to HomeKit in the Home app.
At this point, the system built on the new approach has successfully integrated WLED and HomeKit. The next step is to return to the Mac to set up Hyperion.
Go to the Hyperion GitHub Release page, download the latest version of Hyperion for Mac, install it, and grant it screen recording permissions. Then you can click “Hyperion > Setting” in the menu bar to access its web configuration page.
Windows users need to click “Show all 14 assets” below to see them.
First, we can click the wrench in the upper right corner to change the Hyperion settings page to Chinese. Then, go to “LED Configuration > LED Hardware” and select WLED as the controller type, allowing Hyperion to discover the device itself (or directly input the WLED IP address).
Next, go to the LED layout settings page, set the corresponding LED layout according to the light strip’s sticking path behind the monitor, and then return to the LED controller page to save the settings.
If there are no errors in the settings, you should now see that WLED is starting to display dynamic lighting effects.
Thus, all tests have successfully passed, and all the requirements we set at the beginning have been met.
▍Designing the PCB Module and Stability Testing
Although our tests have been successful, evidently, this “spider cave” system cannot be directly moved to the back of the monitor for use. We need to design a suitable PCB to house the entire circuit and the EPS-01S module.
Designing and Sampling the PCB
I chose Jialichuang EDA for this. As a domestic EDA design software, we can directly submit the designed PCB to Jialichuang for production. Each month, we can sample two PCB projects for free (5 pieces each), which is quite generous. If you don’t want to solder SMT parts yourself, you can also let Jialichuang handle it.
After registering an account and creating a project, the first step is to draw the schematic. This part is not difficult; find or search for the corresponding components on the left, add them to the drawing area, and connect them according to the solution we ran on the breadboard earlier.
Once the schematic is done, click save, then click “Design Schematic to PCB.” Since this project’s PCB is not too complex, a simple single-sided connection will suffice.
After completing the design, click “Manufacture > One-click PCB/SMT” to place an order. The software will prompt you to perform a DRC check to verify if there are any issues with the circuit design. After passing the DRC check, we can order PCB samples from Jialichuang and wait for them to be delivered to our home.
As a lazy person who doesn’t have a reflow soldering platform, I really didn’t want to solder SMT parts myself, so I directly let Jialichuang provide a one-stop service. Although the 50 Yuan SMT soldering fee is indeed not low, considering I’ve already taken advantage of so many boards from Jialichuang, I won’t complain too much.
Soldering Straight Pins
Once the board arrives, I need to solder the ESP-01S module that has already flashed the WLED firmware, as well as the terminals for connecting power and the WS2812B light strip on both sides. However, since the terminals are a bit large, I simply soldered the wires directly onto the corresponding pads, further reducing the overall module size.
Stability Testing
The dynamic lighting control module, which has successfully slimmed down and implemented more functions, is complete, but I still do not recommend immediately using it behind the monitor. After all, the power supply has reached 40W, with a current of up to 8A, so I specifically conducted a day-long stability test to see if there would be any issues with prolonged lighting.
In practical tests, the AMS1117-3.3 felt quite hot to the touch, with a temperature around 50-60 degrees Celsius. This is partly because the ESP-01S module above obstructs heat dissipation, and partly because the module is too small to accommodate any cooling facilities, relying solely on air cooling. Fortunately, the AMS1117-3.3’s maximum operating temperature can reach 120 degrees Celsius, so I don’t need to worry about this issue.
Nevertheless, I still need to actually install it behind the monitor for an extended period to determine whether this module can handle the workload.
Calculating Costs
If we disregard the expenses incurred during the development process, the actual cost of the light strip (including shipping) is as follows:
|
|
|
|
2-meter WS2812B Light Strip
|
|
|
|
|
|
|
|
|
|
|
|
Although it slightly exceeds the budget, it’s clear that the main expenses are in the SMT soldering from Jialichuang. If you choose to solder it yourself, you can save that cost. Overall, the cost of this entire setup is not high, and compared to the Philips Hue dynamic lighting set, which easily runs into thousands of Yuan, this is considered the “cheapest of the cheap” price.
However, compared to commercial products, this version of the WLED dynamic lighting driver module still has many areas for improvement. But for a DIY product for personal use, it’s already quite cheap, stable, and easy to use.
It can also serve as an ordinary lighting lamp, enhancing the ambiance.
▍Second Version Improvements
As mentioned earlier, I found that the terminals on both sides used for wiring were too large, and directly soldering wires caused a significant protrusion, which was not elegant enough. Therefore, after using the first version of the WLED dynamic lighting control module for less than a week, I began designing the second version of the PCB.
Compared to the first version PCB, the second version significantly reduced the length of the module on both sides, with an overall length of only 3.4 centimeters, compressing it to the limit length that can house the ESP-01S.
Additionally, to increase the heat dissipation capability of the AMS1117-3.3, the second version PCB added a bare copper area beneath it, allowing it to transfer heat efficiently to the surrounding module, increasing contact area with the air.
Finally, this version of the PCB also includes interfaces for future firmware upgrades for the ESP-01S. When encountering significant WLED firmware updates that cannot be wirelessly updated, these four interfaces will allow for easy upgrades: just connect RXD and TXD to the corresponding lines of the USB-to-serial module, and short IO0 and GND.
However, as of now, the first version of the WLED dynamic lighting module is still running well, so unless there is a demand, I may not rush to sample the second version of the PCB, leaving it for future upgrades or new demands, such as adding an HDMI input capture module similar to the Philips Hue Sync Box, which costs as high as 2399 Yuan.
By the way, this WLED dynamic lighting module can also serve as a general WS2812B light strip control module. Stick it with the light strip in the desired location, connect the power supply, and bridge it to HomeKit through HomeAssistant, and you can achieve a color light strip device controlled by the Apple Home app at a very low cost.
▍HomeKit and HomeAssistant Automation
With the WLED light strip that does not rely on computer communication, we can now confidently integrate it into HomeKit and HomeAssistant for automation operations.
Based on my needs, most of the time, WLED is used as a constant bias lighting behind the monitor at night. Therefore, I set up a linkage between WLED and work mode: when turned on, WLED will turn on and switch to around 4000K natural light, helping me focus.
Additionally, during gaming mode, through HomeAssistant automation, WLED can be set to RGB rainbow mode, creating a gaming-style environment.
If we talk about the shortcomings of this new WLED dynamic lighting module, they mainly lie in the software aspect.
In my opinion, the biggest regret is the inability to directly select between ambient light mode and dynamic lighting mode in HomeKit. However, I cannot change this issue because the fundamental reason is that HomeKit does not support selecting lighting modes; we can only hope that Apple will add this feature in the future.
Secondly, when I want to exit the dynamic lighting mode, I need to manually exit Hyperion on the computer. After exiting Hyperion, the light strip is likely to turn off completely instead of handing back control to WLED. At this point, I need to manually go to the WLED web or app settings interface and click “Override once” to re-establish control over WLED, which is a bit cumbersome. Moreover, this issue, like the previous one, currently has no better solution.
This project originated from dissatisfaction with the fragmented user experience of the original Prismatik dynamic lighting solution. For a long time, I had no way to solve it until later when I followed the article by @EstrellaXD on DIY HomeKit standing desks, which inspired me to make significant changes.
Honestly, luck played a considerable role in this; I didn’t expect so many DIY predecessors to create such excellent solutions—I’m just a搬运工, solidifying these successfully running hardware into my own module. Therefore, I really need to thank the WLED developer Christian Schwinne and the Hyperion developers for selflessly open-sourcing their results online.
The WLED dynamic lighting driver module is my second HomeKit device DIY project after the standing desk, which I created by researching and referencing data sheets. The process of exploring the unknown and achieving success felt like I was reliving the night six years ago when I first encountered HomeKit and integrated YeeLight bulbs into it—at the moment of success, I realized I hadn’t felt this happy in a long time.
So, who will be the next product transformed to “Work with Apple Home”? Stay tuned.
Author: Wantong, Source: Minority
Original article reference: https://sspai.com/post/76707?utm_source=wechat&utm_medium=social
-
WLED:https://github.com/Aircoookie/WLED/releases
-
Hyperion:https://github.com/hyperion-project/hyperion.ng
-
Tasmotizer:https://github.com/tasmota/tasmotizer
Disclaimer: This article is reprinted with permission from the “Minority” public account. The reprint is for learning and reference only and does not represent this account’s endorsement of its views. This account also does not bear any infringement liability for its content, text, or images.
♥Click 👇 the business card to follow me♥
Previous Recommendations ·
1、The most comprehensive LED lighting program ever!
2、Share a bug location method you might not know
3、From scratch, hand-in-hand teaching you to write a serial debugging assistant