ESP12 — Bad batch out there

Just in case you haven’t seen it yet, GeekEnArgentina has reported on a bad batch of ESP12 boards which he received.  The symptoms were an endless boot loop when trying to program the device, with the problem being temporarily (and mysteriously) suppressed when a finger was touched to the upper, L/H corner of the ESP’s RF shield.

After two days of hectic troubleshooting (GeekEnArgentina was trying to ship out an order of 50 units to a customer), he eventually isolated the problem to a capacitor in the antenna circuit (which is assumed to be the wrong value, similar to the !470Ω LED resistor issue from a couple of years back).

His descriptions of the issue and the troubleshooting process are well worth a read.

 

Advertisements

There be bees here…

If you’ve never sat close to a bee hive and watched the little ladies going about their business, you’ve missed one of natures treats.  They are fascinating creatures on their own and the social cohesion and workings of the hive make them doubly so.  Bee keepers have always had to tread the delicate line between upsetting the balance of daily life in the hive against it’s internal state and the general welfare of the bees, though.  We have traditionally had to open the hives on a regular basis to check on the health of the bees themselves, as well as the state of honey and food stores.  While we still need to keep a careful eye on the health of the bees, IoT and ingenuity are making it easier to look after the bees without having to disrupt the hive with such frequent openings and I was very pleasantly surprised to come across the OpenHiveScale project a couple of days ago.

This is a new and ingenious take on a perennial favourite; a method of monitoring the weight of a beehive and thus being able to judge the amount of stored honey (summer) or food supplies (winter), without having to open the top of the hive and pull out individual frames of comb to inspect them (which always disrupts the hive, no matter how careful the beekeeper is).

The problem initially looks easy to techies.  Just pop a digital scale under the hive and automate sampling of the weight reading to have it delivered directly to your smart-phone.  Unfortunately, if you’ve tried going down this route, you will have discovered for yourself that it’s not quite that simple.  Digital scales (and load sensors in general) don’t deal well with being in a loaded condition for long periods of time (they tend to drift in a non-linear manner) and even if they did, there is still the problem of constantly supplying power to the scale at some remote (sometimes -very- remote) site.  One of the other options is to use a mechanical scale and somehow collect the data (the common low-tech version of this has a cheap, mechanical bathroom scale in a wooden housing under the beehive with some sort of mirror arrangement to allow the beekeeper to monitor the weight on his visits to the apiary).

OpenHiveScale mechanismThe OpenHiveScale project overcomes these problems by using a design based on the ancient “Steelyard” balance, with its sliding weight mechanism.  The fulcrum is folded within the frame to provide a wide load capability in a compact package.  The sliding counterbalance weight is driven by a stepper-motor and belt combination, with the “smarts” for the whole system provided by an ESP8266.  

The whole of this project (electronics, PCB, mechanical build and firmware) are all available from the OpenHiveScale GitHub repository.  Unfortunately, comments in the code are few and far between and there are no real build instructions on the site (there is an assembly_manual.pdf in the “mechanical” directory of the repository, but it is limited to diagrams, without any narrative), so you might have a difficult job duplicating their original work.  The good news is that they do sell kits.  The bad news is that they’re currently out of stock (and the price, including postage, is over €200).

The controller is modular, so if the hive is outside of WiFi coverage, an optional GSM, LoRa or SigFox card can be added (for an extra €30 to €40) to increase the range.

Power consumption is kept to a minimum by using an RTC chip to gate the enable signal on an LM3671 (low quiescent current) regulator and the recommended power source is a pack of 3 x AA alkaline batteries.

Unfortunately, the price (and lack of specific build details) make this a non-starter for all but the most well-heeled beekeepers, which is a shame.  We can only hope that this unique design will become popular enough to make it into mass production (with, hopefully,  a resulting drop in price).  It’s easy to imagine other applications for this scale, too.  Anyone who relies on tanked propane gas, for instance, would welcome the convenience of knowing just when the tanks need to be switched over (instead of having to go out at 10:30 at night, still wet and soapy from an interrupted shower).

 

 

Something new from Seeed…

…but we’re not quite sure what.

Seeed Wio_Lite_RISC-V_front

This morning I received an update from Seeed Studio with, among others, news of a new product in their “Wio” range, the “Wio Lite RISC-V (GD32VF103) – With ESP8266”.

It is attractively priced, at only $6.90 (plus shipping), but whether it’s actually worth ordering is a bit of a mystery.  Unusually for Seeed, there are no documents of any sort on the product page and the available description leaves a lot to be desired.  Basically we know that it’s a “GD32VF103CBT6 Bumblebee core” main processor with power consumption of  “only 1/3 of that of traditional Cortex-M3”.

Seeed Wio_Lite_RISC-V_back

The ESP8266 appears to be a standard, Espressif-produced WROOM-02 model, so nothing too exciting there, but there’s no obvious indication on either the front, or the back of the PCB of any interconnects between it and the GD32VF103 (the vias visible on the back of the board appear to connect the pull-up/down resistors on the front side to the ESP GPIOs).

Update  —  It turns out that a zip file in the “res” sub-dir on GitHub contains the Eagle PCB files for the board and a quick look at those confirm that the WiFi_TX, WiFi_RX and WiFi_RST pins are all directly connected between the ESP8266 and the GD32VF103.  It’ll be interesting to see what firmware the board ships with; the availability of full GPIO headers for the ESP hint that it won’t be using just the standard AT command set.

The GD32VF103 side of the board has a USB-C connector and an SD-card slot (the latter on the back of the board), as well as a LIPO battery connector and on-board charging circuitry, so it’s a useful looking board on it’s own.  It still remains to be seen whether the ESP adds any value to the package, though.

TASMOTA now supports the A4988 stepper-motor controller

As of a couple of days ago,  courtesy of Tim Leuschner, TASMOTA now supports the A4988 stepper-motor controller board.  Here are Tim’s instructions for getting it going:-

How to use:-

1. Physically connect at least Dir-&STP-Pin of the A4988 to 2 free GPIO’s of the ESP.
2. Allocate those GPIOS in settings to “A4988 pins” (#170ff).
3. In console type MOTOR {“setMIS”:1,”setRPM”:60,”setSPR”:200,”doTurn”:1.5} (sets microstepping to 1/1, StepsPerRevolution to 200, RevolutionsPerMinute to 60 and commands the motor to turn one and a half rotations).
MOTOR {“doMove”:100} commands the motor to step 100 times.
MOTOR {“doRotate”:360} commands the motor to rotate 360 degrees.
4. REST-Calls work with : http:///cm?user=aName&password=aPW&cmnd=MOTOR%20{%22setSPR%22:200,%22setRPM%22:60,%22doMove%22:360}

Command list:-

setMIS — Sets the micro-stepping (1,2,4,8,16 stand for a full step, or one-half, one-quarter, one-eighth or one-sixteenth of a step).
setSPR — Sets the number of steps the motor requires for one full rotation (depends on micro-stepping).
setRPM — Sets the number of revolutions per minute (roughly – not precise) – if too high, motor will not turn – test out an appropriate number for your use case.
doMove — Commands the motor to step the given number of times.
doRotate — Commands the motor rotate the given number of degrees.
doTurn — Commands the motor to spin the given number of rotations.

Tim is also looking for a little help with the MQTT implementation of the command set:-

Can someone plz take care to enable the MQTT-way to send this commands?Cheers Tim

Any takers?

A more detailed instruction sheet on how to set up the A4988 (with power switching and control of micro-stepping using additional GPIOs) has already been added to the Wiki by the hard-working maintainers (I don’t know how they keep up with all of the updates).

First steps with the W600 (on Linux)

I ordered a couple of these W600 dev boards a few weeks ago, as they were reported to be the easiest ones to use when introducing yourself to the ThingsTurn Dev BoardW600 chip (these “ThingsTurn” boards don’t have any second processor to grapple with, but do have a UART chip and USB connector for easy power/comms).

It turned out that while the power connection was easy, the comms were anything but and I wasted far too much time messing around trying to get it to accept an upload or even just a terminal connection.  So today’s post mainly consists of a series of short tips on how to get started with the W600 “ThingsTurn” dev board without pulling out all of your hair.  Tips 1 through 4 deal with getting MicroPython onto your W600, while those from #5 onwards are examples of what you can do with the board from the MicroPython REPL (command line).

For my purposes, I just wanted to upload MicroPython as a quick, functional test, without having to download and install a toolchain and/or SDK, or really do anything at all that took more than a couple of lines of typing or 5 minutes of my time.  Two days later, I was -still- getting nowhere very fast; my blood pressure was rising and I was itching to use my magic, solves-everything tool  …the 1.5kg lump hammer.

So, tip #1 is  —  Don’t believe everything you read (including this!).  The W600 firmware and applications are still under heavy development.  Most (but not all, see tip #2) of that work is taking place in China.  The translation and maintenance of the manuals seems to be quite well down the TODO stack (something that most of us are guilty of).  Specifically, don’t bother trying to use their “download.py” (if you can find it) for anything, most especially not for uploading to ThingsTurn boards.

Tip #2  —  Volodymyr Shymanskyy has recently posted a great tool for uploading to the W600.  It knows about the two available bootloader methods and will try to do the right thing, depending upon which type of file you’re attempting to upload.  Don’t bother with anything else; go straight to his repository and start using it now.

Tip #3  —  Don’t assume that your favourite terminal program(s) will work with the ThingsTurn boards, even if it has worked with everything else you’ve ever tried it with.  It turns out the the the ThingsTurn boards (note that I’m being very specific here, as I don’t believe that any of the other W600 modules suffer from this issue) have a requirement for the RTS signal to be held at “0” when connecting, otherwise the W600 will be forced into a permanent reset condition.  I was unable to get either “screen” or “minicom” (my usual goto choices for comms terminals) to play with the ThingsTurn boards.

By this time I knew that the boards worked, as they communicated with “w600tool” easily and loaded MicroPython (to displace the simple, one-second flash on/off program which comes as default on the boards).  Connecting with either screen or minicom would very occasionally produce a random, brief flash from one of the blue LEDs, but there was never any further indication of life and definitely nothing coming from the boards.  A major step forward was finding that sending a “Hang-Up” request (CTRL-A H) from Minicom produced the MicroPython header and a REPL prompt from the board, before it lapsed back into its previous, comatose state.  This confirmed that the upload had indeed worked and that, given the right conditions, MicroPython would run.  At this point I reverted back to my 1980’s RS232 self and started writing a simple C program to toggle the control lines…  before remembering that this was the glorious future and somebody else on the ‘net had undoubtedly already done it (and undoubtedly made a far better job of it than I ever did).  So I knuckled myself on the side of the head a couple of times and turned back to Volodymyr Shymanskyy, as he’d already helped me out once and seemed to have already cracked this particular problem.  That particular rabbit-hole led me, in very short order, to Python.

Tip #4  —  Use the force, Luke!  Or at least, don’t be as stupid as me and refuse to see what’s right under your nose.  You wanted to get running with something quickly:-  MicroPython.  MicroPython =~ Python.  W600tool =~ Python.  There’s a bit of a pattern emerging here.  Yup, those clever Python dev guys have already written the solution to our problem and it is called “miniterm”.  A quick check of the on-line manual pages showed that it was quite capable of toggling selected hardware control lines and holding them in the selected state, as well as all of the normal port and baud selection stuff.  So here’s the command line to get you connected, up and running using miniterm:-


python3 -m serial.tools.miniterm --rts 0 /dev/ttyUSB0 115200

[…and just a reminder here that this is from Linux, you’ll likely have to change at least the device name if you’re using a different OS].

Once you’ve typed that in you’ll see something like:-

— forcing RTS inactive
— Miniterm on /dev/ttyUSB0 115200,8,N,1 —
— Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H —

…followed by an ASCII-art representation of the Winner-Micro (stacked “W” and “M”) logo (which really confuses WordPress formatting, so is not included here), followed by:-

WinnerMicro W600
MicroPython v1.10-279-g3c60627-dirty on 2019-05-24; WinnerMicro module with W600
Type “help()” for more information.
>>>

Yay!  We’re in business!


Tip #5  —  Import the machine-specific hardware module.  Configure a W600 pin (PB14 in this case) as an output (with no pull-up or pull-down) and assign name “led14” to it.  Use the assigned name to toggle the value of the W600 pin (note that the blue LEDs on the ThingsTurn boards have their anodes connected to VCC via a 1k resistor and the cathodes are connected to the GPIO pins, so the output value of “1” turns the LED off and “0” turns it on:-


>>> import machine
>>> led14=machine.Pin(machine.Pin.PB_14,machine.Pin.OUT,machine.Pin.PULL_FLOATING)
>>> led14.value(1)
>>> led14.value(0)


Tip #6  —  Connect to an existing Access Point.  To do this, we first import the network module and then initialize as a station and scan for available networks.  We connect to an available network (SSID “BigHouse”) with whatever the password is (“Th3Pa55word” in this example), check for a valid, live connection and finally, print out the IP address.


>>> import network
>>> sta_if = network.WLAN(network.STA_IF)
>>> sta_if.active(True)
True
>>> sta_if.scan()
[(b'BigHouse', b'0Z:\xc7\x82\x10', 6, -67, 32, False)]
>>> sta_if.connect("BigHouse", "Th3Pa55word")
>>> sta_if.isconnected()
True
print("Connected, ip is: " + sta_if.ifconfig()[0])
Connected, ip is: 192.168.4.3


Tip #7  — Create an access-point on the W600  …and then shut it down again.  First we need to load the easyw600 module, which contains Winner Micro’s own helper functions to make this easy.  There’s just a single call to easyw600.createap(), with your choice of SSID.  You’ll find that the  new access point pops up immediately and is visible and accessible (but not very useful) from any nearby device equipped with WiFi:-

>>> import easyw600
>>> easyw600.createap(ssid="W600_softAP")
softap working, ip is 192.168.43.1

When you’re finished, there’s just a single call to easyw600.closeap() to shut it all down again:-

>>> easyw600.closeap()


Tip #8  –  Enable an FTP server process.  This will allow us to manipulate files on the W600, so that longer MicroPython programs can be written elsewhere and then debugged on the device itself.   Before you start with the FTP server, you need to make sure that your W600 is already on-line and associated with an existing AP (see tip #6, above).

The FTP server is included in yet another module, this time named simply “w600”, so to begin with, we need to make sure that it is imported.  After that, there’s just a one line command to start the FTP server with a given username and password (note that in the given example, the username and password are both set literally to the word “None”):-

>>> import w600
>>> w600.run_ftpserver(port=21,username="None",password="None")
ftpserver is running.

[After writing this tip, I found that the “easyw600” module has a wrapper for run_ftpserver() which is even easier to use, just:-  “easyw600.ftpserver()” ]

You can now access your W600 from any local machine and you’ll see something like this:-

Connected to 192.168.4.3.
220-= welcome on W600 FTP server =-
220
Name (192.168.4.3:guest): None
331 Password required for None
Password:
230 User logged in
Remote system type is UNIX.
ftp> ls
200 Port Command Successful.
150 Opening Binary mode connection for file list.
drwxrwxrwx 0 root root 0 Jan 1 2018 sys
drwxrwxrwx 0 root root 0 Jan 1 2018 lib
drwxrwxrwx 0 root root 0 Jan 1 2018 cert
-rwxrwxrwx 0 root root 139 Jan 1 2018 boot.py
-rwxrwxrwx 0 root root 34 Jan 1 2018 main.py
-rwxrwxrwx 0 root root 40 Jan 1 2018 easyw600.py
226 Transfert Complete.
ftp>

So, we can now create a file, “fc.py” containing Python code on our local Linux machine:-

def wibble(FC="dog"):
    print("Furry creature: " + FC)

wibble("cat")
wibble()
wibble("ferret")

Now upload it to the W600 using FTP’s “put” command and then go back to the W600 console and type:-

>>> import fc

…(note:- there’s no “.py” on the end) and you’ll see the output from your new code.

If you repeat the “import fc” command, there’s no further output, but you can now call the “wibble” function from the REPL command line.  Try:-

>>> fc.wibble()

and

>>> fc.wibble("rabbit")

Note that it isn’t really possible to un-import a file (or module) once it has been cached, so -don’t- edit your file remotely and then expect to see the changes reflected when it is re-uploaded. MicroPython generally ignores an import request for something which it already has marked as existing in cache. The only bullet-proof way around this is to reboot the W600.


Tip #9  –  How do I reboot the W600 (without pulling the power cord)?

>>> import machine
>>> machine.reset()

Tip #10 – And finally, here’s a replacement main.py file which you can now upload to your W600 to have it automatically connect to your WiFi network and start the FTP server (both as described above) on reboot. You -will- need to set the SSID and password for your access point before installing it.

##
## main.py file content. Used to automatically start
## the network, join an access-point and then start
## an FTP server on the W600 at initial boot.
##
## *** You must set an SSID and password ***
##
import network
import w600
import time

print(“Starting network and FTP server…”)

##
## Join Existing Access-Point (Local Wireless Network).
##
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.scan()
sta_if.connect(“MY_SSID”, “MY_PASSWORD”)

##
## Start built-in FTP Server.
##
w600.run_ftpserver(port=21,username=”None”,password=”None”)

##
## …and let the user know what our address is.
##
print(“Waiting for DHCP…”)
time.sleep(5)
sta_if.isconnected()
print(“Connected, ip is: ” + sta_if.ifconfig()[0])


 

Tanix TX85 – Z8350/4GB/64GB

As anyone who has been checking in over the past couple of years will know, I’ve recently become a great fan of Intel-based, micro/nano servers.  Unlike ARM boxen, they come with a case (rather than as a bare-board), complete with power supply, RTC and battery.  They’re cheap to buy and, with a power requirement of about 1/10th of a standard desktop system, are also cheap to run.  On the flip side, they do run on the warm side and so must be wasting more power as heat than their (generally cooler) ARM cousins.  Taking all of that into consideration (and with enough experience to convince me of their long-term reliability), all of the “servers” on our home network have now been downgraded from power-hungry monsters to these tiny, but powerful workhorses.

I’m always on the lookout for cheaper/better models and, a few weeks ago, I noticed that the TV-box maker, Tanix, had just brought out their own version, the Tanix TX85.  It had a couple of advantages over the other models at the low end of the market:-

  • Tanix has a pretty good reputation as a TV-box manufacturer
  • The TX85 appeared to have a pretty good, fanless ventilation system
  • It was very cheap

Having just completed a firewall/VPN project with a brace of different Intel-based micro/nano servers, the Tanix looked like an ideal candidate for the next step; offsite/offline back-up machines.  The idea behind this is that the separate physical sites (site-X and site-Y) connected via a VPN tunnel will each have a tiny server with an attached USB-3 disk.  The machines will generally be powered off and not accessible over the network.  When site-X wants to do a back-up, they request the operator at site-Y to power on the server and disk.  Once it becomes accessible over the VPN tunnel, site-X sends data to the machine at site-Y and on completion sends a “halt -p” instruction to power off.  The same system works in reverse for site-Y back-ups to the site-X machine.  I should qualify this simplified description by adding that this is suitable for small home or home/office offsites, but doesn’t scale well to anything much bigger, that might be handling commerce/database operations  …it also assumes that you have someone capable of restoring data from an offline back-up (something that tandhose same commercial/database operations sometimes tend to overlook).

Anyway, after wandering around the dimly lit alleyways of Alibaba for a couple of days (during which time I found an excellent price advertised by a certain vendor for the Tanix, which morphed into something vastly more expensive when I actually sent in an order — be careful out there, folks!) I finally found the Shenzhen BoxKing Technology Company, where “Nicole” very patiently helped me through the ordering process and gave me a very reasonable quote on shipping, as well as exactly the same (low, $87) price that they were advertising on the actual systems.  From order payment to shipping notification took about a week, but from that point to aUpdate Aug 6th 2019 —  As rrival on my doorstep was only 4 days (despite the box having been stopped and opened by customs).  It’s worth noting here that you might want to insist on the EMS shipment method if the other well-know, big name carriers tend to charge exorbitant service fees in your country (luckily they don’t here).

The normal disclaimers apply here.  I have no relationship with Shenzhen BoxKing Technology (or Tanix), other than being a satisfied customer and, although I recommend them, I do so on the basis of this single order.  I paid the full, advertised price for these systems myself and have not been (nor will be) recompensed in any way for mentioning them here.  ]

Tanix-TX85 retail boxThe systems came in a fairly stout cardboard box (which in my case had been mauled about a bit by customs, but then tidily repackaged and taped up again) contained within an equally stout, waterproof, plastic shipping bag.  The individual boxes containing the systems are very sexy retail versions (see photo), with a thin, slip-on card sleeve, which serves as protection against the box coming open accidentally, while also adding more branding space.

Inside, there’s the system itself (inside a soft bag) on top of a minimal manual and, separated from the system by a card shelf, the metal adapter (and screws) for mounting the CPU to the rear of a monitor.  On the right (see photo below) there’s a second, black and grey box, containing the power supply and an HDMI cable.Unboxed TX85. PSU in lower R/H (black and grey) box.

 

 

As you can see from the second photo, this unit comes with a VGA port, as well as an HDMI port, so it seems that it’s possible to run two monitors concurrently (although I haven’t verified that this actually works yet).  The ventilation holes all round the top of the case actually are ventilation holes and not just some fancy, plastic ornamental work.  There are also slots in the bottom of the case to encourage airflow.

Plugging the TX85 in and switching it on produces one of those mail-order “Uh-oh!” moments, as it takes a second or two to realize that there are no external LEDs (not even on the RJ45 connector) and, until the video comes up, the only indication that the unit is alive is a fairly muted blue glow from an internal LED.

Once the video is enabled, there’s a splash-screen displaying “American Megatrends” where you have a chance to hit F7 on the keyboard to get into the BIOS set-up, or boot selection screen.  The BIOS itself is a very functional one, very, very different from the crippled BIOS which shipped on the first Z8350 I bought.  There are, for instance, options for auto-power-on when mains voltage is reconnected (essential for domestic “servers”) and a comprehensive choice of boot-device options (although I found the method for choosing the latter to be somewhat less than intuitive).

Again, vastly different from that first Z8350 experience, it was absolutely no problem to break into the boot sequence (with F7), select a USB key-drive with Ubuntu as the boot device and never have to see Windows at all (sorry Windows fans, I can confirm that it will try to boot into Windows, which is loaded to the internal 64GB by default, but I have no idea what version it is).  OpenBSD 6.5 also booted (and installed) with no problem on this machine, so I have no doubt that the other distributions of Linux and BSD will run, too.

There will be more to follow on these little boxes once I have the chance to delve a little deeper….


Update 2019 Sept 6th  —  Unfortunately, I have to report the untimely demise of the PSU on one of the two test units.  It had been working for a couple of weeks, but I disconnected the systems while we were away from home and on our return one of them wouldn’t power back up.  As I had a couple of similar 12v PSUs sitting around, it didn’t take too long to isolate the problem.  There was no smoke, or excitement of any sort, it just failed to power-up.  At the moment, this is going down to “infant mortality”.  The system itself is still working perfectly on the replacement PSU.

 

Single button remote control for TASMOTA

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. MOSFET power-latch schematic 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:-

TV-Switch/cmnd/Power

and add a static payload:-

TOGGLE

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.

One-button-remote in operation

All done and dusted in time for her birthday, neybothaman!