That is, as in “trials and tribulations”. I’m busy getting myself familiar with the ESP32 and ESPHOME to see how far I can push these devices now that the price is not a LOT more than the ESP8266.
Regular readers will know that years ago I and others developed “ESP-GO”, firmware to get the best out of the incredibly popular ESP8266 WiFi microcontrollers. I took a few wrong turns there, including avoiding the Arduino framework (the libraries therein tend to be bulky BUT that route has incredible support) which meant I could focus on my core strength – C – and that meant modifying just about every library out there… anyway that’s history – enough.
When I hit on ESPHOME (not to be confused with HOME ASSISTANT) only weeks ago, I started a re-think. I have a number of ESP-32 boards so I got myself a KeyeStudio “shield” or baseboard primarily because typical ESP32 boards have so few ground and 3v3 pins making R&D painful.
I’ve been using Tasmota firmware for a long time now with ESP8266, avoiding ESP32 like the plague because it cost so much more and so it seemed at the time, not providing a LOT more power (unless you need Bluetooth which I don’t).
I’ll be working on this for months but several things have come out of this so far. I’m into WS2812B RGB displays as I LOVE pretty colours. WLED firmware (if you don’t know what that is – look here) can handle incredibly smooth rainbows using these lserial LEDs (hundreds of them) on a lowly ESP8266 (for clarity I run mine on 3v3, get great brilliance and need NO level shifting or other hardware to run them). The ONLY issue with WLED is – that’s what it does – runs a strip of ws2812b – end of story – no buttons on the other IO pins, nothing.
Tasmota can run LCD and OLED displays as well as ws2812b lighting and is improving all the time, but right now on displays particularly, ESPHOME seems to have the edge, with a possible caviat. I just spent an entire day struggling with ESPHOME on an ESP8266, running a strip of 10 ws2812b lights and a display and getting visual juddering on the ws2812b LEDs.
I read various items on the web about hardware limitations and other excuses. so I dug into this one deeply. I ended up with an ESP8266 board doing nothing more than controlling a couple of relays (lighting) and running a strip of ws2812b LEDs in rainbow mode on the otherwise unused ESP8266 RX pin. The ESPHOME online documentation includes this mode “ESP8266_DMA
(default for ESP8266, only on pin GPIO3)” bearing in mind that GPIO3 is serial RX. BEAUTIFUL. But if I tried to run any kind of display, the rainbow still started to fall apart. Ok, limitation accepted.
SO, on advice from one of the guys in the ESPHOME DISCORD forum, I switched to ESP32 and there things started to unravel.
First things first, my handy KeyeStudio shield isn’t QUITE as handy as it looks as various ESP32 boards have different WIDTHS (I already knew there were ESP32-based boards with differing number of pins) so any chance of a universal shield is OUT. However by careful selection of ESP32 boards.. they are not all the same. Note that on the shields I mention (the designers must’ve been half asleep) once the pins are in, it is quite hard to read the pin names – on the underside are pin references for the actual ESP32 board but the expansion pin layout doesn’t entirely match. It does not help that pins on the ESP32 are multi-purpose AND there’s no room, it seems, to show all options so you still end up consulting online charts in the hope of matching pins to what you actually need.
As an aside, I just received a KEYES ESP-32 board from Banggood – indeed the same as the Keystudio board but red which makes the lettering easier to read – maybe a later model?… Bangood refer to it as a . Here it is….
Worth a look.
Anyway, to cut the story short I was now ready with an ESP32 board with lots of 3v3 and ground pins, an external, adequate supply – I was going to get to the bottom of the juddering ws2812b LEDs issue if it killed me. The result? WELL, it appears that the NEOPIXELBUS component of ESPHOME is not given a higher priority than displays or indeed button presses (with debounce)… I STUMBLED on this when I realised that my CLOCK display on the ILI9341 had a 1-second update for seconds. Ok, you can get past that by only updating the LCD/OLED display every minute but that still means ws1812b display issues every minute – if that rainbow is not completely SMOOTH it isn’t worth using.
I’ve asked the question in the DISCORD ESPHOME forum if there is any way to give NEOPIXELBUS higher priority than other libraries – I’m not hopeful but we’ll see. Meanwhile as I now had a board with lots of power and ground pins I thought I’d wire up some real buttons and THAT triggered more memories.
Some years ago I bought some PCB touch buttons dirt cheap from AliExpress and I found I had a couple lying in a drawer. They need ground, 3v3 (2.6-6v) and have an output which goes straight to a GPIO pin. They work a TREAT with TINY PCB options for normally low, normally high and latching or momentary. (though I didn’t make a note of how to change from normally high to normally low, sadly).
WELL it turns out that AliExpress still have them and they are still dirt cheap – 10 for a couple of Euros once you add in the postage from AliExpress. AND they have a pretty light on the back (the front would have been better).
HOWEVER as I just discovered, there are no options on the AliExpress buttons (WHAT??) as (November 2021) they just arrived… so touching them once turns them on, touching again turns them off – not quite what I had in mind – which takes me to my new Banggood postbag – containing a sample that DOES have toggle-momentary options – see the for more info.
I just checked out a random YouTube video and it seems others have discovered these – in the video of 2016 they were just under £3 so Banggood’s price isn’t that far off – and LO – it seems I commented on them 4 years ago in that very same video. Both I and the English guy doing the video had figured out what the link was for but it seems that neither of us got to the bottom of the normally high/normally low option at that time and he did not describe the chip number. I can’t read it on my samples. That same fellow also talks about essentially the same switches and offers ideas on masking to make them do what you want – but as he’s RS sponsored I don’t think you;d wan to see their pricing – unbelievable. As for masking, not a bad idea is black masking tape on the switches, pre-cut-out for areas you need lighting up – OR reversed out printing on thin, clear adhesive-backed sheet.
This keeps getting better – it seems that CNX blog wrote about these switches after reading my original blog entry on the subject (it’s all coming back now)
THEN I discovered (and used) a variation also lying in a drawer – photo included here (and shown in the video) and they are even BETTER and WELL under €1 each. Momentary or toggle. I think I’d prefer, instead of no light when off and a colour when pressed, some kind of border colour until pressed (so you could see them in the dark) but hey. The ads show a range of colours available and even RGB (though I doubt there is much control over the RGB).
Anyway – I’ve created a short video above to show what I’m doing – I hope you enjoy. Only one spelling mistake up to now and it’s in the video so we’re stuck with it 🙂
Hi peter i’m trying to make the same ST7789 display work with a D1 and esphome, but withou any success, can you share this YAML with me to use as an example?
Hi
See “expand to view source” or similar in my reply to KanyonKris.. simply click to get the full yaml. I just did, and over a year down the road that’s all I have left of this project.
Regards
Pete
I pulled my hair out for a solid week trying to get those TTP223 touch switches working with a Tasmota’d Sonoff Basic. The Sonoff was behind a stud partition in an airing cupboard where my bathroom fan was powered off a switched, fused spur.
All I wanted was for a low voltage compliant switch within the “Low voltage” zone of the bathroom to turn the Sonoff relay on with a Tasmota rule to turn it off after 15 minutes.
These TTP223’s just rogue triggered the relay, usually a dozen times in a row through the small hours of the night. Nothing could stop it for me, external pull-up, external pull-down, inverted logic on the GPIO14, nothing worked!
In the end I put an AQARA Zigbee button on the bathroom wall and use MQTT to start the relay/timer now.
I never got to the source of the problem, whether it was the TTP223 or maybe an unstable power supply in the Sonoff? Something was toggling GPIO14 and I never solved it in the end.
G
Oh dear. Sorry you had no luck. Well, Aqara switches work well for me too.
Pete, your first post about ESPHome got my interest and I started tinkering. Got 3 boards running: ESP8266, ESP32, TTGO T-Display.
I run Home Assistant (HA) so I’ve been using the ESPHome add-on, but as you’ve shown, ESPHome works just fine without HA.
One snag I ran into: ESPHome on HA can flash an ESP* board over USB, but only if HA is running HTTPS (which is a pain to setup). No matter, I install to a manual download (compiles the BIN file then downloads to my PC) then flash the ESP* with ESPHome Flasher, Tasmotizer, esptool from the command line, etc. After the first flash the ESP* is ready for OTA updates, which I do thereafter.
I’ve mostly focused on the TTGO, fun to get stuff showing up on that little display (like you I’m moving to a 2.4″ display, will arrive tomorrow, also has touch so yet another thing to play with). I use the 2 buttons on the TTGO as next/previous page. I changed the backlight pin to PWM so I can dim it. I pull some data from HA for display (could do MQTT). I’ll be adding weather next, looks like you’ve already got some of that.
Here’s my code:
Thanks for that I’ll take a look. I moved to Raspberry Pi for compilation.. it’s a bit slower than windows but I like using the dashboard (which it seems doesn’t work properly in Windows) and can flash the first time no problem on a COM port on the RPI – then obviously OTA subsequently.
I’m currently on a roll to see how far I can push one ESP32, got 2 touch buttons, an ILI9341, a BME280 on i2c_b (gpio15 and 16 work), time of flight sensor vl53l0x on i2c_a, DHT22 on GPIO2 and 20 ws2812b LEDs in rainbow mode using NEOPIXELBUS – the only current limitation being the neopixels flicker ever so slightly on LCD update – which was every second – so I switched to only minutes (clock display)… I’ve not yet gotten an answer as to whether it is possible to increase neopixel priority over other stuff to stop that flicker (only an inssue in rainbow mode).
I’ll follow your lead on TOUCH on the ILI9341 – but I need to get a display with the touch panel on it – mine doesn’t have that.
Ok, looks like we’re headed in similar directions here.. – my output to the web page.. included photo – and my code just updated 14/10/2021 00:20…
I just learned something new – in both your comment and my reply – I added [ yaml ] and [ / yaml ] without the spaces before and after the code. Need to figure out how to indent code a little.
That yaml tag is nice, I’ll try to remember it.