I recently bought a DETA Grid Connect Smart Switch from Bunnings, with the plan being to integrate them with Home Assistant, using ESPHome, or other user-provided code. I actually didn’t use ESPHome, but rather pushed my own code/image to the device.
The device uses an ESP8266 compatible chip, with a product code of TYWE3S. I’ve included a link to the manual for the TYWE3S package.
There are two different methods that I tried for replacing the image with a custom image (as I wanted to avoid the provided cloud service and integrate directly within my home network).
Method 1 – Tuya-Convert
This method uses the tuya-convert software which is a Linux based package that you use to simulate an OTA (over-the-air) update to the device. This will replace the firmware with a Tasmota or ESPHome image (or a custom image you create). This method needs a Linux computer (I used an Ubuntu USB stick), and a WiFi adaptor. Basically the software impersonates an access point to which the DETA smart switch connects, and then sends it a new image. You can only use this method once – i.e. when the original firmware is on the smart switch. Once you push a new image to the device, you’re then reliant on your own OTA for any further changes (or use method 2).
I’ve been using this method with an image generated by the Arduino IDE, but uploaded through tuya-convert.
Method 2 – Arduino IDE
This method used an AVR programmer and a couple of hookup wires to push an image to the device directly. In my case, I used an AVR programmer from DFRobot. The device basically acts as a USB to Serial converter.
Ensure the programmer is set to 3.3V and not 5V. Using the programmer, you need to connect the following pins:
- VCC -> VCC
- TX -> TX
- RX -> RX
- GND -> GND
- GND -> GPIO0 (during programming)
- GND -> RST (during programming)
In order to push an image to the device, you need to first put the device into programming mode. This is done by pulling GPIO0 and RST to GND for 3 seconds. Release RST (the device boots), and once you see the code upload start, release GPIO0. If you are going to put your own firmware/image on the device, make sure to include OTA code so that you can do further updates over WiFi.
This sometimes takes a few attempts. Sometimes it works first time, sometimes I might have the timing slightly off, or I may not quite have the pins in contact. So be prepared to give it a couple of attempts.
For interest, the pinouts for manipulating the button and LEDs are as follows:
- GPIO4 = Device status LED – pull to GND/LOW to illuminate the LED.
- GPIO12 = Button 2 – GND/LOW represents a button press.
- GPIO13 = Relay 1 – set to HIGH to turn on the AC relay for Light 1. This will automatically illuminate the LED on the button.
- GPIO14 = Relay 2 – set to HIGH to turn on the AC relay for Light 2. This will automatically illuminate the LED on the button.
- GPIO16 = Button 1 – GND/LOW represents a button press.
The pinouts are the same for the single and double gang switches. I’m pretty happy with these devices as they’re compliant with Australian regulations, and very versatile due to the ESP8266 micro-controller.
I’ve since tested this with the single and double light switches, the double power point, the extension cord, the power board and the plug top – although their GPIOs are different.
For updated information on the 3 and 4 gang switches, have a look at my latest post.