ESP32-P4: High-performance MCU with IO-connectivity and security features
espressif.com
espressif.com
Arduino does a great job with marketing but at the end of the day you could do 99% of Arduino projects with an ESP32 for 1/10th the cost, use less power, and get way more features at the same time, while still using the Arduino IDE or VS Code with Platform.IO.
Why pay for WiFi power (which is rather expensive) when you literally are sending Ethernet communication wires to your uC ?
Personally I'd take an ESP32 over a teensy 4.1 unless you specifically need the extra GPIOs or something. The teensy's are great hardware, but you're stuck with either Arduino or hand rolling.
You don't pay for WiFi power if the RF amp is off, and ESP-IDF for me is far better to work with than the Arduino software ecosystem especially once the complexity starts going up.
Also, if you just want to make widgets and not learn embedded development esp-home is brilliant.
A good YouTube Channel I find for microcontroller aspects is - Andreas Spiess
One of his videos you may find useful - https://youtu.be/ajt7vtgKNNM
Has the Arduino toolchain been enough for home automation? I’ve been playing with Zephyr, but when I’ve gotten down into those gritty late-AM Saturday night programming hours, actual library support seems to be patchy, outside Arduino and Espressif toolchains.
I ended up running MicroPython on the Sonoff Dual R3 (a cheap and cheerful box about the size of a fig, controlling two separate line voltage relays) but GPIO access is really unsafe, which makes it useless for sensing, but fine for control. For everything else I use the ESP-WROOM-32, a fairly ancient dev board, and it’s highly capable, but I get the sense there are better boards for prototyping in 2023.
If you have a preferred board, do tell!
For all my home automation I use ESPHome and Home Assistant (20+ custom devices, plus however many light bulbs and Sonoffs and stuff).
For tool chain I personally use Platform.IO in VSCode but I’ve done a fair few with Arduino IDE and it works in a pinch.
Rust support landed before that, https://github.com/esp-rs
This is all being done by Xtensa themselves, including the Rust.
I was about to go off on a rant about how power hungry the ESP32 is. But having a look its not as bad as I remembered (or perhaps I was thinking about the 8266)
https://diyi0t.com/reduce-the-esp32-power-consumption/
depending on the board you can get it to as low as 15ma in "normal" use(light sleep microprocessor only, modems off). But when the wifi is on it chows down powers.
15mA "light sleep" is really heavy actually compared to most things IMO. Hell, the Nordic Semiconductor nRF5340 uses 5mA _WHEN TRANSMITTING ON ITS RADIO_.
https://www.nordicsemi.com/Products/nRF5340
-----------
ESP32 is in that zone between the low-power (and ultra-low power) uCs and Raspberry Pi. ESP32 is ~20mA to 50mA, comparable to RP2040 (which I also consider to be very "heavy").
Arduino-chips, like the ATMega328pb (as old as it is), is on the scale of "Years on AA batteries of sleep". While chips like ESP32 are on "Hours of AA batteries of sleep".
--------
The only advantage to ESP32 is its WiFi. If you need anything else at all, there's a lot of better chips available. In particular, Teensy is probably the best board for ~50mA to ~100mA levels that the ESP32 finds itself in.
The ESP32 isn't ideal for basic battery stuff that needs to be awake all the time, or size constrained stuff - that's where nRF and BLE shines (or Silabs/Cypress).
However, in deep sleep you can get 10uA< which is decent assuming you wake up rarely, do a bit of WiFi work and go back to sleep.
For the right job (powered stuff that needs BLE, WiFi or ethernet, maybe hosting a local webserver for config and/or mqtt) the ESP32 is an absolute bargain compared to alternatives and a pleasure to work with to boot. The modules also typically have lots of flash onboard, ideal for embedding web UIs.
I mean that is bluetooth radio, so its cheating just a little :)
No, I get your point. the ESP stuff I do spends most of its time in deepsleep, so yeah the 15ma is not great, but its not _that_ much of an issue because I can just wake up less often. Not having to use C is even better though.
10 year previous me would be screaming at my attitude. I remember when the pyboard came out and I was very much "pfftt, amateurs. 35mA to do nothing very fast"
However having lots of connectivity really makes up for the not great consumption. I don't have to slap on an RF solution, or like I did 12 years ago, use a horrific ethernet->rs232 bridge.
However if I need online low power consumption, I'll need to use STM32, and cry at how bad the documentation is(or was, I've not tried to use it for years).
That's Microchip's SAM L10/L11, STM32U5, and the Nordic Semiconductor chip I mentioned earlier. Probably a few more out there (ARM sells their core to many different companies after all).
I seem to remember reading somewhere that it made a significant difference to power usage while having little responsiveness effect.
It's cool that they're seriously expanding their media interfacing capabilities - the ESP32s already have some, but they're quite basic.
I don't see a mention of it, so I have to wonder: What about Linux? There was a project a while back to get Linux running (at a snail's pace) by using JuiceVM to emulate a RISC-V CPU - now we have ESP32s with actual RISC-V CPUs (and MMUs as well!) ... so what's stopping Linux from running?
To answer the foreseeable "why would you want that": It would be really nice to get a standard OS with preemptive multitasking, dynamically loaded binaries, a shell and standard tooling.
NuttX has a lot of these (Zephyr has some), but I still feel find them quite limiting: At best you have to deal with "the microcontroller version of ..." (see Python, Go, .NET - they're all somehow worse versions). Don't we have enough power nowadays, even in the lower-tier ESPs or is my intuition totally off?
I know there are relatively cheap "SBC-style" boards (Raspberry Pi Zero W) for this purpose, but there's still a sizeable pricing (and size) gap between those and "MCU style" boards.
The one board I'm aware of that is trying to bridge the gap is the 128Mb Ox64 (https://pine64.com/product/128mb-ox64-sbc-available-on-decem...) and basically I wonder whether this might be Espressif's response to it.
Surely the day that even on these sort of low cost microcontrollers can run Linux is not far...
Edit: looks like there is already a port https://www.cnx-software.com/2020/02/17/how-to-build-run-lin...
Someone managed to get Linux to work by writing a virtual machine and emulating a Linux capable computer, but that was obviously not a serious use case (it was also extremely slow for obvious reasons).
https://www.cnx-software.com/2020/02/17/how-to-build-run-lin...
I would expect support from such a language to support me with I/O while I concentrate on my program. For example by providing an event loop.
Of course, if I need a more performant approach I would switch to a low level language.
https://docs.toit.io/peripherals
They also have nice simple tutorials.
Not sure about the event loop. I don't think it's even based. Looks more like "immediate mode".
But surely quick "How to do Esp32 things" mirroring this http://docs.micropython.org/en/latest/esp32/quickref.html would be very nice.
Without it you need to look for tutorials and documentation tree or even documentation for specific packages providing embedded functionalities.
The next best thing is currently probably this tutorial: https://docs.google.com/document/d/1K-TYea7jbYfj2ecMUmr0T0zd...
https://docs.toit.io/language/tasks
Synchronization: https://libs.toit.io/monitor/library-summary
For example the GPIO pin has a wait_for method which pauses a task until a signal is seen. https://libs.toit.io/gpio/class-Pin
As a layman they look like an insane deal. With western manufacturers $3.5 doesn't even get you a firm handshake whereas Espressif gives you a fully intergrated module with everything already on board.
https://www.digikey.com/en/products/detail/espressif-systems...
STM is more about versatile lineup; there are many variants with different footprints, redundant peripherals, price points etc. I think the $0.5 is only if you're a major manufacturer buying G0s or they're predecessors.
https://www.amazon.com/Espressif-ESP32-C3-WROOM-02-N4-Module...
The documentation for the STM32s is probably better though still not impressive, and the STM32 software libraries are nothing to write home about. I think the ESP IDF might actually be better though I don't have a lot of experience with it.
TRM and datasheets are clean and good (and no forced registration like some vendors).
H7 is a very beefy general purpose micro - more GPIO, multiple CAN, more UARTs etc. ESP shines when you need IP networking, wifi or bluetooth and can live within the (pretty generous) gpio and peripheral limitations.
I'm also not sure about licensing, but I know STM32s that you buy as development boards have a non-production or non-commercial use clause. Which sucks if you want to produce something in really small batches. I don't know if ARM based Picos or RISCV ESP32s have that same constraint. But I doubt they do.
No, they don't. You can get the boards starting at about $2 a piece, which is about the same as STM32 clone boards.
The ESP-IDF framework is very nice but I haven't had much exposure to CMake so I'm still wrangling around with project structure.
Apparently does not have double precision fp.
Also no WiFi or BT so it's rather different from their current offerings.
768k internal RAM will be useful.
This is chip is interesting as it is said the BL808 has a USB bug which forbid you to flash the bootrom over USB and you need to use the UART.
This means seriously strong assembly code reuse.
1. The innovation and performance you’re talking about.
2. Hiring. We’re going to be able to be on a flashy language, doing something cool which isn’t always the case with embedded. We’ve had a hell of a time getting candidates in that could write low level code competently. Rust should make that easier and hopefully using it will make us more attractive to the small pool of devs we’re courting.