Barely-branded mains-voltage electronics


When I moved into my apartment last year, I bought some cheap smart plugs (not an affiliate link, I promise) so that my roommates and I could operate several lights and lamps throughout the apartment by yelling at Alexa at 3am instead of trying to plug things in behind tables and cabinets in the dark.

Based on the “KMC” branding, I assumed they were from KMC Controls, but it turned out to just be 3 random letters chosen for this particular “brand”.

Once they arrived, I searched the Play Store for a matching app. KMC Smart seemed to be what I was looking for, but the developer name was a person’s name, and the contact email was a personal Gmail address with seemingly no relation to the publisher’s name. That didn’t inspire confidence in the privacy or security of this situation.

After looking back at the Amazon listing, I saw that the required app was Smart Life. Wait, that’s not published by KMC! I tapped the publisher’s name (“Tuya Inc.”, if you didn’t open these app listings) and found an app called “Tuya Smart”. All of three of these apps have similar descriptions and the exact same screenshots minus some color scheme differences.

I finally decided to use the Tuya app because it seemed the most “official”. It worked fine to set up the smart plugs and link my Google Home and Amazon Echo accounts for assistant control, but I still never liked it.


One day shortly before the holidays last year, I was at HEB (which is a grocery store chain in Texas, for those who live in other states) and I found a very cheap ($10) “smart” RGB light bulb. I bought it because it was so much cheaper than the Philips Hue lights I had been looking at previously, but I didn’t expect much.

I don’t even remember what branding it had on the outside packaging, but the bulb itself has no branding information on it at all. Again, this doesn’t make me feel good about its reliability.

I remembered setting up my “off-brand” (not even sure which brand they’re ripping off) smart plugs and wondered if the same Tuya app(s) would work with this no-name (I’d trust a light bulb from the Canadian grocery company without a name more) light bulb.

It turns out the Tuya app worked just fine to control the bulb and add it to my Google Home and Amazon Echo accounts, and that’s how things worked the rest of the time I lived in that apartment.

When I moved, I had to connect these devices to a new wireless network using that same Tuya app again. For some reason, the light bulb worked fine in the Tuya app, but would only show as “offline” in the Google Home app, and as a result, my Google Home couldn’t control it. Since I had lost my primary purpose for having a smart light bulb, I tried resetting and reconfiguring the bulb and re-linking my accounts, then I skipped the remaining reasonable steps of making a new account and contacting support (who would I even contact?) and jumped straight into flashing firmware.

Taking control

I’m subscribed to r/HomeAutomation, so I regularly see posts about flashing firmware on smart devices, but I had no experience doing so. From these posts, I had learned that most cheap IoT devices used an ESP8266 microcontroller. I have used the same microcontroller for making my own WiFi-connected projects, so I understood why:

  • WiFi built-in
  • Easy to program using the Arduino IDE (C++), Python, Lua, and probably more by now
  • More powerful than a standard Arduino (now Arduino makes boards for IoT that can compete)
  • Extremely cheap compared to those Arduino boards*

* I understand they’re cheaper because Arduino provides a lot more to the maker community while most ESP8266 manufacturers just benefit from the popularity of Arduino, its software libraries, the maker community’s other contributions to microcontroller development, but I can’t afford to buy Arduino for every project.

For a while, I considered writing my own program for this controller. I assumed I could just open the case, wire the serial pins to a USB/TTL controller, flash my own software to it, and have control of the relay(s) and LED(s) in each device.

Did I ever get around to doing this? Actually, yes! It’s here on GitHub.

In reality, I had a lot more important things to do (read: coursework and employment). Last week, in an inconsequential and subconscious effort to skirt these responsibilities, I did some actual research into how to take these devices out of someone else’s cloud control.

From that research, I discovered a lot more about Tuya devices. Specifically, how to take them away from Tuya.

Thanks to the tuya-convert utility described in that article, I was able to flash the Tasmota open-source firmware onto all of my smart plugs and the light bulb.

The actual flashing process is pretty neat, but my understanding is limited:

  1. The tuya-convert application running on Linux on a laptop broadcasts a WiFi network and starts a local web server that hosts the URLs the device is known to connect to in order to check for updates.
  2. Another device (in my case, an old tablet**) connects and causes the laptop to broadcast…well, broadcast packets.
  3. Factory resetting the device at this point causes it to connect to this WiFi network. I’m not sure why it auto-connects when I had to manually choose a WiFi network using the Tuya app to set it up before, but it does. Eventually. It took quite a few tries. Maybe the special SSID of vtrust-flash?
  4. The device tries to check for an update, but instead the tuya-convert server responds. It then offers a menu of choices, I chose to install Tasmota. It kindly dumped the old firmware and configuration into a backup folder and then flashed the device with Tasmtoa.

** The tablet (Nexus 10) is running Android KitKat. Devices such as my phone that run newer versions refused to stay connected to a WiFi network without internet access and don’t provide an option to disable this behavior without root, which is extremely frustrating.

Now that it’s flashed, it’s configuration time. The newly-flashed Tasmota device broadcasts a WiFi network of its own for only a couple minutes. In this time, I had to connect to it and give it my home network information. This took a few tries because it kept failing to connect and would then require a factory reset (done by holding the button on the plugs, I’m not sure if the light bulb would support Tuya’s switch on-off-on-off-on-off reset). Thinking back to having a similar problem with a Nintendo 3DS years ago, I tried enabling support for wireless-G on my router in addition to wireless-N, and it worked. I’m not sure how they connected before flashing. Maybe this could explain connection issues I had with my own ESP8266 projects?

Losing control

By this point, I had a smart plug running a web server, but it was otherwise useless because Tasmota had no idea how to use its new body. Luckily, I found a template for my exact plug that told me which GPIO pins to use for the button, light, and most importantly, relay.

Tasmota smart plug web UI

Now I have a web interface to turn the plug on and off. As exciting as a “console” button is to someone like me, I’ve still lost my main functionality of the plug: control using voice assistants. Will I ever regain it? Yes Find out in the next post!