AiLight – A hackable RGBW light bulb

Some weeks ago a tweet by Manolis Nikiforakis (@niki511) with the #ESP8266 hashtag drew my attention. Manolis had just received a “smart lamp” branded by Ai-Thinker, the AiLight. Yes, the same Ai-Thinker that has sold millions of ESP8266 based modules. Chances were it had an ESP8266 microcontroller inside. Too good not to buy one and take a look at the inside.

Manolis shared the link where he bought his at Ebay for a bit more than USD 10 plus shipping. Unfortunately it’s out of stock there and there are amazingly few other places where you can buy it. I only found the same product with prices around USD 15-18 at Ebay as ESP8266 Smart Home Wifi RGB LED Light [Ebay] or Noduino Open Light LED Smart Bulb [Ebay] also in a cheaper pack of two light bulbs [Ebay]. You can also find it at Aliexpress sold as “DIY Wifi LED Bulb E27 5W AC110-240V lampada LED Dimmable Bulb Lamp Remote Control Led Spot Light for iPhone Android Phones” [Aliexpress]. Don’t you love those seo-ugly names?

I actually bought two because you never know. And they arrived last Thursday. It took me less that 1 minute to open one of the boxes, pop out the cap and take a look at the inside just to see what I already knew. Time to play 🙂

Some pics to start

I’m not good or fond of “unboxings” but since it’s a hard to find product I might add here some pics of the boxing and the light bulb.

Each light bulb comes in a light brown box (149x105x67mm if you ask) labelled “WiFi Light” on both faces and with a light bulb pic and a mysterious empty square (?). Looks like a place to mark the variation (they sell them in silver and gold finish), but the sticker with the color is actually on the other side of the box…

There is a label on the bottom of the box with the legend “M1636_SVWIFI” and the usual “Made in China”. I guess SV means “silver” so the model would be “M1636” (I actually found some of the references above looking for this model number).


Inside the box there is a simple two fold paper with Chinese instructions to download the app to control the device on your cellphone. Two things to note: first the funny guy pictured in the paper. I’m not much into Chinese culture but he looks like a 60yo nerd. And then the baseline “If you are not an engineer”. What does it mean? Maybe they meant it’s a product for everybody, you don’t need to be an engineer. Or maybe it’s a “use the provided app unless you plan to hack it”?



And finally the light bulb it’s a copy of the Philips Hue [Amazon] without the logo, with WiFi instead of Zigbee and at a fraction of the price.



Taking a closer look

The bulb cap is not glued, it just fits in. Just pull with a bit of strength and it will pop out. After removing it you have full access to the PCB.


The PCB it’s actually 2 PCBs. The outer one has 8 high power white LEDs, 6 red LEDs, and 4 blue and 4 green LEDs. The inner PCB holds the logic circuit with an ESP8266EX microcontroller and a Winbond 25Q80BVSIG 1MByte flash memory chip. These are the usuals suspects.  There is also a SOT23-6 package labelled ADJG and a 20 pin IC labelled MY9291QD.


There are also 5 pads labelled 3V3, GND, RX, TX and IO0. Too good to be true. They were probably used at the factory to flash the stock firmware on the controller using a gig with pogo pins. Anyway it looks easy to solder some thin wires and upload custom firmware.

The only doubt left is how to control the LEDs. Googling the MY9291 chip throws one perfect match: the My-Semi MY9291 LED driver. Bingo. But the datasheet lacks any information about how to use it…

Digging on the Internet

Aside from the product in Ebay or Aliexpress there is little information about these light bulbs in the Internet. But with the information I already had I dug a little bit on the Internet and found two interesting pages.

FCC aplication

On one hand I there is the FCC application by Ai-Thinker dated November 9th, 2016. In the application, aside from some interesting documentation like the cellphone app “Tuya Smart” user manual, there are plenty of images from the inside of the product.


Picture from the FCC application

As you can see in the pictures below the PCB is glued and behind it there is a small AC/DC transformer. The bulb itself is 116mm long and 62mm diameter.


Picture from the FCC application


Picture from the FCC application


Picture from the FCC application

Noduino OpenLight

On the other hand, going down the path of the MY9291 reference you quickly found the Noduino OpenLight wiki page at JacksLab, by Jack Tan, alias comcat, the guy behind the Noduino project. In that page you have lots of information about the light bulb including sample code and the schematics of (part of) the circuitry by Jack.


Apparently Jack Tan or the Noduino team is behind this product somehow. Anyone knows what relation is there between Noduino and Ai-Thinker? In the Noduino OpenLight page there are pictures of a virtually identical light bulb in the shape but also with the same PCB. But not only that.

You have an precise description of the LED PCB and reference to the MY9291 LED driver by Taiwan Mingyang (hence MY-Semi). It also confirms that the AC/DC transformer outputs 12V at 1A max. And describes two different step-down ICs. The MP1470 and the MP2359, both by MPS. The MP1470 has the ADJ mark.

But most interesting, the page includes a section on how to compile your own firmware for the OpenLight based on the Noduino SDK.

A library and a little bit of code

I checked out the Noduino SDK and there it was: a C driver for the MY9291. That’s everything I needed. By the way, I noticed the Noduino SDK includes my HLW8012 library (but not the most up-to-date version).

The driver is licensed GPLv3 and copyrighted to Maike Labs, Maike Labs is icamgo and icamgo is Noduino. You can use the driver as is but I took some time to encapsulate it in a library with some helper methods to manage the color and state of the LEDs. I have tested it with the ESP8285 in the AiLight but should work on ATmega328 or other AVR chips.

The MY9291 library for Arduino ESP8266 is released as free open software and can be checked out at my my9291 repository on Github.

Let me show you a simple example on how to set red LED on at 100% duty cycle (MY9291_COMMAND_DEFAULT defines 8-bit color depth so 255 means 100%):

#include <my9291.h>

#define MY9291_DI_PIN   13
#define MY9291_DCKI_PIN 15

my9291 _my9291 = my9291(

void setup() {
    _my9291.setColor((my9291_color_t) { 255, 0, 0, 0 });

void loop() {}

Flashing it

It might look hard to solder those small pads in the beginning but it’s actually really simple. Get a 5 wire cable and remove 1-2mm of insulation from the wires, tin them a bit. Apply a hot wire on the pads and leave a small drop of tin on them too. Then just touch each wire with a pad and heat them together for a fraction of a second.


Connect the wires to you FTDI (or alike) board. TX to RX and RX to TX. Connect GND and IO0 to ground and finally 3V3. Once you plug your programmer to the computer the board will boot into flash mode. While you are flashing it you can remove the IO0 connection. Upon reboot it will enter normal mode and you should see the debug messages in the screen.


And of course it has been ESPurn’d. Version 1.6.7 of the ESPurna firmware supports the Ai-Thinker AiLight / Noduino OpenLight. You can turn on/off the light bulb and select the color from the web interface or you can do both things via MQTT from Node-RED for instance.


CC BY-SA 4.0 AiLight – A hackable RGBW light bulb by Tinkerman is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

46 thoughts on “AiLight – A hackable RGBW light bulb

  1. Jeff Eberl

    Awesome. How well does the light work (not from a data or programming perspective, but from a light perspective)?

    1. Xose Pérez Post author

      White LEDs are very bright and cold. I tested it in a small room where I had an incandescent 60W bulb and the AiLight looked waaay brigther. The example I added in the library is the rainbow transition taken from the NeoPixel library by Adafruit. The colors are solid except for the border between the metallic case and the cap where there are some color waves. Transitions are very smooth.

    1. Xose Pérez Post author


      Didn’t know about those LED light bulbs. They look too cheap to have any brains inside. I can’t tell.

  2. Mark

    How do the bulbs fallback if Wifi connection is lost? Do they still operate without wifi?

    Can you add more animations inside? 😀

    1. Xose Pérez Post author

      If the wifi connection is lost the bulb will keep the color and status (on/off). If you have a physical switch to turn it off, if you turn it on again it will show the previous status and color as well. So it pretty much works as a normal bulb. What I do when the light is after a switch is to set the boot mode to “always on”. This way you can switch it on and off like a normal bulb although you might need to toggle the switch twice if the bulb is off by software.

      And yes. I will definitely add animations 🙂

      1. Mark

        Awesome, you covered all the aspects! You know what would be a cool addon for these bulbs…Music source connected to msgeq7 connected to an esp/rpi sending data via mqtt to the bulbs for music sync. (if not too big latency…), standalone led strips work like this for music (its an all in one package) but here in the case of bulbs data would need to be transffered.

        1. Xose Pérez Post author

          Once you start playing with them you can do all sorts of fun stuff. But right now I’m thinking of something more “usual”, like the rainbow mode. “Disco” or notifications, like notify you when you cellphone is ringing.

          1. Blair Thompson

            Doing that at the moment using tasker and openhab. Tasker sends a GET request to the HA server when I miss a call… My SonoffSC glows red to make me aware.

  3. Pingback: AI Light ESP8266 based WiFi RGB Light Bulb Supports MQTT via ESPurna Open Source Firmware

    1. Xose Pérez Post author

      Not at the moment. Would be a nice addition if anyone wants to work on that…

      1. Maciej

        Where can I download the ESPurna bin file for the bulb? I’ve soldered the wires, had it flashed with the generic sonoff firmware (just to get the OTA update possibility) but now I’m stuck as I don’t know how to build the image. HELP….. 🙁

        1. Xose Pérez Post author

          What do you mean by “generic sonoff firmware”? If it uses ArduinoOTA you can just build ESPurna for the AiLight and flash it over OTA from the Arduino IDE or using PlatformIO. Currently I’m not providing images of the firmware. That will change soon.

          1. Maciej

            But that’s my dilemma. How do I build it? Totally new here to some of these things (geek in some parts but a noob in others)

          2. Xose Pérez Post author

            If you are using Arduino add a “`#define AI_LIGHT“` line to your “`espurna/code/config/arduino.h“` file (it’s missing in 1.6.X versions). the rebuild the project and flash it.

          3. Michel Clavette

            Providing firmware images (like available for ESP Easy) would be great!

            I just got 5 bulbs from AliExpress and two had a processor marked KK2015 instead of the ESP8266EX. The PCBs seem identical. I can send you pictures if you want.

            I’ll try to flash the KK2015 with the same firmware as a ESP8266 and see what comes out.

            Kind regards,


          4. Xose Pérez Post author

            Don’t know about that KK5015 controller… images will be great and any other info you have about them too..

  4. Pingback: CNXSoft — Новости Андроид приставок и встраиваемых систем » $12 AI Light на базе ESP8266 WiFi, RGB лампочка поддерживающая MQTT через Open Source прошивку ESPurna

  5. Fabien MARCHEWKA

    Just recieve my bulbs today. I will try Espruino this week. Than you Jose for your work and your blog !

    1. Fabien MARCHEWKA

      Works fine with your firmware. Not very easy to solder on pads (especially if you doesn’t have good soldering station, i think …). Can be use near bed but only 600 lumens. Not enough for many application. Milight 9W are way better and you can buy them in GU10 or E27 (but not ESP based !)

  6. Christian

    Thank you very much for all your effort and time. I defined AI_LIGHT in the Arduino IDE. So the general Hardware-Platform Check works fine. But after that the compilation runs in an error.

    relay:448: error: #elif with no expression
    #elif AI_LIGHT
    exit status 1
    #elif with no expression

    Then I edited the relay.ino so that just the following expression is included

    _relays.push_back((relay_t) {0, 0});

    Compiling is fine now, but I can’t turn the light on in the ESPurna WebUI.

    Can you help? Would really be appreciated.

    Thank you

  7. Christian

    Thanks. At this point I didn’t remove any code. Take a look at the source of relay.ino (line 448).

    #elif AI_LIGHT

    and not

    #elif defined(AI_LIGHT)

    Can it be, that this leads to the error, that I am not able to switch on the light?

    Stupid me has already removed the soldered cables 🙁

    But I could try your OTA through the Arduino IDE.

    Do you maybe have an idea how I could check if I am into a hardware or software (hopefully) based error?

    1. Xose Pérez Post author

      Yes, that was a bug in the code and it’s fixes with 1.7.1. Try building the last version and flash it OTA.

  8. Sacha Telgenhof

    Thanks for the great article! I have the same lights and managed to flash them as you explained. Just was wondering if you managed to upload firmware through OTA. I continuously get the error message “No response from device”

    To rule out other factors (firewall, etc.) I also tried another ESP8266 device and was able to upload the BasicOTA example sketch via OTA. Also tried different PC/Laptops and all the same result.

    Cheers! Sacha

      1. Dovydas Gulbinas

        Hi I wanted to build AI-LIGHT bin from source, but I stumbled upon this irregularity:
        platform = espressif8266
        framework = arduino
        board = esp8285
        The board seems to be set at esp8285 is this right?

        Also I want to ask you what board should i choose because my AI-LIGHT has another flash chip (Paragon_SPI_NOR_PN25F32) which according to datasheet is 4MB

        1. Xose Pérez Post author

          The main difference (appart from the flash size) is the flash mode. Try using an esp12e board with DIO and if it fails change to QIO.

  9. Dave Myers

    Hi Xose,

    Thanks again for your work on this firmware. I’ve used in past on ecoPlug and slampher. Now trying to setup an AI-LIGHT with HomeAssistant. Looks like it will require using HomeAssistant’s MQTT Template module to convert from r,g,b decimal values provided by HomeAssistant to #hex strings expected by espurna. Wondering if you have a working example of using HomeAssistant with espurna for color control.


    1. Xose Pérez Post author

      The development branch of ESPurna supports Home Assistant color coding, please note it’s still under test but you could give it a try and provide feedback.

  10. JF

    I’ve just received an order with 2 bulbs and a USB-TTL adapter. I’ll flash them as soon as possible, and integrate them with Home-Assistant! Thanks for your work and this very useful article!

  11. SwiCago

    For anyone that wants to re-flash, solder wires and first get an OTA firmware on it. I decided to solder pins to the pads and was able to flash a few times, but did not get an OTA on it before the TX pad broke off. I pulled straight up on the connector and the pad with the trace came right off the board. 🙁 Oh well, live and learn. At least I have a firmware on it that lets me do something with it LOL, but not what I wanted to end with. I’ll have to solder some fine wire to the esp itself to re-flash.

    1. Xose Pérez Post author

      Definetely a good advice. Flash someting OTA-capable and double check you are not breaking it with any new feature…

  12. E

    Very interesting, I was digging through your code to get some idea on what payload the MQTT in Espurna is expecting for this lamp, but could not figure it out. My application sends HSB, as 3 comma separated values in one payload. Is that something ESPurna can work with?

    1. Xose Pérez Post author

      Currenty ESPurna supports CSS color (#RRGGBB) comma separated RGB values (RRR,GGG,BBB) or white only value (WWW) and temperature values (####K). It does not support HSB in any way right now.

    1. Xose Pérez Post author

      You mean a brigther ESP8266 based bulb? I don’t know of any other with a higher power rate.

  13. Brandon St.Rose

    I’m now coming across this article, i recently bought 2 bulbs and 2 outlets and while they work with my amazon echo dot , i can’t get openhab or any other app (yeti or yonomi) to see them only the tuya you have any tutorials on achieving this?

    1. Xose Pérez Post author

      The WeMo emulation is proved to work only with original Alexa devices (Echo or Dot). Any other device will probably not work. Echo or Dot implementation of the WeMo protocol is somewhat loosy and does not check the finerprint of the device or any other security check, that’s why it’s easily spoofed.

  14. Lennyz1988

    Apparently I bought a clone from this product. It appears to be exactly the same from the outside. Only I cannot get the MY9291 library to switch the leds on.

    I can flash just fine. I can upload any sketch I want but I cannot get the leds to turn on. Do you have any idea what I could try?

    A picture from the inside:


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

This site uses Akismet to reduce spam. Learn how your comment data is processed.