Getting Started with the ESP32

The ESP32 is a low-cost system-on-chip (SoC) series created by Espressif Systems. It is an improvement on the popular ESP8266 that is widely used in IoT projects. The ESP32 has both Wi-Fi and Bluetooth capabilities, which make it an all-rounded chip for the development of IoT projects and embedded systems in general. In this tutorial, you will learn how to get started with the ESP32 and learn how to use it to connect to a Wi-Fi hotspot. This will equip you with basic knowledge that you will need when working on your ESP32 projects in the future.

Hardware and Software requirements

You will need the following things to get started:

Hardware configuration

Setting up the hardware is a simple task. All you need to do is mount the ESP32 development board onto the breadboard and then connect the USB cable to power the setup. The complete hardware configuration is as shown below.

The simplicity of the configuration can be attributed to the fact that the ESP32 development board comes with all passive components and additional parts that the ESP32 chip needs to run. Some of them include an antenna and antenna matching circuit, a USB interface and voltage regulators for power supply. In addition to this, it has a breadboard friendly pin configuration that allows access to all the ESP32 pins.

Installing PlatformIO

Now that the hardware is set up, you can proceed to software configuration and programming the ESP32. Start by visiting the Espressifs ESP32 github repository. There you will find example sketches, installation instructions for different development platforms and a layout and pin configuration of the ESP32 development board.

Some of the development platforms you can use to program the ESP32 include:

  •       Arduino IDE
  •        PlatformIO
  •       Make
  •       ESP-IDF

In this tutorial we will use the PlatformIO development platform because it is easier to setup and use, compared to the other platforms.

To install PlatformIO, click on the link provided in the installation instructions and then click on the platformIO IDE link to take you to the platformIO download page shown below. Alternatively, you can navigate directly to the PlatformIO IDE installation page.

You can either install PlatformIO IDE for Atom text editor or Microsoft Visual Studio code. In this tutorial Atom text editor will be used. Therefore, first download Atom text editor on your computer if you do not have it already.

Once Atom is installed, run it and navigate to Preferences>Install and then type Platformio on the search tab. From the results you receive install platformio-ide by clicking on the corresponding install button.

Once the installation process is complete, click on the restart button so that the changes made to Atom can take effect. If the installation was successful Atom will appear as shown below.

With the PlatformIO IDE completely set up, you can now easily upload code onto your ESP32 board.

Configuring the Board with PlatformIO

Create a new project on PlatformIO by clicking on the New Project button. You will be required to select the board that you are using. In this case it is the Espressif ESP32 Dev Module. You will also be required to choose the framework. It is set to Arduino by default, so there is no need for you to change it. Once that is done, click on the Finish button to start the new project.

PlatformIO will create the necessary project folders and files for you. You can access them from the tab on the left side of the PlatformIO window. Navigate to the main.cpp file which is the file that will be holding the main sketch. Copy the code below and paste it into the main.cpp file.


Your PlatformIO interface will look like this:

Before uploading the code to your ESP32 development board, replace your_ssid and your_password with the ssid and password of your Wi-Fi network. This way your board will be able to connect to your Wi-Fi network. To upload the code, first click on the build button from the toolbar on the left side of the window. This compiles the program for the ESP32 platform. Once compiling is done the serial monitor will display success.

You can now upload the code to your board by clicking on the upload button. The upload button is just below the build button. With PlatformIO you don’t have to select the serial port on which your board is connected to, as that is done automatically. When the upload is complete open the serial monitor by clicking on the serial monitor button. This will allow you to view output from the program. The sketch that you have uploaded will enable the ESP32 board to connect to the Wi-Fi network and print the IP address of the ESP32 board on the serial monitor.

If nothing gets displayed on the serial monitor, press the reset button on the board so that the board can run the sketch again from the beginning. If the IP address of your board does not get printed on the serial monitor, confirm whether the SSID and password you provided is correct.

How to Go Further

Connecting to a Wi-Fi network is just one of the many things that the ESP32 is capable of. Some of the other things you can accomplish using it include, hosting a webpage, Bluetooth low energy communication, creating a web client for online data logging and Over-the-Air (OTA) programming among many others. This makes it an ideal prototyping tool for any kind of project. We will be looking at how to implement some of those other features in later tutorials. So, stay tuned.