Sunday, November 8, 2020

Tasmota Wall Light Switch

This is a log of what I did to get a Smart Wifi Wall Light Switch operating with Tasmota.  
This switch requires a Neutral Wire.

I have been playing around with Sonoff Smart Plugs S20 and S26. The S26 is very tricky to program,as there is only spots to connect to. I burned one by using a soldering iron too hot. Feck!

I got this a few months ago but couldn't find any references to it anywhere. I suspected that it had a ESP8266 at the heart of it, as the modules are so cheap.  

https://images-na.ssl-images-amazon.com/images/I/51XzqN26dgL._AC_SX679_.jpg

 I cracked open the switch and got the WiFi chip number. It was not an ESP8266 but a variant of it. 

Here is the guy. TYWE3S.
TYWE3S Support · Issue #852 · xoseperez/espurna · GitHub 

 Here are the pinouts.
TYWE3S · stodev-com-br/Sonoff-Tasmota Wiki · GitHub 
The pins of interest are TXD0, RXD0, IO0, GND and VCC.

I soldered it as shown below. 

I looked up the chip and got the pin outs. It is a surface mounted chip, so soldering would be fairly difficult. As it turned out, it was not too challenging. The pins are raised up a bit and they are not too close.







I connected it up to breadboard and connected it to a FTDI32 board.
It needs to be set to 3.3v, via the jumper, otherwise you will fry the board. 

The wire on IO0 needs to be connected to GND when it is powered up.

OBVIOUSLY IT CANNOT BE CONNECT TO THE MAINS IN ANY WAY, AS IT WILL FRY THINGS, INCLUDING YOURSELF  = DEAD.
FT232RL FTDI USB to TTL Serial Adapter Module for Arduino FT232 ...


Connect them together, as required.


 I used an Arch Linux laptop to do the flashing. It will be very similar on other distros.

Commands to Flash with Tasmota

  You need to get a copy of esptool for your distribution


Backup the image on the device

esptool.py --port /dev/ttyUSB0 read_flash 0x00000 0x100000 image1M.bin 

Erase the flash memory

esptool.py --port /dev/ttyUSB0 erase_flash

Write with Tasmota

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

Configure Tasmota

 
The next part involves configuring Tasmota on the device.
 
Set-up WiFi
 Select Configure
Configuration/Configure WiWi
 
Set the Name of the Device
Configuration/Configure Other
Friendly Name 1 
Set-up IP4 on the Device
 
Configure the functionality for the device 
Template
Configuration/Configure Other
{"NAME":"Jinvoo T1","GPIO":[52,0,0,0,0,0,0,0,17,21,0,0,0],"FLAG":1,"BASE":18}
 
 
I configured the device to use MQTT and in Domoticz.
MQTT is brilliant. I use it extensively with my Boiler Radiator controller system

Then using HABridge, I was able to expose it to Amazon Alexa and use via Voice 
 

This is the end product

 
A switch connected to a double socket controlled over WiFi. 
 
I am going to use it to control my Soldering Iron 
and Fume Extracting Fan





Magic Dust Seasoning


This makes the most excellent seasoning.

I use for sprinkling on cooked food or just before serving. I find that if you cook with it, all the aromatics are lost.

https://www.thespruceeats.com/magic-dust-spice-rub-335886

I have broken it out for different sized batches. 

x 1
x 2 x 3 x 4
64g Paprika 128g 192g 256g
32g Kosher Salt (Finely Ground) 64g 96g 128g
32g Sugar 64g 96g 128g
32g Chilli Powder 64g 96g 128g
32g Ground Cumin 64g 96g 128g
32g Granulated Garlic 64g 96g 128g
2 Tbls Cayenne 4 Tbls 6 Tbls 8 Tbls
2 Tbls Mustard Powder 4 Tbls 6 Tbls 8 Tbls
2 Tbls Ground Black Pepper 4 Tbls 6 Tbls 8 Tbls

I grind everything to dust.

Mix and GO