This is just a quick reiteration of a simple project from 2016 to show how easy it is to use an ESP8266 to solve a real-world problem.
Our television is quite a few years old now and still working well, apart from one annoying problem; it no longer recognizes the on/off command from any of the 3 compatible remote controls that we have. To get around this problem, I popped an ESP8266 into a junction box between the TV and the mains socket, loaded it up with TASMOTA (of course) and then used IFTTT.com to connect our Googly Home Mini back to the ESP. Now we can just say “Hey Gew Gull, T.V. on!” and everything works like a charm …well, mostly. My better half mumbles quite a lot (it’s usually “Rhubarb, rhubarb …humbug …seat down”, or something along those lines), but both Goojle and I agree that she does mumble …and it doesn’t seem to matter whether it’s in English or Japanese. This is a problem, because while I’m always willing to walk across the room to turn a television off, I’m somewhat reluctant to turn the da$”!@ thing back on (and if you have ever been subject to the brain-rotting onslaught of puerile slop served up on Japanese TV, you’ll know what I mean). The whole point of the ESP was to fix it for her.
However, reading about all the latest and greatest microcontroller stuff over on CNX Software the other morning (over breakfast, while she was partaking of the aforementioned BRooPS), I came across an article on a low-power LoRa-based dual switch unit, which reminded me strongly of the old 2016 ESP doorbell project. I suddenly realized that I not only had the answer to mumbling (no, not a gag …don’t be cruel!), but I also had the hardware already built and sitting (somewhere fairly well down) in the “previous-projects” box.
With a television, radio and most lights, you already know the status of that device (whether it is on or off) and the issue is that you want to change that status (think of those light switches at the top and bottom of a flight of stairs …you don’t really notice whether the switch is currently up or down …you just know that in the middle of the night you need to flick the switch at the top to see your way down and then flick the one at the bottom to turn the light off again). You just want to toggle the state. One thing that we do know about TASMOTA is that it does “toggle” really well. So basically, all we need to do is tweak the doorbell demo just a tiny bit to send the MQTT data to a different topic and with a payload of “TOGGLE”. That shouldn’t be too difficult.
And it wasn’t. I still had a ton of superfluous crud in the demo code to flash and fade the multitudinous LEDs on the Yellow Dev Board from the previous project, but I just left it in there (along with the OTA update functionality). The main changes were to add the new topic:-
and add a static payload:-
Oh, and because I wanted the ESP to stay connected long enough to grab any OTA updates that I might be trying to fling at it, I extended the run time to a whopping 12 seconds and added a boolean flag to prevent the main loop from toggling the power to the TV 11,500 times while we were waiting for the OTA timeout.
The tl;dr summary of the doorbell hardware is that a single tact switch provides a pulse of power to the ESP8266, which is enough to bring it up to the state where it can turn on a MOSFET attached to GPIO16, which is connected directly across the tact switch and so latches the power to the ESP on, even when you remove your finger from the switch. Once the ESP has connected to local WiFi, sent off its packet to the MQTT broker and handled any pending OTA update (or, most likely, timed out) it simply removes drive from the MOSFET gate, turning it off and thus powering itself down. There is no “standby” current draw, as the whole unit is powered down.
All done and dusted in time for her birthday, neybothaman!