2023-02-18 20:37

Power Plugs

Research

zigbee logo wifi logo

source: https://au.element14.com/wcsstore/ExtendedSitesCatalogAssetStore/cms/asset/images/common/campaign/internet_of_things/zigbee-logo.jpg

source: https://media.istockphoto.com/vectors/wifi-logo-zone-location-stock-vector-vector-id926493652?k=6&m=926493652&s=170667a&w=0&h=GW4qZ33sNCEN22QpVtAtYHkLzVftYgy6S8GpzwKhmSM=

There were two main platforms I considered for my research: ZigBee and WiFi based. ZigBee has the advantage that it uses a dedicated radio channel and mesh communication, though it needs an additional gateway device. WiFi, however, can be used out of the box with any default wifi access point.

Out of lazyness I chose WiFi and scanned the shops for appropriate devices. I found these Plugs on Aliexpress for 109€ for 10 pieces (10,90€ per piece) with Tuya as a service provider. [link]

Gosund SP1

source: https://templates.blakadder.com/gosund_SP1.html

Tuya is a proprietary, cloud based IoT development platform based in China. You have to create an account and configure your smart devices which then send their telemetry to the cloud service.

I didn’t want to send my data to a 3rd part provider (especially not one in China). Another issue is that if the internet connection breaks down, I lose all my measurements during the outage. However, I found that the microcontroller in theses plugs are ESP8266 with the ability to flash Tasmota - a custom firmware.

tasmota logo

source: https://www.desdeelreloj.com/content/images/2021/02/tasmota.jpg

Tasmota is an open source firmware created with the vision to provide an easy smart device configuration with a web user interface, OTA updates, automation and, most importantly, complete local device control including MQTT.

The Tasmota documentation for the Gosund SP1 provides an overview of the drawbacks for using this device [link]. A major drawback of the SP1 is that it sometimes seems to not have an ESP8266 but an W701 CPU which is (at the point I write this post) not Tasmota compatible. I found this issue only after I ordered 10 pieces from Aliexpress so I hoped to not be affected by the new CPUs.

I was…

There are two possible ways of flashing the SP1: OTA with a fake update server or by opening it up, soldering some wires to the chip and flashing it via FTDI. For OTA flashing to work, the SP1 needed to have an older firmware of Tuya preinstalled. At some point, Tuya found out that people were using this loophole to flash custom firmware on their devices and closed it in their firmware.

5/10 of my devices had an ESP and the older firmware. To flash them, I used Tuya-convert. It is important that a device was never connected to any wifi with internet access. Tuya-convert creates a fake wifi access-point for the device to connect to and provides the desired firmware on the default Tuya update url. The device is tricked into thinking it downloads an update and flashes itself with the custom firmware.

Flash OTA

I installed Tuya-convert on my linux notebook and logged out of my home wifi.

git clone https://github.com/ct-Open-Source/tuya-convert
cd tuya-convert
./install_prereq.sh

Then I downloaded the latest Tasmota firmware from here and started the flashing process:

./start_flash.sh

After the flash you are able to connect to the fake wifi tasmota-xxx access point and open the web UI (e.g.: with a phone) of the SP1 at 192.168.4.1.

web interface #1 web interface #2 web interface #3

I selected the module template for Gosund SP1, configured the Wifi and chose a name for the power meter.

Flash via FTDI

1/10 of my devices had an ESP with a later Tuya firmware. I had no choice but to open it up. The blog Oliver’s /dev/null replacement provides great instructions for this process.

Here a few pictures of the results:

open SP1 #1 open SP1 #2 open SP1 #3 open SP1 #4

To flash the ESP via FTDI, I installed Tasmotizer on my linux notebook and followed the instructions.

At the end I, removed the soldered wires and re-assembled the case.

Remaining devices

Sadly, 4/10 of my devices had the new W701 cpu installed. Currently, they are sitting in my closet waiting for the time there is a way to get Tasmota flashed.

Name of the chip installed: CUCO-Z0-R-V1.2

Here are some links to threads about the current progress: