Kickstart Your Embedded Projects With ESP32 and PlatformIO

We’ll begin this article light for the newcomers. The IoT (Internet of Things) refers to the connectivity between physical objects and computer devices like smartphones, watches, home appliances (fridge, air conditioners, etc.), smart TV, cars or any transportation systems.
Note from the author
Kick-start get to use microcontrollers like the ESP32 quite often for our IoT projects. That’s why you can take this article as our honest recommendation of a great money-for-value development board. We thought it’s a nice thing to do — sharing bits of insight with tech savvy mates- so stay tuned for more tech articles!

Intro into IoT and IoT Microcontrollers

We’ll begin this article light for the newcomers. The IoT (Internet of Things) refers to the connectivity between physical objects and computer devices like smartphones, watches, home appliances (fridge, air conditioners, etc.), smart TV, cars or any transportation systems. IoT identifies the general abilities of network devices to gather and analyze data from around the world and share this data over the internet to execute fascinating projects and functions. As these IoT devices collect and gather data using their sensors, so there is a need to provide more computational power to process data efficiently. IoT devices are deeply merged with electronics, sensors, software, and network connectivity, which enable IoT devices to sense, collect, process, and transfer data. These processes are controlled by mini processors in IoT devices called microcontrollers. With every passing day, IoT devices are becoming smaller, therefore, IoT processors or microcontrollers are constantly decreasing in size and at the same time become more and more efficient in order to meet the requirements. In this article, we discuss a well-known microcontroller ESP32, which is used in most IoT devices around the world, and discuss its specification, architecture, and compare it to other IoT microcontrollers.

EPS32 Microcontroller

Figure 1: NodeMCU ESP32s

The ESP32 is a series of low-power, low-cost System On Chip (SOC) microcontrollers with built-in Bluetooth and WiFi modules. It also contains flash memory and a chip antenna. In the Esp32 SOC microcontrollers series, ESP-Wroom-32 is the smallest module specifically used for small size IoT devices like smartwatches and healthcare products. A functional block diagram of ESP32 is provided below that provides more technical information of CPU cores, peripheral co-processors with WiFi and Bluetooth technologies.

Figure 2: Architecture Diagram of ESP32

The main processor is 2 core, 32-bit LX6 microprocessor with 80–240Mhz frequency. It has internal ROM memory of 448KiB for booting and core functions, 520 KiB SRAM for data and instructions, and 16 KiB RTC SRAM for data storage and main CPU during RTC boot from deep-sleep mode. The ESP32 is equipped with external SRAM memory capability that supports up to 16KiB external flashes and SRAM. It has a peripheral IO interface with DMA with capacitive touch function, analog to digital converter (ADC), digital to analog converter (DAC), UART, IC (Integrated Chip), Controller Area Network, Serial Peripheral Interface (SPI), PWM (Pulse Width Modulation), Inter-Integrated Circuit, and RMII.

One of the most famous development kits that are based on the ESP-WROOM-32 chips is the NodeMCU 32s. It provides 38 IO ports (displayed in the following figure) and has an open-source community.

Figure 3: Pinout and dimensions NodeMCU ESP32s [1]

Compared to other IoT microcontrollers

We compare different ESP32 series IoT microcontrollers to help you select the most relevant ESP32 development board according to the requirements of your project. The ESP32 is integrated with new features like WiFi and Bluetooth technologies as compared to its predecessor ESP8266. It is a standalone chip that has all the features of a development board. We compare the ESP32 microcontroller with the most popular IoT microcontrollers. For this purpose, a table is created below which presents the comparison of different IoT microcontrollers and the importance of ESP32 microcontroller.

Now that we got an overview of the hardware capabilities, let’s talk software.

PlatformIO

It is a cross-platform, cross-architecture, multi-framework, and development environment for software developers specifically design to develop embedded products. It is a development toolkit that can be run on the most operating system and integrated with other code editor frameworks like Visual Studio (VS Code), Atom, Eclipse, NetBeans, and Sublime Text. It is also available on cloud-based code editor frameworks like Codeanywhere and Eclipse Che.

It can be integrated with Microsoft Visual Studio Code, which is a free open-source multi-platform code development platform available for Linux, Windows, and Mac OS X. The most significant feature of VS Code is that it supports extensions. With the help of these extensions, developers can add more functionalities to VS Code, that enable them to use VS Code for virtually any platform and code language. PlatformIO integrated with VS Code as an extension to enhance its functionality.

Using PlatformIO To Deploy on ESP32

Other development frameworks like the Arduino IDE are also used for small embedded-based applications. However, for more complex projects with more than 200 lines of code, multiple libraries, and other advanced features like debugging, and auto-completion, VS Code with PlatformIO extension is the best solution. To program ESP32 and ESP8266 boards, VS Code with PlatoformIO provides complete functions and features. You need to follow the given steps for ESP32 programming:

Open VS Code:

  1. Click on the Extensions button to open the Extensions tab
  2. In the Search box type “PlatformIO IDE” and press Enter
  3. Select the very first option in the search results list as shown in the Figure below
  4. In the last, click on the Install button to install the PlatformIO extension.
Figure 4: Installing steps of PlatformIO

After installation, the next step is to create a new project for ESP32 board development. For this purpose, click on the PlatformIO Home icon, and then click on the New Project as presented in Figure 3.

Figure 5: Creating New Project for ESP32 Development

Give a name to the project (for example BLINK_LED) and then choose a board type for the development. In our case, the development board is ESP32, therefore we choose “DOIT ESP32 DEVKIT V1”. In the framework type, we use Arduino. In the last, click the Finish button to complete the wizard. VS Code utilizes folder structure for PlatformIO extension which is different from the standard .ino project. Initially, beginners feel difficult to deal with several files but with time they get experience to handle these files.

Figure 6: Project Wizard for ESP32 Development

Cool ESP32 DIY Projects


There are several DIY projects, that are developed on top of the ESP32 platform. We’ll leave a few links below of some cool projects, some also featuring the source code and complete descriptions of the projects. You can follow these links to find relevant ESP32 projects.

https://randomnerdtutorials.com/esp32-web-server-gauges/

https://randomnerdtutorials.com/esp32-wi-fi-manager-asyncwebserver/

https://randomnerdtutorials.com/esp32-firebase-realtime-database/

Reference

1. (2022). Retrieved 28 January 2022, from https://docs.ai-thinker.com/_media/esp32/docs/nodemcu-32s_product_specification.pdf


Our other articles