Magic Home LED Controller ESPurna’d

Following the bright path (sic) of the Ai-Thinker AiLight / Noduino OpenLight I wrote about a few weeks ago, now it’s turn for one of those devices you purchase but once they arrive they are stored in the TODO box until they eventually come back to life.

The Magic Home LED Controller [Aliexpress, also available from Ebay] is an ESP8266 based single-color RGB(W) LED strip controller. It works with every 5050 LED strip [Aliexpress] out there. Just be careful since even thou some LED strips are waterproof [Aliexpress] this controller is not.

Being able to flash a custom firmware in the controller lets you really own the device. Why? Because:

  1. You are not required to install a proprietary app on you phone to manage it
  2. You are not limited by the options the developers of that app have decided you will need
  3. You can make it interoperate with other devices at home
  4. You, and only you, know when you turn on your lights
  5. And if all the previous points are not enough: it’s so much fun!


Getting the hardware ready

Just like in the Ai Light, flashing any custom firmware into this controller will require you to solder some wires to small copper pads on the board. It’s not hard but it’s one of those things you learn by doing. Just to get you started let me give you some advice that work for me:

  • Use a thin tip
  • Ensure it’s hot before starting, I usually set it to 350 celsius
  • Heat the pads one by one and apply a little blob of tin
  • Remove 1-2 mm of insulator from the cables
  • Tin the cable too
  • Make contact between the pads and the cable tips and apply heat again to reflow the tin for less than one second



Connect the wires to your USB2UART programmer as in the picture above, GND to GDN, TX to RX and RX to TX. Tie IO0 to ground to enter flash mode and power the board through the original jack. If you are going to flash and test several times, remember to disconnect and connect IO0 from ground every time. Booting while IO0 is tied to ground makes it enter into flash mode, otherwise it’s normal boot mode.

Also, once you have an OTA compatible firmware loaded you might want to remove the wires (again, apply some heat) and flash new versions over the aire from then on.

Flashing ESPurna

The ESPurna firmware is released as free open software and can be checked out at my Espurna repository on Bitbucket.

I strongly recommend everyone to use PlatformIO to build and flash their ESP8266 projects (and their Arduino projects, and their STM32 projects,…). You can either use the command line version of PlatformIO or the PlatformIO IDE based on Atom. Either way the builder will take care of all the project dependencies (frameworks, toolkits, libraries,…). You just have to checkout the project from the link above, open the “code” folder with the IDE (or “cd” to it) and run the builder for your target board. In the PlatformIO IDE that’s done pressing F7 and selecting “PlatformIO: Upload (env:led-controller-debug)”.

Using the command line this translates into:

git clone http://bitbucket.org/xoseperez/espurna
cd espurna/code
pio run -e led-controller-debug -t upload

Upon reboot the blue LED in the board will flash every half second and it will create an access point named something like “LED_CONTROLLER_ABCDEF”, connect to it using “fibonacci” as password and then open a browser pointing to It will ask you for authentication. Use user “admin” and pass “fibonacci” again.

The first time you will have to change the default password and login again. Then I recommend you to change the hostname (say you will call it “ledstrip”), and the wifi credentials for your home network. Then press reconnect and it will connect to your WiFi using the credentials you just provided.

When connected to a WiFi the builtin led flashes briefly every five seconds. Then you can just browse to “http://ledstrip.local” (“ledstrip” is the hostname you set in the previous step) to go back to the web interface.


Using ESPurna

The ESPurna web interface lets you control the status of the lights (on/off) and the color, but it also lets you configure the access to other services like MQTT, the REST API, Home Assistant,…

If you have a local MQTT broker you can connect ESPurna to it (check the MQTT tab in the menu) and start changing color and status remotely right away:

# turns on the light
mosquitto_pub -t /home/ledstrip/relay/0 -m 1

# turns off the light
mosquitto_pub -t /home/ledstrip/relay/0 -m 0

# toggles the light 
mosquitto_pub -t /home/ledstrip/relay/0 -m 2

# Changes color to red using #RRGGBB notation
mosquitto_pub -t /home/ledstrip/color -m "#FF0000"

# Changes color to red using R,G,B notation (only in dev branch as of this writing)
mosquitto_pub -t /home/ledstrip/color -m "255,0,0"

# Changes color using temperature (only in dev branch as of this writing)
mosquitto_pub -t /home/ledstrip/color -m "6500K"

Using the REST API is a little more involved since you have to use the APIKEY provided in the web interface for every request, but still it’s really simple and something you can test from the browser (it’s actually REST-ish since it accepts GET requests to change statuses).

# URL to turn light on

# URL to turn light off

# URL to turn toogle light

# URL to change color to RED using #RRGGBB notation (notice the '#' is encoded as '%23')

# URL to change color to RED using R,G,B notation (only in dev branch as of this writing),0,0

# URL to change color using temperature (only in dev branch as of this writing)

Finally you can also use Home Assistant to change the color and status of the light using the MQTT Light component. The plan is to support MQTT JSON Light component also, to change status, color, brightness, temperature and adding effects to the lights. Soon!


Home Assistant widget to change status and color of the LED strip

CC BY-SA 4.0 Magic Home LED Controller ESPurna’d by Tinkerman is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

19 thoughts on “Magic Home LED Controller ESPurna’d

    1. Xose Pérez Post author

      Sure, a minor change is required to drive the W line together with the RGB lines. Right now the code uses the W only when red, green and blue values are the same.

    1. Xose Pérez Post author

      In the dev branch you can provide a single 8 bit value as color (via MQTT or REST API) this value will control the PWM GPIO defined for the W line.

    1. Xose Pérez Post author

      I know the product and I guess it won’t be hard to use it with ESPurna. If you happen to have one you might try to find out what GPIOs drive the power mosfet for the RGBW lines.

        1. Xose Pérez Post author

          A first approach with only one white channel (add these lines to the code/espurna/config/hardware.h file just before the “Unknown hardware” section and build the project with -DH801 or adding “#define H801” int eh arduino.h file.

          // -----------------------------------------------------------------------------
          // HUACANXING H801
          // -----------------------------------------------------------------------------
          #elif defined(H801)
              #define MANUFACTURER        "HUACANXING"
              #define DEVICE              "H801"
              #define LED1_PIN            5
              #define LED1_PIN_INVERSE    1
              #define LED2_PIN            2
              #define LED2_PIN_INVERSE    1
              #define RELAY_PROVIDER      RELAY_PROVIDER_LIGHT
              #define LIGHT_PROVIDER      LIGHT_PROVIDER_RGBW
              #undef RGBW_INVERSE_LOGIC
              #undef RGBW_RED_PIN
              #undef RGBW_GREEN_PIN
              #undef RGBW_BLUE_PIN
              #undef RGBW_WHITE_PIN
              #define RGBW_INVERSE_LOGIC      0
              #define RGBW_RED_PIN            15
              #define RGBW_GREEN_PIN          13
              #define RGBW_BLUE_PIN           12
              #define RGBW_WHITE_PIN          14
              //#define RGBW_WHITE_PIN          4 <= warm white
          1. Bryan Mayland

            I see that the H801 support is in git now, however looking at hardware.h I see setSetting(“lightProvider”, LIGHT_PROVIDER_RGB2W), but there is no provider define named LIGHT_PROVIDER_RGB2W.

            And now it is in 1.8.0 release. It compiles but I am not sure it will work properly.

          2. Xose Pérez Post author

            There is a LIGHT_PROVIDER_RGB2W defined in the general.h file. But I reckon there are still some features missing, specially dimming (or one channel dimming). If you use an RGB strip with the H801 my suggestion is to change the provider to LIGHT_PROVIDER_RGB, otherwise it won’t handle whites correctly.

  1. Pingback: A closer look at the H801 LED WiFi Controller - Tinkerman

  2. Zeph

    Is it possible to decode the IR input (for the IR remote versions)?

    Optimal would be to do both:
    1) allow the IR to modify the light output (option to disable this)
    2) report the IR code via MQTT (if enabled)
    So it could have local control (good for speed) and/or allow the central controller to decide what to do with IR codes. Of course, if local IR control is allowed, it would be good to have a way that the central controller could know the current mode/levels so it could update any home control displays.

    1. Xose Pérez Post author

      It should be possible. The version I have does not have and IR receiver so I could implement that functionality. Help is welcome.

  3. Sheldon Williamson

    Hello is there any way to change the output voltage with the firmware…. right now it puts out 12v… could you male it put out 3.7v?

    1. Xose Pérez Post author

      The output voltage will be the input voltage you provide since the four channels are driven by power mosfets. But, there is a minimum for the microcontroller to work. Assuming the regulator is an ASM1117-3.3 with a typical voltage dropout of 1.1V you will need around 4.4V to power it…

    1. Xose Pérez Post author

      Once you get ESPurna in it you can control it from your Echo or Dot. But atm, it won’t work with a DIY device and the Alexa SDK.

    1. Xose Pérez Post author

      But I’m not sure about the pitch issue. They are 100mil. Most of the 5050 strips I’ve used have this same pitch…


Leave a Reply (all comments are moderated, be patient)