Introduction to the ESP32
It feels and works like an Arduino, but... WOW...My new favourite microcontroller
Imagine an Arduino that fits snuggly on a breadboard, has more memory, more pins, more speed, more communications (including Wifi, Bluetooth Classic, and BLE), but costs less than an Arduino Uno.
Because it is an Arduino, you can program like you would program an Arduino Uno.
You can use the familiar and simple Arduino IDE. You old sketches will work, and so will your favorite libraries.
Only, this is not an Arduino...
It’s the ESP32, from Espresif.
ESP32 is the successor to the ESP8266. The ESP8266 is a board that introduced the idea that a microcontroller with ample processing power and wireless connectivity at an insanely low cost is possible.
The ESP32 took all the awesome features of the ESP8266, improved on them, and added many more (like Bluetooth).
What I really like about the ESP32 though, is that its a mature product.
While the ESP8266 was, infamously, painful to work with for most people familiar with the Arduino, the ESP32 is a pleasure with which to work.
In addition, while the ESP8266 was plagued, in my experience, with reliability issues and felt experimental, the ESP32 is rock solid.
Espressif has done a remarkable job in implementing ESP32 support within the Arduino IDE.
And the hardware itself is super-reliable. I have one of my IoT prototypes working flawlessly for over two months now, without losing a beat.
What this means for you is simple: If you know how to use an Arduino Uno, you can use an ESP32.
Why would you want to use an ESP32? Because it can transform the scope of your projects while actually spending less money on hardware.
I have been using the ESP8266 for a few years now, but I never actually committed to it. I found it clunky, and I did not have the time to deal with its frequent problems.
The ESP32 changed this.
I started using it as my exclusive prototyping board in January 2019. I was blown away by how easy it was to transition to this board from the Arduino Uno.
Make no mistake: I still love the Arduino Uno and it is my go-to board for teaching electronics and programming.
But as a Maker, the ESP32 is my new favorite.
Since I focused on the ESP32, I have used it for several projects, including a heart rate monitor, and an Internet of Things gadget that can respond to my voice.
A couple of things impressed me during this time:
- How quick it was for me to start working with the ESP32.
- How quick prototyping was, once I got started.
- How I felt liberated from the Arduino Uno limitation; this liberation opened up my project horizons.
Let me show you what I mean with a quick example. Say that you want to connect your project to the Internet, and send out some sensor data. Here’s how to do this in an ESP32, using the Arduino IDE.
Oh, and we’ll use secure communications, because it is 2019.
You can see the full sketch here, but below I provide the highlights.
At the header, include the secure Wifi client library. This library ships with the ESP32-Arduino core for the Arduino IDE:
Provide the credentials to your Wifi network:
Provide the target site root certificate (I only show the first three lines here, and extracting this certificate from your target website is very easy):
Create a secure client object:
In setup() , connect to your Wifi network:
And in loop(), first set the root certificate for the connection to the remote server:
… and connect:
You are now connected, and you can transmit data securely using client.println(), or receive using client.read().
Because the ESP32 dedicates a full core to running the radio components and has cryptographic hardware acceleration, the Wifi and secure web functions happen seamlessly for your sketch. Your sketch is running in its own full-speed core, at full speed, not losing a beat.
That is one less thing for me to worry about.
At this point, you might be thinking “That’s cool, I want to jump right in and use the ESP32 in my project NOW!”.
Well, that was my approach 🙂
I did learn that there are several similarities, but also differences between the ESP32 and my familiar Arduino Uno. I discovered that knowing what those are upfront would have made my work with the ESP32 easier, and my prototyping faster.
I am going to discuss those differences and similarities in the next article (or, in tomorrow's email, if you have received this article via email).
In the next article I also want to show you another cool thing that you can do with the ESP32, that is a stretch for the Arduino Uno.
In the meantime, do you have any questions about the ESP32 that you’d like to ask me? Just post it below.
"Introduction to the ESP32" series
Ready for some serious learning?
ESP32 for Busy People.
This is our comprehensive ESP32 course for Arduino Makers.
It's packed with high-quality video, mini-projects, and everything you need to learn Arduino from the ground up.
Just click on the big red button to learn more.
Jump to another article in this series.