The lead in
After putting off the inevitable for so long, It was time to finally tackle serial flashing my first Tuya device. I have about 20 devices on Tasmota or ESPHome currently but I have been luck up until now that I have been able to OTA flash all of them.
That was until the new firmware came out from Tuya breaking OTA and I finally got around to putting smart switch's in my house apart from my kitchen. I have waited until now as almost all of mine, living in Queensland, have ceiling fan dimmers on them. It has taken until now to finally decide on a switch I am happy with that does both lights and fan. Cost has also been a factor a with needing 19 switches. When decent ones were $100 plus I baulked.
Enter the Arlec Deta range from Bunnings. at $53 for the light and fan switch I could justify that, Anyway I digress. Sorry.
Picking up a bunch of the fans switch's as well as 1, 2, 3 and 4 gang switch's I installed them and then regretted not flashing them to Tasmota before doing so. Tuya while simple and cloud based is just that Simple, Slow and Cloud based. Linking buttons with rules is slow if at all possible, which when you have a house full of double plated light switch's is a PITA.
A bit of reading and questions later I attempted to flash my first victim, a double gang switch.
First and failed. again and again.
The process seem simple enough. Power on or reset the ESP chip while holding GPIO0 to ground to put in in programming mode. Hit go in Tasmotizer and bingo it should work, right?. No matter what I tried I could not get it to work.
In part due to a hand tremor I suffer from which made in impossible for me to hold a pin header to the TX and TX pins on the chip while doing a rain dance, resetting and holding GPIO0 on the ground in a headlock. This was not going to end well.
For the same reason I did not wan to try soldering tiny wires to the pins only to burn out the chip.
What I needed to to take some of the guess work out of the hook-up and flashing.
- Jaycar XC4464 Arduino Compatible Serial Adaptor
- Jaycar XC-4514 Arduino Compatible DC Voltage Regulator
- Jaycar ST0300 SPDT Sub-Miniature Toggle Switch
- Jaycar SP0710 Red Miniature Pushbutton - SPST Momentary Action 125V 1A
- Hook-up Wires
- 2 x Female Pin Headers
You defiantly can get all of these item a lot cheaper than Jaycar. In my case with all of the electronic I do, I actually had all of these components on hand. Not to mention the convenience factor of having a local store..
About the DC-DC Step Down. The requirement for this is based on your USB-Serial Adaptor. The Jaycar version like mine has selectable 5v and 3.3v logic output. However the VCC output is 5v regardless. Only the RX/TX Logic is 3.3v. If the adaptor you choose is different and the voltage selector also changes the vcc output then you can completely omit the step-down module altogether.
Why even have one you say? Well yes some ESP chips will happily accept 5v instead of 3.3v, some don't. For peace of mind sake I have included it. If you are certain what you are flashing can take 5v, by all means remove it from the design.
I chose to use Veroboard purely because I had it lying around. It is usually my preference to quickly hash out a circuit board (other than breakout boards). Word of warning for people playing along at home. If you have not used Veroboard before, make sure you solder does not flow between track lines unless you really intend to. It can easily create short circuits between pins if you are not careful. I usually double check all of my work before applying power to the board with a Digital Multimeter set to continuity mode, check from track to track.
Layout of the board up to you. You might choose to mount the power toggle switch and programming momentary button separate from the board. I was lazy and just drilled holes in a spare section of the board and mounted them directly. If like me you are mounting the Step-Down module directly to the board, make sure you cut the track just about the other input and output pin. This will defiantly be a problem. Make sure on the ground output side that you leave enough room to attach both the line to the GND pin on the output header and the line to the momentary button.
Mounting of the USB-Serial module is up to you. I initially was going to solder it directly to the board, however I did have spare headers that suited the output pins. I put the header on the board so I could lay it over slightly, bend the pins on the adaptor and mount it aligned with the board. I secure the serial module with a couple of Velcro dots (Have I ever said mod much I love Velcro dots and electronics). At least this way It is not going to get knocked easily and I can remove and reuse if needed without de-soldering it.
Using the board
- Connect your creation to USB, Make sure your power toggle is off
- Hook-up to your ESP Device. Make sure TX and RX are crossed over between the flash board and the chip
- Get your flash program ready with your favourite flavour of firmware (ESPhome, Tasmota, Arduino etc...) Serial port is set.
- Hit Go on your program
- Before it connect times out, Hold down the momentary button, Toggle the power to on, Wait about 2-3 seconds for it to boot, release the program mode button
With complete faith (or dumb luck) it should connect, erase and flash your firmware. If it did, well done you deserve an alcoholic (or non) beverage of your choosing.
When you are all ready to go and flash your first chip you might realise that I had not accomplished one aspect of my problem. Attaching the wires to the ESP chip. Yes I could take jumper wires, cut one end and solder the cut end to the pin. The board still make life simple to do the flashing process.
While researching this project I stumbled on a little hidden gem. a 3D printed ESP + TYWE3S Programming Jig . Once I saw it, I had to have it.
Tracking down a local 3D printing company on a Sunday morning (Yeah I know I am one of those guys) He happily took a look at the Thingiverse models and with an hour had printed one for me. For the sum total of $1.20 AUD. He was so good he printed me a second one :). I make a quick dash to my local Jaycar, Got Pogo PCB pins and a set of micro drill bits. Cleaned out the pin holes, Inserted pins and glues them in place with superglue. I then attached jumper wires to the top part of the pins and got this bad boy.
It fits snugly around the pins of the TYWE3S chips I was trying to flash. No need to hold my tongue in an unnatural position, while safely flashing the chip. Hold a button, Flick a switch and done.
The wrap up
I know this seems a lot of work. But when you just dropped $800 on smart switches you don't want to screw them up.
Comment from: Member
This post has 1 feedback awaiting moderation...