Just trying to untangle the threads

Software

Theo Arends continues to fix, improve and expand TASMOTA at a rate that, as a mere mortal, I find incredible. One of the areas which has seen a lot of activity is the list of supported modules and devices. When you connect to the web server on your device and select the configuration menu, the top item on the list is “Configure Module”. This allows you to select your specific hardware (currently, with release 5.11.1, ranging from the original ITead Sonoff Basic, all the way through to the Arilux LC06 RGB LED controller) to enable device-specific features in TASMOTA.

While there are 40-odd entries in the module list, the question is, are you out of luck if your hardware isn’t yet included? The answer, I’m glad to report, is a resounding “Heck, no!”. Theo has included a couple of devices in the list which make it relatively easy to drop TASMOTA onto pretty much anything which has an ESP8266 device on-board and have it work,not only with the basic relay switching function, but also with a whole load of other, custom goodies connected. Here’s an example.

I usually have a couple of the “Yellow Dev Boards” to hand, mainly because they’re so easy to press into service without having to jump through too many hoops. They have plenty of nice LEDs, an on-board, low quiescent current voltage regulator and an attached battery holder (making for an easy, remote sensor platform), an LDR already wired to the ADC input, all driven by an ESP12 variant (the version has varied over time).

TASMOTA doesn’t have a configuration entry for the Yellow Dev Board specifically, but because the board has an ESP12, most of the entries on the list will work to some degree or other. Okay, so why don’t we just go with the default “Sonoff Basic” then? Because the Basic only has a limited number of GPIOs available (and some of them are inverted via MOSFET drivers), it doesn’t lend itself too well to customization. You can load your own board with the Basic and successfully connect to the TASMOTA web server, but then you really need to look through the hardware available in the “Configure Modules” list and find something which is closer to your specific hardware.

If you’re using a Witty Cloud board (rather than the Yellow), for instance, you’re in luck; entry #32 in the modules list is for that specific board. If you have a Wemos D1 Mini, that’s also included at number #18. It’s worth scanning the list to see whether your specific board might have been added recently.

As you can see from the screenshots, the entries in the list aren’t sorted, so searching for an entry can be a little difficult.

As it turns out, the WeMos D1 entry is a good choice when you’re using an ESP12 series ESP8266 and this is the one I’ve chosen in the screenshot examples (the grey entry at the very top). After selecting (and saving!) this module type, you’ll find that the GPIO options are greatly expanded, compared to the Sonoff Basic.

Note that the WeMos D1 parameter list includes the WeMos pin nomenclature to the left of the GPIO names and the Sonoff default assignations to the right. This looks a little confusing at first glance, but is actually quite useful when deciding where to connect peripheral devices on your own ESP module (for instance, assigning your relay/SSR to GPIO12 and LED to GPIO13 will still leave your device working if the module type is changed back to Sonoff Basic at any time in the future).

The drop-down selection box to the right of each GPIO (currently showing “00 None”) allows you to select what function or peripheral you’d like to have assigned to that pin. Again, choosing the WeMos D1 module type enables a wide range of options for each individual GPIO (as of version 5.11.1 of TASMOTA, there are 64 different switches, buttons, LEDs, sensors, busses, relays and functions available, including some which I assume are device specific — what’s a “PZEM Tx”?? — and others which look like a future project in the making — do “IRrecv” or “BkLight” sound interesting to anyone other than me?).

So, going back to our Yellow Dev board, we have an RGB LED, as well as a bunch of boring old red LEDs across the top of the board (see the picture, above). In this particular application, we’re going to add a DS18B20 temperature sensor to GPIO5 and a small, solid-state relay (SSR) to GPIO12 (the default Sonoff relay pin). This is going to allow us to switch an incandescent light bulb on (as a low power heater) when the DS18B20 indicates that the temperature has dropped below freezing. As it’s no fun at all to do this sort of thing without blinkenlights, we’re also going to use the RGB LED to indicate freezing temperatures (blue flashes), above freezing (red flashes) and, for bonus points with those people who aren’t as colour-blind as I am, hovering around freezing point (purple flashes). We’re also going to add a button to GPIO0 which will provide the standard Sonoff/TASMOTA functions of toggle (for the relay/SSR), as well as the ESP8266 default of forcing the module into programming mode when pressed at power-on.

We’re going to use two methods to drive the LEDs; simple on/off for the green LED (because it’s the Sonoff default power LED, as the handy cross-reference in the Module Type menu, above right, shows us) and PWM drive for the red LED (GPIO14) and blue LED (GPIO15).

One point to note about the green LED is that the xref text shows it as “Led1i”. That trailing “i” indicates that, on the Sonoff, the ESP output is inverted, because theLED is actually driven via a dedicated MOSFET. On our Yellow board there’s no driver MOSFET, so we choose the non-inverting “Led1” when assigning a device to GPIO13.

GPIO14 and GPIO15 are LEDs, but because we want to vary the intensity and mix the colours (it’s that chunky, though-hole RGB LED at the top right of the Yellow board, remember), we’re going to assign types PWM1 and PWM2 to them.

The SSR is assigned type “Relay1” on the Sonoff default GPIO12 and we assign type “DS18B20” to GPIO5. The sensor assign does neat stuff, using Theo’s modified version the One Wire code to communicate on the designated pin (you must add a 4k7 resistor between the 3v3 pin and the data pin to have this work correctly and, if you’re using a sensor on long, unshielded leads, I’d recommend that you place the resistor at the outer, DS18B20 end, rather than on the GPIO end and add a 0.1µf between the DS18B20 ground and 3v3 pins).

Here’s what the module configuration panel looks like with all of those changes made:-

When you hit “Save”, the module will be restarted with your new configuration implemented. At this point it would be a good idea to go back into the main configuration menu and select “Backup Configuration” to save all of those changes to a file on your local machine.

In the second part of this post, we’ll look at some minor hacking of the Yellow board hardware to make a functional device, as well as going over the web and MQTT commands to get the peripherals working.

Theo has (as usual) been very busy with TASMOTA and has pushed out two releases in the last couple of weeks. The first, at the very end of October (the “Halloween-een” 5.9.0 release) was a fairly massive update, with portions of the code being updated to follow Google’s C++ style guide as well as rewrites of some of the code to use command look-up tables and JavaScript. In addition to those, there are seventy-odd other fixes, changes and additions. Phew! A couple of the notable items are:-

Addition of sea-level pressure calculation and a new ‘altitude’ command.

Addition of support for up to 8 relays (possible new product hint?).

Fixes for timezone and southern hemisphere STD/DST times.

Fix for a large flash erase issue.

Fix for ‘all-off’ issue when SaveState is inactive.

Fix for a pressure calculation issue with some BMP sensors.

…and lots more (check out the _releasenotes.ino file in the sonoff directory for the full listing).

The second release, 5.9.1, on the 7th of Nov, doesn’t have quite so many updates, but does add functionality to make addition of external sensors even easier and also adds support for the ADS1115 I2C AtoD chip, which a lot of people are going to find very useful.

That’s just a short round-up (I have no idea where Theo gets the time to do all of this magic …he must type at the speed of light) and, as already mentioned above, there are a lot more changes and fixes in there, so I’d recommend that you stroll over to GitHub and pull the latest version (it’s almost guaranteed to have even newer additions by the time you get there).

OpenMQTTGateway is, as the name suggests, a bi-directional gateway between MQTT and other hardware and/or protocols that may be running in or around your smart home. It supports most of the ESP8266 range of hardware, as well as an Arduino equipped with a Wiz W5100 ethernet adapter. The basic idea is that your ESP (or Arduino) interfaces with MQTT on the main network and provides seamless communications with (for instance) 433MHz or IR devices which otherwise are not directly connected.

A while back Florian made the package easily upgradeable by adding module support, where contributors can add support for other hardware and protocols by adding additional module files, rather than having to mess with the core functionality. This usually comes down to adding a single “ZgatewayXX.ino” or “ZsensorXX.ino” file (where “XX” is a unique identifier) and possibly an additional .h file, depending upon how complex your Z file is.

The latest addition is for a Bluetooth Low Energy based plant sensor (the Mi Flora) and provides a useful example of interfacing to BLE devices.

Most OTA schemes just allow you to push an update to your ESP8266, but Xose Pérez’s latest offering, “NoFUSS”, is a plug-in for your ESP8266 project which enables your ESP8266 to regularly check in with a specified server and automatically download an update if there’s one available. Neat!

In addition to the simple update functionality, NoFuss allows you to configure whether updates will be offered to specific groups of ESPs (for instance, temperature sensors which might all use the BME280 module) and to configure a specific load sequence (so that the SPIFFS filesystem on the target ESP might be updated before the actual project firmware).

The requirements for implementing this on your home network are fairly simple. The server side requires a web-server capable of supporting PHP. The ESP side requires that you add Xose’s NoFUSSClient library to your ESP project. The configuration for both sides is explained in Xose’s original article and the git repository for the project is available here.

Tinkerman (Xose Pérez) has just updated his ESPurna package (an alternative to Theo’s TASMOTA) to version 1.9.4. The change log shows additions for the Huacanxing H802 LED controller and the V9261F and ECH1560 energy metering ICs as well as fixes to ensure that all ESP8285 based devices are forced to use esp01_1m (limited memory) and updates to MQTT handling.

If you’re using any version less than 1.9.0, it’s probably worth upgrading anyway, as that was the last major update, where Xose added support for a whole bunch of newer Sonoff products (including the RF Bridge, T1 light switch and 4CH Pro).