Introduction to the ESP32 

From the Arduino Uno to the ESP32

Maker transformation

In the previous article, I wrote about the ESP32 and how impressed I am with what I have been able to do with it since I started using it in my projects a few months ago.

I wrote about how the ESP32, the successor of the ground-breaking ESP8266, did everything right for Arduino Makers: processing power, communications options, form factor, compatibility with the Arduino ecosystem and the Arduino IDE, and, of course, the price. 

In the previous article, I promised to discuss the differences and similarities between the Arduino and the ESP32. I will give a summary of this in this email (see below).

I also promised that I’d give you another example of something cool you can do with the ESP32, and how easy it is to do that almost out of the box. And, yes, I’ll do that in this email too (see below).

Before I get to the technical stuff, I want to say this: soon after I started working with the ESP32, I started feeling liberated from the shackles of the Arduino Uno. While the Uno is the perfect board for the beginner, its limitations are apparent as soon as you decide to build an IoT application or something that combines displays, sensors, communications, and a basic user interface.

Yes, there are many other boards that I could use instead of the ESP32. But none of those I played with seemed right. Their price was too high, or something important was missing from their hardware, or they were too different from the familiar Arduino sketching paradigm, or I had to use its manufacturer’s infrastructure to make it work.

This ESP32 opened up my project horizons.

I believe that after your first steps with the ESP32, you will also feel liberated. Your project horizons will also open.

Now, I’d like to make a quick comparison between the Arduino and the ESP32. Since more Arduino Makers are familiar with the Arduino Uno, I will focus on Arduino Uno VS ESP32, but this comparison holds true for most Arduino boards.

These two don't have much in common.

Here’s the thing: These two are totally different.

Not only they look different, but their architecture is also totally different, and they have a different hardware architecture.

Their built-in capabilities are very different.

Memory and storage, the processing capacity, the number of GPIOs that they expose, the communications features and much more; these are very different microcontrollers.

In terms of features, the closest Arduino boards that are comparable to the ESP32 are probably the Arduino MKR1010, the Arduino 101 or the Arduino Zero. At least, these Arduinos have integrated Wi-Fi and Bluetooth, and comparable computational capacity.

Because the Arduino Uno and the ESP32 are so different in terms of hardware, it doesn’t make sense to compare  them that way. It makes more sense to write about the use cases of each one.

Here’s what I think:

Is the ESP32 right for you?

Well, it's definitely not for beginners. If you are not familiar with the Arduino, the ESP32 will be a complex board to learn. I don’t recommend it.

The ESP32 provides a perfect opportunity for Arduino Makers to extend and expand on their skills. The hardware that the ESP32 contains means that you can work on more exciting  projects and that alone is very desirable.

I find that the ESP32 is better value than comparable Arduino boards, like the MKR1000/1020 and the Arduino Zero.

Who is the Arduino Uno for?

I think that the Arduino is a much better choice for new makers.

It's simple.

It's more forgiving, as well, to problems in wiring and mistakes in wiring.

It's easier to set up.

In summary, if you are a new Maker, learn using the Arduino Uno. Then move on to the ESP32.

Now, I want to show you something really cool. As you probably know, the Arduino Uno doesn’t have the ability to generate a true analog signal. It can create the effect of an analog signal via Pulse Width Modulation.

The ESP32 can generate PWM output, of course. Almost all of its pins are PWM-capable. And it can do that with far more programmable control of the PWM signal parameters than what is possible to do with the Arduino.

But the ESP32 can also generate true analog output because it contains two 8-bit DACs: Digital to Analog Converter. You can access those two DACs (channels) via two of the GPIOs (25 and 26).

Let’s see how easy it is to create a true analog signal.

Example 1: Let’s create a flat waveform on GPIO 25 (this is DAC channel 1). The DAC resolution is 8 bits, so let's “write” decimal 127 to GPIO25.

It’s this easy:

dacWrite(25,127);

Value 127 is in the middle of the range of possible values 0..255, so the result of “dacWrite(25,127);” is around 1.65V measured on GPIO25 (assuming that the supply voltage is 3.3V).

We can take this one step further and create an actual sine wave:

for (int deg = 0; deg < 360; deg++)
    dacWrite(25, int(128 + 80 * (sin(deg*PI/180)))); // Sine wave

This example will generate a sine wave on GPIO25. If you connect an oscilloscope on that pin, you will see this visualization of the signal:

A sine wave, calculated during run-time on the ESP32.

The ESP32 is fast enough to be able to calculate the waveform in runtime, so you don’t have to create lookup tables in memory. And if you enjoy math, you can develop mathematical expressions to generate arbitrary waveforms.

In the next article in this series, I will write about my experience of using the ESP32 to make this gadget:

Something I made to help me learn the ESP32.

My motivation for working on this gadget was to learn the ESP32 in a real-world setting. I wanted something to help me explore as many elements of hardware as possible.

This project helped me learn how to build a system around the ESP32 that integrates environment sensing, an Internet clock, appliance voice  control via IFTTT and Google Assist, a touch TFT display for the user interface, and the use of many of the ESP32 features such as the SPI File System, Wifi, timer, and more, with an efficient program design.

Checkout the next article in this series with more information about my pet project 🙂

Peter

PS. In the meantime, do you have any questions about the ESP32 that you’d like to ask me? Just post them below.

"Introduction to the ESP32" series

Ready for some serious learning?

Enrol to 

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.

  • Will you do Low power bare bones ESP projects? Like a door sensor that only activates when the door is open and pre programmed to sun at certain times? Like only at nights (example)
    Maybe also some with solar panels?

    • Hi Belen, in this course, I did not cover low power and low power applications.

      It is something that I want to explore in an intermediate-level course if there is enough interest.

      In a low-power application (usually battery-powered), I would also go for more specialised hardware compared to the generic ESP32 Dev Kit. Something like the FireBeetle ESP32 or the Wemos D32 Pro.

  • Jason Soar says:

    Mr. Dalmaris,
    In your new course, will you include a section on BLE mesh networks? The reason I ask is I am currently working on a project, that utilizes a esp32, in which a mesh network is a critical component of. However, I have combed the Internet over and found virtually no examples of how to integrate this into my project. Have a great day!

    • Hi Jason,

      no, unfortunately. BLE mesh networks is a more advanced topic. It is not something I have done, so I would need to do research on this.

      I will set up a page on which you can request and vote on new topics for this course, if you like, please suggest this.

  • Jon Morss says:

    Peter,

    Which flavor of the ESP32 are you going to focus on considering there are multiple models? Are you planning to cover anything like MQTT and such?

    Also, the Arduino 101 is dead since Intel killed it some time back.

    As far as comparisons, you mentioned the MKR WiFi 1010 (it also has a BLE Radio) and the Arduino Zero (not sure the status on this), but there is also the MKR1000 and UNO Wifi. Also, there is the whole Particle family with the Proton being around for some time and then the Adafruit Feather line which I believe is based on the ESP chips. These might be something to do a comparison of as well.

    The ESP32 has been covered quite a bit on Udemy as well as on the Web, so it will be interesting to see your take on this.

    Cheers,

    Jon

    • Hi Jon,

      in this course I am using the basic WROOM32 module on the Dev Kit v4. It is a “getting started” course, after all.

      I have been experimenting with MQTT in my IoT gadget, and I will talk about it in a follow up course I am planning. That is probably going to be a project course, showing all the tech that has gone into my IoT gadget. However, the exact content is open, I will wait for you and anyone interested to pitch ideas.

      You are right, there are alternatives to the ESP32, like those you mentioned. I have all of those (Arduino 101, Zero, not the Uno Wifi, Proton, Particle). I still find the ESP32 to have the best balance of features, performance and price. It seems no big deal to buy 3 ESP32 to dedicate to three prototypes. You can’t do that with an Arduino 101.