Electronics Projects Tutorial

Brilliant Smart WiFi plug

These smart plugs are a readily available, low-cost, and non-invasive home automation solution. Some models also have power monitoring.

This module can be purchased from the likes of PB Tech but its stock firmware does not have an open API that allows for access to the energy data.

To access the full potential of the unit the firmware needs to be upgraded. A good open-source firmware for IoT devices is Tasmota, which has an HTTP and MQTT interface for externals apps and automation setups. See below for more details on programming and setup.

 

Teardown & reprogramming

Caution!! 

These units use mains power which can have deadly consequences! Only continue if you have past electronics experience and at least medium ability.

Never plug the unit into mains power with the case open or plugged into a low power interface!

 

 

 

 

 

 

 

 

 

MCU interfacing schematic

This smart plug is very similar to this one, and the programming is the same as they use the same microcontrollers. They use an ESP8285 (basically the same as ESP8266) with 1mb flash on-chip memory in a TYW2S module. 

Open the plastic case by carefully hitting and working around the sides of the shell around the opening side with a plastic-ended hammer. This should break the glue, not the shell if done correctly.

Once the shell is opened, remove the circuit board and solder on jumper wires onto the TX, RX, GND & +3.3V solder pads on the underside of the circuit board (see diagram “TYWE2S Module solder-pads pinout“). A jumper wire will also need to be soldered to “IO0” on the back of the TYW2S module.

This tutorial below can be followed to program the smart plugs with Tasmota firmware

https://tasmota.github.io/docs/devices/CE-Smart-Home—LA-WF3-Wifi-Plug/

 

TYWE25 module

TYWE25 module

TYWE25 Module solder-pads pinout

TYWE25 Module solder-pads pinout

 

 

Tasmota interface

https://tasmota.github.io/docs/

The Tasmota interface can be accessed via any web browser using the device’s IP address.

Calibration settings:

The calibration settings can be preset in the console by inputting the following.

PowerCal 9368

VoltageCal 58436

CurrentCal 85

Template:

This template string can be input via. the UI template interface and will set up the device pins correctly for the hardware.

{“NAME”:“BL20925”,“GPIO”:[0,0,0,17,133,132,0,0,131,158,21,0,0],“FLAG”:0,“BASE”:52}

Node-Red interface

It is possible to extract device information from the MQTT / HTTP interface. Below is an example of a real-time power monitor with Node-Red and MQTT:

Flow Chart Dashboard

Node-Red example code

This code has two methods of sorting the input data.

The first uses a function to extract the variables from a single JSON object.
The second used a switch statement to send outputs depending on their MQTT topic. This could also be done in a function if needed.

Download the example flow here (right-click and save as). Use the import function in Node-Red to add it to your server.

MQTT_Example_Flow

Typical Hardware Schematic

New hardware

New devices seem to be using a lower-cost MCU from Beken and usually for the Tuya platforms such as Smart life.

These devices can still be re-programmed to run with MQTT etc thanks to this repo. Download its programmer and follow their instruction to program these new devices. They have also created a list of teardowns and instructions for a large range of devices here, which makes things a lot easier if you can find the same device. Use your browser’s search function to reduce your scrolling.

Research links

 

7 Comments

Leave a Reply to Freddy Cancel reply

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

Powered by: Wordpress
Skip to toolbar