Tasmota on ESP8266 RGBW Fcmila Smart Bulb

install open source firmware on cheap rgbw smart bulb

23-10-2020 - 7 minutes, 6 seconds -

Despite Amazon's tendency to gouge customers when it comes to "smart" items, I recently picked up 4 of the Fcmila branded smart RGB bulbs for a pretty amazing deal, cheaper than anywhere else, domestic or overseas. I saw they changed the price the next day after I placed my order, pretty much doubling it. When I received the package, there were only 2 bulbs inside. I emailed the retailer and asked where is the rest of my order? They emailed back and tried to weasel out of it by offering me 50% of my money back in exchange for dropping it. I said no thanks, just send me the rest of my order. They begrudgingly complied and hopefully the remaining two bulbs are on the way.

These are branded as Fcmila but this particular bulb is manufactured by Tuya and rebranded by untold numbers of retailers. All Tuya smart devices use either the "Smart Life" or "Tuya Smart" mobile apps for connection and configuration. But who wants to give away all of their data to some corporation when you don't have to, right? Not only that, but Tuya has lied in the past about their cloud solution's "military grade security".

To start off with, let me say there's a much easier way to flash firmware to Tuya devices. Hacker kueblc has created a great open-source tool called tuya-convert to flash the firmware of your choice over-the-air without even having to open up the device. But where is the fun in that? Plus I really want to see what's inside this thing anyways.

At minimum you will need jumpers, a computer, a soldering iron, and a USB UART adapter that's capable of 3.3 volts as well as esptool and the tasmota firmware. Also you can reference my previous writeup for info on setting up the USB adapter.

Remove the plastic dome by using a twisting and pulling motion at the same time, being careful not to use too much pressure or you will break it. It's not threaded, it's just a compression fit. Now we can see the board itself.

This might be a familiar sight if you've ever looked inside a smart device. There's the wifi antenna in the middle, with several chips on the board. There's the ESP8266 chip on the left with a smudge of adhesive on it, a SLM211A LED driver on the right that uses PWM directly from the MCU, and what looks to be some kind of flash memory chip on the bottom. Let's put it under the glass so we can see the pinout.

I've labeled the relevant pins to make it clearer. These are the pins we will need to solder the jumpers to to install the firmware. We've also got 8 white LED chips and 4 RGB chips.

I'm really interested in what's on the other side. I used a heat gun on low to heat up the aluminum base and pry off the board. Do not put the gun on the board itself. The base I assume acts as a heatsink. I've seen some manufacturers use ceramic, others aluminum.

Now we can snip the wires and pull the board out and see what's hiding underneath. Could be pins for the pinout to attach leads to so I won't have to solder.

Surprise, it's nothing. Just solder points for the leads and the bottom of the wifi antenna. Oh well. Let's go ahead and get the pins soldered.

We've got the pins soldered and connected to the USB adapter. Remember that RX goes to TX and vice versa, and power is 3.3v, not 5v. There's one more step to go through before we can switch the board into programming mode. We have to solder a jumper from the ground to GPIO0.

You can leave this jumper on throughout the flashing process. Now let's connect the USB and see what's going on here. Refer to my previous Tasmota on Sonoff article for installing esptool and configuration. First let's issue a simple command to make sure we're connected:

$ sudo python3 esptool.py --port /dev/ttyUSB0 read_mac

Output:

esptool.py v2.8 Serial port /dev/ttyUSB0 Connecting.... Detecting chip type... ESP8266 Chip is ESP8266EX Features: WiFi Crystal is 26MHz MAC: bc:dd:c2:2e:9d:07 Uploading stub... Running stub... Stub running... MAC: bc:dd:c2:2e:9d:07 Hard resetting via RTS pin...

We're connected and given the MAC address of the device. After each command you will have to fully unplug the USB adapter and plug it back in before you can enter another command. Next let's see the flash manufacturer code and the flash memory size.

$ sudo python3 esptool.py --port /dev/ttyUSB0 flash_id

Output:

esptool.py v2.8 Serial port /dev/ttyUSB0 Connecting.... Detecting chip type... ESP8266 Chip is ESP8266EX Features: WiFi Crystal is 26MHz MAC: bc:dd:c2:2e:9d:07 Uploading stub... Running stub... Stub running... Manufacturer: c8 Device: 4014 Detected flash size: 1MB Hard resetting via RTS pin..

You can refer to this table to match the ID numbers to manufacturer and device. In our case, going by the table the manufacturer is GIGADEVICE (c8) and the flash memory model number (4014) is GIGADEVICE_GD25Q80.

None of this is necessary, it's just a demonstration of some of the neat features of esptool. For a full list you can esptool.py -h.

Now let's make a backup of the existing firmware in case something goes wrong.

sudo python3 esptool.py --port /dev/ttyUSB0 read_flash 0x00000 0x100000 fwbackup.bin

Output:

esptool.py v2.8 Serial port /dev/ttyUSB0 Connecting.... Detecting chip type... ESP8266 Chip is ESP8266EX Features: WiFi Crystal is 26MHz MAC: bc:dd:c2:2e:9d:07 Uploading stub... Running stub... Stub running... 1048576 (100 %) 1048576 (100 %) Read 1048576 bytes at 0x0 in 94.7 seconds (88.5 kbit/s)... Hard resetting via RTS pin...

Erase the current flash.

$ sudo python3 esptool.py --port /dev/ttyUSB0 erase_flash

Output:

esptool.py v2.8 Serial port /dev/ttyUSB0 Connecting.... Detecting chip type... ESP8266 Chip is ESP8266EX Features: WiFi Crystal is 26MHz MAC: bc:dd:c2:2e:9d:07 Uploading stub... Running stub... Stub running... Erasing flash (this may take a while)... Chip erase completed successfully in 1.6s Hard resetting via RTS pin...

Write the tasmota flash to the device.

$ sudo python3 esptool.py --port /dev/ttyUSB0 write_flash -fs 1MB -fm dout 0x0 tasmota.bin

Output:

esptool.py v2.8 Serial port /dev/ttyUSB0 Connecting.... Detecting chip type... ESP8266 Chip is ESP8266EX Features: WiFi Crystal is 26MHz MAC: bc:dd:c2:2e:9d:07 Uploading stub... Running stub... Stub running... Configuring flash size... Compressed 591504 bytes to 410198... Wrote 591504 bytes (410198 compressed) at 0x00000000 in 36.4 seconds (effective 130.0 kbit/s)... Hash of data verified.

Leaving... Hard resetting via RTS pin...

And you're done. Let's put everything back together and test this baby out. You may have to switch the device into AP mode by switching the light switch 3 times before the tasmota access point becomes available from your wifi device if it does not appear immediately. Once you see it, connect to it by using the instructions from my previous writeup and configure your wifi credentials accordingly. Enter the local address of the bulb in your browser and go to Configuration>Configure Module and enter the following configuration:

Save that configuration and the device will restart on its own. You will next be presented with a screen like the following:

You can adjust the sliders and see the desired colors emitting from the bulb. You may notice though that you cannot get a solid bright white from the tasmota interface though. This is where Home Assistant integration comes in. Configuring Home Assistant is beyond the scope of this article but a few screen shots are in order. After integration, within your Home Assistant dashboard you will see a lamp symbol.

You can click on the symbol to turn the light on and off and use the slider to control the brightness. There is also an indicator telling you the wifi strength. Use the three dot menu to access the settings.

Here you can access the RGB settings as well as setup effects for pure white, warm white, cool white, brightness, etc. Also there is a timeline at the top showing when the bulb was interacted with.

The real fun begins once you start to configure automations with your light. Some things you can do is adjust color settings based on time of day, strobing effects, RGB fades, and motion detection based on your sensor setup. Home assistant also supports voice integration if you just want to talk to the bulb and tell it to do different things based on your configurations and scene settings. The options are limitless. One thing's for sure though, once you've taken control of your smart device, you can truly call it your own.