Getting Started With ESP32 From Scratch

AtomicHaggis
5 min readSep 17, 2021

--

Starting with an empty project template

ESP32 modules from Espressif are immensely powerful modules with oodles of customisable I/O, expressly created for the IoT and embedded devices market.

The ESP32 modules are surprisingly inexpensive for their capabilities, with straightforward developer kits costing, for the most part, less than $10 each from Digikey or Mouser regional sites. The more advanced developer kits are also reasonably priced, and we’ll go over some of them in future articles.

There are variants with single- and dual-core processors and all are CE and FCC approved, which makes manufacturing with them so much simpler than designing a circuit from scratch.

They also support high quality open source platforms such as FreeRTOS, Mongoose OS, nanoFramework (if you prefer coding in C#) and other commercial operating systems.

The ESP32-DevKitC-v4 — WROVER Variant

I have recently started design and development with these modules, but getting started can be tricky as the official ESP documentation doesn’t tell you how to create a development project from scratch. It only shows you how to clone an existing project (hello-world) and modify that to make it your own. I prefer to start clean in a new project, so this guide serves to show you how to do that.

This guide, and others in the future, have been created to help new ESP32 and RISC developers like myself to get a better understanding of the pitfalls and struggles of making your first moves with this wonderful little platform.

New Beginnings

While the ESP32 modules are fully supported with Arduino-style development, this will not be our focus. We will be working with the modules using Assembly, C, C++ and MicroPython. I understand the Arduino aspect is of interest to a great number of new developers so I will link to relevant third-party resources where appropriate. For the most part, though, we’ll keep things native.

I use a Mac for development, along with Homebrew for installing prerequisites and libraries. I recommend either a Mac or even a Linux virtual machine, but Windows is also supported. I use VS Code (with the Espressif ESP extension for easy coding and debugging) and vim as my main coding tools.

The ESP32 has been used to create everything from simple smartphones, vehicle and asset tracking, 8-bit console emulation, music players and so much more. Once you see the potential of this little device you’ll feel the creative juices starting to flow!

On With The Show

Now, let’s get started with our first step in the whole process.

To undertake this, you’ll need to already have a development environment already configured. You can follow the guides provided by Espressif to do this with Getting Started on the Espressif Docs portal. Also, be sure to check out the section called Establish Serial Connection with ESP32, as it concerns driver installation on all supported platforms.

Once you’ve completed the environment setup and tested your environment and development kit with the hello-world project, you can begin with the rest of the steps below. If you’re not able to connect with your device, it may be because you need to install the SiLabs CP210x USB to UART Bridge VCP Drivers, which you can get here.

Let’s Begin — The ESP32-WROOM-32

The ESP32-DevKitC-32E with ESP32-WROOM-32(E/UE)
The ESP32-DevKitC-32E with ESP32-WROOM-32(E/UE)

Our first foray into this realm will be with the ESP32-WROOM-32E based ESP32-DevKitC-v4 developer kit. This kit offers a substantial number of customisable I/O pins for many types of project. You can check out the full specifications here and you can buy the ESP32-DevKitC-32E dev kit from either Mouser (www.mouser.com) or Digikey (www.digikey.com).

Step 1 — Set Up The Environment

Open up your terminal/console application and go into your ESP32 projects directory. Set up your environment, as per the documentation.

Output of Console — Environment Configured
Output of Console — Environment Configured (macOS)

Once you see the Done! You can now compile ESP-IDF projects. message, we’re ready to proceed.

Step 2 — Acquire The Empty Project Template

An empty project template is provided on GitHub for us to use, so let’s clone that into our projects folder with the following command:

git clone https://github.com/espressif/esp-idf-template.git esp-template

If you prefer a different name than “esp-template” for the new template directory, enter it instead at the end of the clone command.

A new folder will be created called esp-template.

Step 3 — Create A New Project

Now all you need to do to create a new project is to copy this new esp-template directory to another one of your choice. For my example, I’m going to create a new project called “bluetooth-test”

In macOS & Linux:
cp -R esp-template bluetooth-test

In Windows:
xcopy esp-template bluetooth-test /E /H /C /I

The command line switches used above perform the following operations:

/E — Copy subdirectories, including any empty ones.
/H — Copy files with hidden and system file attributes
/C — Continue copying even if an error occurs.
/I — If in doubt, always assume the destination is a folder. e.g.
when the destination does not exist.

Now when you enter the new directory, you’ll see the following structure:

New ESP project created from template

Step 4 — Finish Up & Configure Project

That’s it! Now you can run the usual commands such as:

idf.py set-target esp32

and

idf.py menuconfig

You can also add in your components directory and any other dependencies your project will require.

I hope this helps others get started on new projects without having to do cleanup first. Please let me know in the comments if you have any questions or suggestions and we’ll take those into account for any updates or new articles.

Interesting Links

It is always good to have more reference material, so here are a few links I particularly like for the ESP32 family:

--

--

AtomicHaggis

I’m a technology professional with experience in embedded systems, Linux, ARM, MIPS, RISC, Android, Apple and Windows. I love retro gaming, music and the arts.