Electronics
RGB Light with an ESP8266 and Homebridge
An ESP8266 that drives an RGB light with PWM and answers the web requests of the homebridge-http-rgb-push plugin.
- ESP8266
- Homebridge
- Archived
- 2 min read
Archived project
The GitHub repository for this project is archived: it is read-only and no longer updated. What follows describes the project as it was, so check for a newer alternative before you build it.
An RGB light for the Home app: switch it on and off, and set the colour and the brightness. An ESP8266 drives the three colour channels with PWM, and the Homebridge plugin homebridge-http-rgb-push by @sandervanwoensel talks to it over HTTP.
Homebridge is a program that runs on a computer such as a Raspberry Pi, and makes devices that do not support HomeKit show up in the Apple Home app. This project dates from the Homebridge years, before the native HomeKit firmware of this site. For how the site builds HomeKit devices today, see HomeKit or Matter for your ESP32.
The hardware
| Channel | ESP8266 pin |
|---|---|
| Red | 13 (D7) |
| Green | 12 (D6) |
| Blue | 14 (D5) |
The sketch writes the colours with analogWrite.
The web addresses
The configuration of the plugin uses these addresses of the ESP8266:
| Address | Use |
|---|---|
/on and /off | Switch the light |
/status | Reports whether it is on |
/color and /set/<hex> | Read and set the colour |
/brightness and /light/<value> | Read and set the brightness |
The sketch handles two habits of the Home app: a brightness change is always followed by an on request, and sliding the brightness to zero sends both a brightness and an off request.
Good to know
- The sketch is version 2.0.0. It is under the GNU General Public License, so this article describes it and does not copy the code. The conversion between HSV and RGB is from a StackOverflow answer, as the sketch says.
- The repository is under the GPL-3.0 licence.
- Apple, HomeKit and Homebridge are trademarks of their owners. This project is not made or approved by them.
The project is in the APPLE-HOMEBRIDGE-RGB-LIGHT repository on GitHub.
More projects
Keep building.
Electronics, 3D printing and CNC builds, documented from the first idea to the last screw.
All projects

