Ai-Light RGBW LED Wi-Fi Light Bulbs with MQTT (ESP8266)

Ai Lights

I already had most of my lights converted to RGBW but couldn’t resist getting one of these when I heard they contained the ESP8266 and could be reprogrammed, I eventually ended up with three after buying a second to verify the first was not at fault and then a third to check it was the same product from a different source!

Inside is an ESP8266EX with 32Mbit flash and a MY9291 LED driver controlling 8 high power white LEDs, 6 red LEDs, 4 green LEDs and 4 blue LEDs.

The eBay seller I bought the first two from is no longer active but this where I got the third one, a bargain at only £8.60/11USD

You should know by now that I wasn’t interested in using the default firmware and software, intending to load something MQTT capable instead but in retrospect I probably should have tested it using the default first as it would have saved some bother later on. Flashing the latest (at the time very new) AI-Light compatible version of ESPurna was easy enough but although the web interface was working but I couldn’t get the LEDs to light. Suspecting a hardware problem I ordered a second bulb but while waiting for that to arrive I was contacted by someone else who had the same problem so at least that confirmed it wasn’t just me. I delved back into it and tried some previous versions of ESPurna and eventually found one that worked! Happy to say the bugs appear to have been worked out and the latest versions of ESPurna are working without a problem and it’s a really nice firmware.

To get into the bulb for reprogramming you need to pop the translucent cap off the top, it’s not glued or fastened in any way, just a tight fit. I found the easiest way is just to grab the base one hand, the cap in another and pull rather than try and prise it off. The cap isn’t as fragile/brittle as it might at first seem.

With the cap popped off we can see the ESP8266 chip

Then look at the board for the connections for VCC, GND, RX, TX and IO0, you will need to tack some wires on for programming, they are quite small but my approach to this sort of things is to add a little bit of solder to each pad, tin the wires and it then it only takes a quick dab with the soldering iron to attach the wires.

These are the connections we need
Wires tacked on for initial programming

Uploading ESPurna

This is very easy if you use PlatformIO. Just clone the Bitbucket repository for ESPurna and connect the AiLight up to your 3.3V USB Serial adapter, making sure the GPIO0 connection is grounded before you power up the bulb.

Fire up the PlatformIO IDE and load the ESPurna code directory then upload via “Run other target…” and select “Upload (env:ai-light-debug)”

After the upload has finished power cycle the bulb and then upload the SPIFFS image (which contains the files for the web interface) via “Run other target…” and select “Upload SPIFFS image (env:ai-light-debug)”

Now disconnect the GPIO0 to ground connection and power cycle the bulb again.

Now look for a Wi-Fi network of the form AI_LIGHT_xxxxxx where xxxxxx is the unique “Chip ID” of your bulb (the last 3 bytes of the MAC address).

Connect to that network and open http://192.168.4.1 in your browser.

Login with the user name “admin” and default password of “fibonacci”.

On logging in for the first time you will be forced to change the admin password and then log back in with the new password.

The ESPurna Web Interface

Go to the “WIFI” option, Add Network and enter the SSID and password for your network and optionally fixed IP, DNS etc. Press the hamburger icon to reopen the menu, select update and then reset.

The bulb will now reboot and log on to your local network where you can connect to it via IP or by using the chip ID as a hostname depending on your setup.

You can configure MQTT and other things such as Alexa integration (using Fauxmo to emulate a Belkin WeMo) via the web interface and control the bulb directly using the on/off switch and colour picker. You can also set what you want the bulb to do when power is turned off and back on again, choose from on, off, the same as it was or toggle.

ESPurna Colour Picker

OTA Updates

Probably more so than any of the other devices I’ve looked at OTA (Over The Air) updates are vital for these as you don’t want to be resoldering those wires every time you want to update.  Fortunately this is easy with ESPurna.

First of all open the platformio.ini file an look for the [env:ai-light-debug-ota] section

Below that change the upload_port to your bulb’s IP address and the password to the one you setup when first connecting to the web interface:

upload_port = “192.168.4.1”
upload_flags = –auth=fibonacci –port 8266

Then use the “Upload (env:ai-light-debug-ota)” and “Upload SPIFFS image (env:ai-light-debug-ota)” options under “Run other target…”

MQTT Usage

Assuming the Root MQTT Topic is configured in the web interface as “lights/AI_LIGHT_xxxxxx” you can turn the bulb on or off by sending a payload of “1” or “0” to the topic “lights/AI_LIGHT_xxxxxx/relay/0” or toggle the status by sending a payload of “2”

To change the colour send an RGB value, eg.”#228b22″ to “lights/AI_LIGHT_xxxxxx/color”

The current on/off Status can be obtained from the topic: “lights/AI_LIGHT_xxxxxx/relay/0” and the current colour from “lights/AI_LIGHT_xxxxxx/color ”

The bulb will also report various information on the following topics every 5 minutes:

Firware name: /app
Firware version: /version
Hostname: /hostname
IP Address: /ip
MAC Address: /mac
RSSI (Signal strength): /rssi
Uptime in seconds: /uptime
Free Heap: /freeheap
Power to the ESP8266 in millivolts: /vcc
MQTT Connected: /status (1 when connected, 0 when disconnected via MQTT will)

Node-RED

Usage with Node-RED is straightforward, we can just send the output from a colour picker set to output hex straight to the topic for the bulbs colour:

Node-RED Flow
Node-RED Colour Picker

Here is the code to copy & paste into Node-RED:

[{"id":"d074f6b2.cb8ed8","type":"mqtt out","z":"b667b1f1.bf821","name":"","topic":"","qos":"","retain":"","broker":"32a2fac0.cd5d06","x":730,"y":3160,"wires":[]},{"id":"10952819.891478","type":"ui_colour_picker","z":"b667b1f1.bf821","name":"","label":"","group":"e80e9831.cad848","format":"hex","outformat":"string","showSwatch":false,"showPicker":true,"showValue":false,"showAlpha":false,"order":2,"width":"4","height":"2","passthru":true,"topic":"lights/AI_LIGHT_218FB2/color","x":490,"y":3180,"wires":[["d074f6b2.cb8ed8"]]},{"id":"17c17342.7c5efd","type":"ui_switch","z":"b667b1f1.bf821","name":"","label":"AI_LIGHT_218FB2","group":"e80e9831.cad848","order":1,"width":0,"height":0,"passthru":true,"topic":"lights/AI_LIGHT_218FB2/relay/0","style":"","onvalue":"1","onvalueType":"str","onicon":"","oncolor":"","offvalue":"0","offvalueType":"str","officon":"","offcolor":"","x":510,"y":3140,"wires":[["d074f6b2.cb8ed8"]]},{"id":"32a2fac0.cd5d06","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"15","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""},{"id":"e80e9831.cad848","type":"ui_group","z":"","name":"AiLights","tab":"978d3f00.2ffa4","order":3,"disp":true,"width":"6"},{"id":"978d3f00.2ffa4","type":"ui_tab","z":"","name":"Test","icon":"dashboard","order":4}]

 

2 thoughts on “Ai-Light RGBW LED Wi-Fi Light Bulbs with MQTT (ESP8266)

  1. Hello! I have tried to do the same, but am having some issues with the bulb not connecting very successfully to wifi. It seems to be incredibly flaky, almost as if its connecting, disconnecting, connecting etc.

    Did you have any issues at all with regard to WiFi?

    Thanks,

    Gareth

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.