I recently flashed a pair of Super-Mini ESP32-S3 boards using the online Tasmota flasher here.As I had no need for Bluetooth I went straight for the standard Tasmota (ENGLISH) option – which for anyone who doesn’t know, somehow works automatically for both ESP8266 and some ESP32 boards (ESP32-C2, C3, C6, S2, S3 and ESP8266) which I didn’t know until I took the time to hover over the drop-down option in the Tasmota setup page.Anyway, the “Super-Mini ESP32-S3” boards are widely available and cheap – and they have an on-board WS2812B RGB brightly coloured light.
The job at hand was to make a nice, simple PING sensor with visible display as I’ve been having reliability problems with my broadband which is 5G-based.Well, the 5G supplier, while offering truly unlimited data, when challenged will always come back with “we don’t support routers, you’ll have to test on a phone…” like I’m going to leave my phone hooked up 24-7 to supply broadband for our TV and my testing… yeah, right.Tecnhically these “routers” they refer to are “modems” So, back to the modem/routers – I have an “old” 4G LTE modem which has no long-term decent testing facility and a “new” 5g modem which similary has nothing special in testing ability either – you can get both to do a single (well, 4 in a row) PING of, say 8.8.8.8 or 8.8.4.4 (i.e.
Google) but then what – I needed to keep an eye on this – or have other family members keep an eye open while watching TV) to prove either way where the problem lies with the broadband.I switched from 5G to the 4G modem but I needed some means to monitor if one was any better than the other.So I decided to go with an ESP32 board sitting doing pings regularly and the simplest way, it occurred to me, to provide visual feedback might be to use an RGB LED with GREEN for no failures, YELLOW for some failures (using PING4 – which does 4 at a time in quick succession) and RED for no successes in any batch of 4 pings.
The Super-Mini SP32-S3 seemed like a good choice as I had 3 of them sitting around doing nothing and they have that WS2812B LED on the PCB.Mine also have tiny blue and red LEDS, one to the left of the USB-C connector, the other to the right.See the images above.
Of course not all boards will be the same as I found out when grilling my favourite AI for answers.In my case the tiny blue LED flashes at high speed constantly and the tiny red LED just comes on occasionally.Harmless but annoying.
So I set about finding out how to stop them completely – it turns out you can’t.The RED light only flashes occasionally as it is attached to the same port bit (GPIO48) as the onboard RGB light and hence comes on when the processor is sending serial data to the WS2812B.And the point of that is? The blue light is apparently somehow attached to the battery mechanism on the board and similarly you can’t program either of them out.
By the look of it the only way to hide these is to cover them in tape or if you’re brave enough – remove them with a soldering iron.I don’t recommend the latter unless you’ve a steady hand and a small iron.Meanwhile, what’s that damned bright red ligh doing – the Internet has gone off just as I’m trying to write this blog entry.
It actually took me several attempts to get the image to the left up – I can type on this WordPress blog locally but broadband outages while uploading images just does not work – oh well.Thinking about it, I’ve had problems uploading images to WordPress in the past – quickly resolved by a second attempt, but never understood why they happened until now… short term broadband outage? I’ve never been able to test that until now..SO, I’m doing a PING every 30 seconds which results in the RGB light changing, to red, yellow or green, and just to make sure the board isn’t STUCK (crashed – unlikely but possible)… I’ve added a brief 1-second flash of WHITE at the 30 second changeover – otherwise the light might stay on green, the board crash and I’d not be informed of an outage.
I tried for a 100ms FLASH but tasmota wasn’t having that.Ok, so my code.In Tasmota you can do lots of things at the console (in the web interface or in the serial console) including setting up GPIOs (I prefer to use the CONFIG section for setting up GPIOs and set GPIO48 to WS2812).
Back to the console… you can create rules abnd enable them, so here is what I put into the console… Rule1 ON System#Boot DO backlog RuleTimer1 10; LED1 #000000 ENDON ON Rules#Timer=1 DO Backlog Ping4 8.8.4.4; RuleTimer1 30 ENDON Rule2 ON Ping#8.8.4.4#Success==4 DO backlog led1 #ffffff; delay 1; Led1 #00FF00 ENDON ON Ping#8.8.4.4#Success==3 DO backlog led1 #ffffff; delay 1; Led1 #FFFF00 ENDON ON Ping#8.8.4.4#Success==2 DO backlog led1 #ffffff; delay 1; Led1 #FF8800 ENDON ON Ping#8.8.4.4#Success==1 DO backlog led1 #ffffff; delay 1; Led1 #FF4420 ENDON ON Ping#8.8.4.4#Success==0 DO backlog led1 #ffffff; delay 1; Led1 #FF0000 ENDON rule1 1 rule2 1 The rules go into the console as a single line and if you copy the above, make sure there are no TABS used.Enter rule 1, then rule 2 then enable rule 1 and enable rule 2.This is all non-volatile – after rebooting the board what you should see that the WS2812 will be whatever colour it was before, for a second maybe, then it will go to colour #000000 or nothing..
after 10 seconds, the first rule will run and that will send out a ping and 30 seconds later you’ll see the resulting colour.From thereafter, every 30 seconds the board WS2812B LED will update.WELL it turns out two things – with care you can reduce the above down to one rule – and secondly, the delay after the full white back to green or red etc, doesn’t work as Tasmota has issues with delay 1.
Also I asked the AI for help changing that delay and it came up with ruletimer1 1 (100ms).THAT didn’t work well as it affected the previous use of ruletimer1 (not so smart AI) – so I tried ruletimer2 1 – that didn’t seem to work well, so for a laugh I left out that delay altogether – and that works just fine.Here’s my current version – only one rule, together with the separately entered line to turn the rule on (in case you’ve not already turned on rule 1.
Again all of this is non-volatile.As the rule below stands, every 30 seconds, the device does a ping4 to address 8.8.4.4 and then depending on the result, does a quick flash of white followed by green (or yellow, red etc) until another 30 seconds has gone by.To see this in action, enter the commands in the Tasmota console (tools – console from the webUI)….
and watch the status.Rule1
ON System#Boot DO Backlog RuleTimer1 1; Led1 #000000 ENDON
ON Rules#Timer=1 DO Backlog Ping4 8.8.4.4; RuleTimer1 30 ENDON
ON Ping#8.8.4.4#Success==4 DO Backlog Led1 #ffffff; Led1 #00ff00 ENDON
ON Ping#8.8.4.4#Success==3 DO Backlog Led1 #ffffff; Led1 #FFFF00 ENDON
ON Ping#8.8.4.4#Success==2 DO Backlog Led1 #ffffff; Led1 #FF8800 ENDON
ON Ping#8.8.4.4#Success==1 DO Backlog Led1 #ffffff; Led1 #FF4420 ENDON
ON Ping#8.8.4.4#Success==0 DO Backlog Led1 #ffffff; Led1 #FF0000 ENDON
rule1 1
To monitor the above – in the console you will see a sequence starting at the first line below..18:08:40.975 RUL: RULES#TIMER=1 performs 'Backlog Ping4 8.8.4.4; RuleTimer1 30'
18:08:41.022 MQT: stat/esp32-pico-d4/RESULT = {"Ping":"Done"}
18:08:41.221 MQT: stat/esp32-pico-d4/RESULT = {"T1":30,"T2":0,"T3":0,"T4":0,"T5":0,"T6":0,"T7":0,"T8":0}
18:08:45.174 MQT: tele/esp32-pico-d4/RESULT = {"Ping":{"8.8.4.4":{"Reachable":true,"IP":"8.8.4.4","Success":4,"Timeout":0,"MinTime":102,"MaxTime":203,"AvgTime":159}}}
18:08:45.180 RUL: PING#8.8.4.4#SUCCESS==4 performs 'Backlog Led1 #ffffff; Led1 #00ff00'
18:08:45.221 MQT: stat/esp32-pico-d4/RESULT = {"Led1":"FFFFFF"}
18:08:45.472 MQT: stat/esp32-pico-d4/RESULT = {"Led1":"00FF00"}
Ignore the line above that says:
18:08:41.221 MQT: stat/esp32-pico-d4/RESULT = {"T1":30,"T2":0,"T3":0,"T4":0,"T5":0,"T6":0,"T7":0,"T8":0}