Should you use ESP32 or ESP8266 in your project? What is the difference between ESP32 and ESP8266? In this article, we'll answer these questions by comparing the ESP32 and ESP8266, and cover the pros and cons of each board.
ESP32 and ESP8266 are very cost-effective Wi-Fi modules ideal for DIY projects in the Internet of Things (IoT) field.
Both chips are 32-bit processors. The ESP32 is a dual-core 160MHz to 240MHz CPU, while the ESP8266 is a single-core processor that runs at 80MHz.
These WiFi modules all come with GPIO and support various protocols such as SPI, I2C, UART, etc. The best part is that they come with wireless networking, which sets them apart from other microcontrollers like Arduino. This means you can easily control and monitor the device remotely via Wi-Fi or Bluetooth (ESP32) for a very low price.
Specs: ESP32 vs ESP8266
The ESP32 is the successor to the ESP8266. It adds extra CPU cores, faster Wi-Fi, more GPIO, and supports Bluetooth 4.2 and Bluetooth Low Energy. Additionally, the ESP32 comes with touch-sensing pins that can be used to wake the ESP32 from deep sleep, a built-in hall effect sensor, and a built-in temperature sensor.
Both boards are very cheap, but the ESP32 costs a little more. While the ESP32 sells for about $6 to $12, the ESP8266 costs $4 to $6 (depending on where you get them).
More GPIOs on ESP32
The ESP32 has more GPIO than the ESP8266, you can decide which pins UART, I2C, SPI - you just need to set the code. This is possible because of the multiplexing capabilities of the ESP32 chip that allow you to assign multiple functions to the same pin.
If you don't set them on the code, they will be on the pins defined by default as shown in the image below (this is an example for the ESP32 DEVKIT V1 DOIT board - pin locations may vary by manufacturer).
PWM, ADC, etc.
You can set the PWM signal in any GPIO and set the configurable frequency and duty cycle on the code.
For the analog pins, these are static, but the ESP32 supports measurements on 18 channels (analog enable pins), while the ESP8266 has only one 10-bit ADC pin. The ESP32 also supports two 8-bit DAC channels.
Additionally, the ESP32 contains 10 capacitive sensing GPIOs that detect touch and can be used to trigger events, or wake the ESP32 from deep sleep.
Arduino IDE - ESP32 vs ESP8266
There are many ways to program the ESP32 and ESP8266 boards. Currently, both boards can be programmed using the Arduino IDE programming environment.
This is a good thing, especially for those who are used to Arduino programming and are familiar with the Arduino programming language.
Using the Arduino IDE to get started with an ESP32 or ESP8266 and have your first project running is very simple. There are a lot of guides on the Internet: such as installing the ESP32 board in the Arduino IDE (Windows instructions); installing the ESP32 board in the Arduino IDE (Mac and Linux instructions); how to install the ESP8266 board in the Arduino IDE, etc.
While you can use the Arduino IDE to program both boards, they may not be compatible with the same libraries and commands. Some libraries are only compatible with one of the boards. This means that most of the time your ESP8266 code is not compatible with ESP32. However, usually you only need to make some modifications.
MicroPython Firwmare - ESP32 vs ESP8266
Another popular way to program ESP32 and ESP8266 boards is to use MicroPython firmware.
MicroPython is a reimplementation of Python 3 for microcontrollers and embedded systems. MicroPython is very similar to regular Python. So, if you already know how to program in Python, then you know how to program in MicroPython too.
In MicroPython, most Python scripts are compatible with both boards (unlike when using the Arduino IDE). This means that most of the time you can use the same script for ESP32 and ESP8266.
So, at this point you should ask: Should I buy the ESP8266 or the ESP32?
It really depends on what you want to do. Both boards have value to use, and both have pros and cons.
ESP8266 is cheaper than ESP32. While it doesn't have as many features, it works well for most simple DIY IoT projects. Also, since it's "older" and therefore more supported on the software side, you might find it easier to find help. However, it has some limitations in terms of GPIO mapping and it may not have enough pins for what you intend to do. If this is the case, you should use the ESP32.
The ESP32 is more powerful than the ESP8266, contains more GPIOs with multiple functions, faster Wi-Fi, and also supports Bluetooth. A lot of people think the ESP32 is harder to handle than the ESP8266 because it's more complex. In our opinion, programming the ESP32 is as easy as the ESP8266, especially if you plan to program it in the Arduino language or MicroPython.
On the other hand, the ESP32 also has some drawbacks. First, it's more expensive than the ESP8266. So if you're making a simple IoT project, the ESP8266 might do the trick at a lower price. Also, since it's newer than the ESP8266, not all software was developed to take full advantage of the ESP32's capabilities, so there's less support and more bugs. But in the long run, these issues will be resolved and both boards will have room for their respective applications.
My personal experience: In 2019, I use the ESP32 almost exclusively for IoT projects. It's more versatile and has more features like bluetooth, different wakeup sources, lots of peripherals and more. Also, the difference in price is not a big deal in my opinion. I think once you port to the ESP32, you won't want to go back to the ESP8266.