This blog features two gadgets who’s common thread is the ESP8266 processor and the use of Tasmota firmware
Firstly the H801 LED WiFi Controller !
I could have sworn I wrote about these incredibly useful H801 controllers some time ago but apparently not.
If you are new to the H801 devices, a short explanation could be useful. Typically sold by a range of AliExpress stores (check for best pricing, delivery and catches) I’ve been using these on and off to control 12v RGB LED strip for some time.
They can of course be run as-is, with an APP but I didn’t even go there, instead immediately opting to install the open source Tasmota firmware onto them because they run on an internal ESP8266. They come apart very easily (4 screws) and internally you can see holes marked (among other things) gnd, 3v3, rx, tx and GPIO0
So, flashing the boards is easy using the software Tasmotizer – and there is a link on the board (2 pads – if you wish you could solder pins onto them). The link needs shorting only when flashing before power is applied and keep it there until Flashing is done. The only variation from other ESP8266-based boards is that RX and TX are possibly the opposite way to the way you might normally connect an FTDI.
This has been covered to death on the web so I’ll not discuss the flashing process any further. Suffice it to say that the board needs no power other than your FTDI 3v3 to do the flashing. Once done you will want to setu p up the board as you would any other Tasmota-flashed ESP8266 – by entering WiFi (and MQTT) credentials.
And here’s the POINT of this article. Ages ago I flashed three of these units – calling them (un-originally) dimmer1, dimmer2 and dimmer3. So, what IS it about these that makes them worth spending £7 (China). Well, lets say you want to control some LED strip – lots of it (up to 4A per channel – 5 channels – depending of course on the capacity of your 12v power supply). Either RGB (12v) or just separate LEDS strips. Normally for such a job in the past, I might pick a Sonoff Basic as a starting point – but then you also need 12v at power for all that strip…. the Sonoff can turn on and off the 12v supply with it’s relay – sure, that’s one way of doing it.
So what started me on this journey? I have a cupboard in the living room to which, some years ago I fitted an ESP-GO project including Aidan Ruff’s prototype PCB (an ESP-12 + 220v AC supply + 10A relay). I fitted a DHT22 temperature/humidity sensor to the board (on a 5cm lead to keep heat interference down to a minimum). As I was going to drive LEDs, I also fitted a separate plug-in-the-wall 12v 3A supply to power the 12v LEDs. I fitted one warm white LED STRIP on each of 2 shelves and a red LED strip on the back for ambiance..That all worked for years, controlled by MQTT to run the shelf lights and red strip during the evening and to auto-read temperature and humidity on GPIO2.
That setup developed an issue just recently (no idea why – the relay appeared ON but the 12v to the LEDs was running at half mast despite the 12v PSU being just fine) and I was about to start hunting down another old board and got myself frustrated in the process.. then I remembered I had an H801, ready-Tasmotized (by me) with the H801 template it. Could I make use of this?
Well, to cut a long story short the answer is YES. I pretty much started from scratch with nothing more than a decent 12v 3A supply and the H801 boxed unit. So PART of the magic here is that the H801 has MOSFET internal drivers to handle up to 5 LED STRIPS – it really does NOT care which one is which… and you do NOT have to use the H801 template. So, what about my temperature sensor?
Because I chose to go without the H801 template, GPIO2 magically became available to me for temperature sensing or anything else. I grabbed the old DHT22 from the original board and soldered it onto the H801 PCB pins, cutting a tiny groove in the case for the leads to fit through. All of this took far less time to implement than write about – I may add.
Next – I re-attached the white shelf lights to output W1 on the H801 and some RGB strip I had handy to the RGB outputs. I could have been more ambitious but this did the job for me (W2 is currently sitting doing nothing – I could have put some COLD white LED on that and given myself complete warm to cold light (colour temperature) control – but I like warm white.
All I had to do was set up a basic “Generic 18” Tasmota module under Tasmota web “configuration” and fill in 6 GPIO settings… so.. I set up GPIO2 to connect to the AM2301 (i.e. DHT22). I also set up 5 PWM outputs as you would see on the Tasmota site and that’s why I’ve not provided more hardware info here – it’s all on that page.
I could probably have also setup GPIO5 and 16 to the internal LEDs in the H801 but it’s a living room cupboard and the unit is mounted on the back – who wants a bunch of flashing lights in that situation? Tasmota being Tasmota I could also have made use of GPIO17 or the analog input for some extra function – but could not think of a use for it in this instance.
So, next – well, this could get really complex – but I don’t need it to be. Tasmota will regularly and automatically report (via MQTT) the status of the DHT22 – commands “POWER 1” and “POWER 0” (TOGGLE in the webUI) will turn the LEDS on and off – and the simple COLOR command will let me control (by MQTT) the RGB backlight and my white shelf lights (as a whole if I want – or separately – the sky is the limit.
For reference in case you’re not really into Tasmota. In MQTT a command might for example be topic: cmnd/cupboard/power and payload 1 or 0
For colour control there are LOTS of ways to do this – for my needs I just needed colour [red, green, blue, white1, white2] – values being 0-255 in each case.
And now, my new Banggood 4-Way Relay Board
The interesting thing here is – had timing been different, I might have gone down a different route – as a new board from Banggood (4-way Relay Module with AC/DC power supply) has just arrived for me – resembling the board I mentioned above which Aidan and I put together some time ago but never took into production (but with 4 relays instead of 1).
This board however goes a stage further and offers not only 220vAC input, but also 7-30v DC and 5V input. It has 4 10A relays and connectors for spare GPIO and FTDI – which makes programming it up for Tasmota a snap. So, kind of like the Sonoff 4CH Pro but cheaper and more flexible but uncased.
Depending where you live, this board should land on your doorstep at under $10 (€8.70 inc shipping to Spain). For a general purpose ESP8266 board it takes some beating, depending on your requirements (if you are simply driving 12v LEDS then the H801 might be a better bet – but for say 4 completely separate mains devices and some input sensor(s), this is a better idea. GREAT for experimenting.
I had to use an FTDI once for set up but after that I realised I could possibly then make use of the RX and TX lines for even more extras – updating Tasmota as usual via OTA.
The manual on the Banggood site mentions some arduino code – but given the vast peripheral support of Tasmota – why? Mine’s getting a blue OLED display (GPIO4 and 2) and a DHT22 on GPIO5 unless I can re-use a serial pin!! What fun.
Having set up the Tasmota configuration so that GPIO16,14,12 and 13 were attached to relay 1,2,3 and 4 respectively – and having put in the 4 board links associated with those relays (to the left of the ESP8266), not only did the relays toggle on and off, but 4 onboard LEDs (top of the board, to the left of the ESP8266) started following the relay status.
At this point – a working board. However there would be no reason to stop there. I used “tasmota-display.bin.gz” as that obviously gives access to relays etc while providing maximum flexibility for any display one may care to add not to mention the odd sensor.
There is an uncommitted (inverted) LED on the board so for now I’ve attached GPIO5 to that and used GPIO4 and GPIO2 for i2c so I could put a 1.3″ SSH1106 OLED board on as well – just because I can.
Note: the dev version of Tasmota – 22.214.171.124 is brand-spanking new. Bit of an odd issue late on Friday night (Feb 19, 2021) – the SSD1306 was working and then stopped. The SSH1106 would not work at all. By late afternoon Feb 21, 2021 this was all magically fixed with no version renumbering.
HERE’S THE WEIRD THING. using the standard defined outputs for the relays originally, I had noticed that on power up, one of the relays flickered briefly (before and after I started messing with the SSD1306). In the process of setting up the board from scratch – I decided to set up i2c FIRST by OTA (not FTDI) – nothing worked – until I realised the board had reset it’s hostname to – would you believe “WEMOS-D1-MINI” – don’t look at me! So I set it back to “relay4” and with my display now working (after doing nothing more than setting up i2c and turning the auto-created power ON in the console) the display lit up with “SSD1306”. I immediately felt the urge to experiment.
displaytext [zf1]Hello there
Yup, that worked… z here means clear screen and f1 changes the font – yes, it’s that easy.
Now I was on a roll, I wondered, getting rid of the relay flicker, could it be as easy as no longer using GPIO16 ? YES, so I set up 3 relays using the same ports as before but GPIO15 instead of GPIO16 for the last one and inserting links accordingly. There’s a nice board indicator – could that be made to use GPIO16 set as an inverted relay 5 ( as if it would matter if that flickered on power up?). NO – as there is no status info available from GPIO16, I tried GPIO5 – that worked.
With just that perseverance I now have a 4-relay board who’s first relay works better than it did at launch…. ie no relay chatter on relay 1 at power up) – and I can also run I2c, for example an SSD1306 display – and still have an IO pin (GPIO3 (RX)) with which to attach a DHT22 – which I just did for the sake of it. What fun!
Final mod (for now) – GPIO3 (RX) to the DHT22, freeing up GPIO5 for an onboard light (relay_i 5).
Who says the ESP8266 doesn’t have enough pins. So, in the image above, toggles 1 to 4 control the relays – toggle 5 (power 5) turns the internal LED on and off and toggle 6 turns the SSD1306 display on and off.