SARA's ESP32 Beginnings

The SARA Christmas Dinner, 11 Dec 2018, at Roma's Backdoor in Owosso provided six members with an ESP32-WROOM-32D circuit board. THANK YOU Digi-Key! The members were challenged to bring an example project (or more) to a club night in 2019 for a 'show-and-tell'. Thus kicking off this page to try and track whatever anyone is doing and establish some basic information to help get everone started.

SARA's Initial ESP32 Links

The following list was posted to our site a couple of days after the 2018 Christmas dinner where six members got new ESP32 development boards. Hoping to spur interest and get some projects started with ESP32 microcontrollers.

Review Micros = Computer / Controller Concepts

A 'computer' usually has capability to run a program and modify the program flow and directions based on inputs. Program flow changes as the program runs. Usually direction will be based upon mathematical/logical calculations derived from the various inputs. A 'controller' uses inputs to directly control outputs and runs the same program flow. Inputs are used to modify outputs in a direct manner.

Most 'controller boards' have similar general characteristics. Power and ground connections; analog / digital inputs / PWM / OODO / AREF; reset button; power indicator / voltage regulator(s); USB; serial I/O; I2C are the popular ones with most of today's controllers. Also, WIFI and Bluetooth are becoming nearly standard (these allow for 'wireless' programing. The interior controller logic (high level) are very similar and utilizes C, Python, Ruby, etc. languages. This means you can usually migrate from one controller to another by passing the base code through the proper IDE. The code reuse can be very high in microcontroller projects, making them ideal for many home developed projects.

The Arduino, ESR8266, ESP32, etc. (insert long list here) series of controllers is a great example. They can all be developed on the Arduino IDE (free program). So, lets get into the ESP32 in particular.

ESP32 Basic Development

The ESP32 is one of the hottest new wireless controller chips, it offers both Bluetooth Low Energy and WiFi radios rolled up with a 32-bit dual core processor. The ESP32 is packed with every kind of peripheral you probably would wish for. The company, AI-Thinker, which makes the most popular ESP8266 modules - they started full-scale production in October, 2016. So lets provide a starting point for our SARA members. First suggestion is the ESP32 Page at Expressif and then Expressif's ESP32 Getting Started page. Continuing at: YouTube ESP32 Projects so see a few ideas others have tried. Follow with your own plan!

A quick board compare for some microcontrollers:

  SPECS / Board  ESP32  ESP8266 Arduino UNO
Number of Cores211
Architure32 bit32 bit8 bit
CPU Frequency160 MHz80 MHz16 MHz
RAM512 KB160 KB2 KB
Flash16 MB16 MB32 KB
Number GPIO Pins    361714
Busses "8266"+CAN   "UNO" + I2S   SPI,I2C, UART  
ADC Pins1816
DAC Pins100

A Development Diagram shows the basic layout of what you will be using for a project.

ESP Development Diagram for ESP32

     ESP Development Diagram for ESP32


Things are still in a state of flux on the software side (high tech means continual improvement equals continous changes), but the basics of writing, compiling, and flashing code unto the chip remains a stable for working environment for development with the ESP32.

The ESP32 module comes preloaded with a ROM image using the AT command set, similar to the ESP8266 module if you worked on those. If you want to waste 95% of the ESP32's potential using it as a glorified serial-to-WiFi modem, you're setup out of the box! But you should all want to dig a little deeper and gain from the ESP32's added power and flexability.

A WORD OF CAUTION: as you shop the different ESP32 development kits, watch the pinouts, some have more (or less) physical pins, meaning some have better capabilities to support your projects. I am not certain if with the same number of pins between parts that the same configuratrions are used... you MUST be looking specifically at what signal goes to what pin. I think this is a problem for some when the start using a 'prepared' sketch on different hardware. Just know what you have and what the sketch is written for, they can be very different. Know that the term 'ESP32' can mean the development tyle boards or just the processor IC assembly. Read and act carefully.

The programming toolchain for the ESP32 is pretty straightforward and uses C as the base language (most flexibity in code reuse). We suggest using Espressif's software library (esp-idf), a cross-compiler and build tools that are specific to the chip (xtensa-esp32-*), and then use a utility to flash the resulting binary file to the ESP32 device. So the following can be used as a guide for that. Next we'll get an Espressif's demo application compiled and flashed into the ESP32. So we will have everything running on your system.

Assembling the Tool Set

Your first stop is the Espressif IoT Development Framework (esp-idf) GitHub We strongly recommend cloning the repository to your local computer because it's frequently updated and you'll want to keep it up to date. Here's the command that worked on a Linux machine.

git clone --recursive

Note the recursive option which pulls down all submodules that the framework depends on: in this case some binary blob libraries in components/esp32/lib and components/bt/lib as well as the program that will actually flash the chip for us.

If you just download the zip file from GitHub, it will be missing these essential pieces. Because of the submodules, you'll also need to do a two-step to keep everything current. git pull works for the top level, and git submodule update --recursive updates all of the submodules.

Now off to get the cross-compiler toolchain. There are instructions for your particular operating system inside your system's docs folder. Instructions for Linux, MacOS, and Windows are all there and are the fastest way to get you up and running. Just download the binary stuff from the location listed in the setup file. This is especially true of Windows, where the people at Espressif have pre-packaged all of the command-line tools that you're going to need. Download the 'toolchain zip file', unzip, and you're almost there.

Environment Variables, Part I

The computer needs to know where you've stored the cross-compiler components, and regardless of which operating system you're using, you have to explictly tell it. On Linux and Mac, export PATH=$PATH:/path/to/esp/xtensa-esp32-elf/bin will work, where /path/to/esp is wherever you unzipped the cross-compiler binaries. On Windows, you can either set the path permanently by writing export IDF_PATH="C:/path/to/esp-idf into a file called C:/msys32/etc/profile.d/esp-path or by typing the same export command every time you run C:\msys32\msys2_shell.cmd.

Coding, Flashing, Hello World!

At this point, you should have all the toolchain pieces together. It's time to check out the template application: git clone Now simply open up a terminal, cd into the application's directory and type make. Nothing happens.

Environment Variables, Part II

That's right, you need more paths setup. The makefile in the sample application needs to know where the main makefile framework (in esp-idf) is located. The documentation that comes with the template application suggests defining an environment variable: export IDF_PATH=/path/to/esp-idf. This is the same across all systems. You might want to write a shell script or batch file to do this for you and include it within your project.

ESP32 MenuConfig Image


One of the real nice features of the IDF is the menu-driven configuration. The menu options mkay change as more functionality gets implemented and it is a good probablity that changes will continue. You can control a lot of your platform-specific settings: like which TTY or COM port you're using, what baud rate, what speed you'd like the ESP32's cores to run at, etc. Pay attention to "Serial flasher config" and browse through "Component config" at the very least to insure it what you desire..

Since the target is constantly moving, not much advice we could offer will still be valid in a short future. You must go through each menu entry and make sure that it matches your system requirements. The results of this configuration, when you hit the "Save" option, will be stored in an sdkconfig file. You can copy this between projects if you don't want to go through the menus all over again. Click here and watch the video Expressif IoT Menu as to what we are talking about.

One More Thing

Now you're almost set. If you flash the demo app right now, it won't be able to connect to your WiFi network without your credentials. Open up the main/main.c, find the "SSID" and "password" fields, and enter the particulars for your home network. Since this is just a test of the toolchain, it's optional, but it feels good to know that the ESP32 can get online.

Flashing the Chip

With the configuration done, you're ready to connect up the serial port and flash the program. To put the chip in the bootloader mode, you need to hold the boot-mode pin, GPIO0, grounded while grounding and releasing the enable pin, EN. If you do this with a terminal application running, you'll see "waiting for download" typed out. Close your terminal program, type make flash, and then re-open the terminal program and you should see lots of debugging info as it attempts to connect to your WiFi.

Now you're in the loop of coding, flashing, and debugging. Sure, this demo application does not really do anything useful. The real point is that if you've gotten this far, you can now compile, flash, and run code on the ESP32 device. And that's really you're first step to really usng the ESP32!


Getting up and running is "easy". Clone the repository with the esp-idf libraries, download and unzip the binary toolchain, and clone the template app. There are two environment variables you have to define: one for the path to the toolchain binaries, and another for the location of the libraries. Run make menuconfig and make flash inside the template application, and you should be off and running.

On a Linux system, here is a setup script that does everything mentioned above. Create a directory where you'd like everything installed, copy this file in there, type . and watch it go. If you've installed things before, it pulls down the latest version of everything from GitHub and re-defines the environment variables for you. Even if you don't want to use it or have an odd setup, reading through it is a handy checklist to make sure that you've got everything accounted for. Let use know if it doesn't work for you, and we'll try to fix it.

Note that although this sounds like a lot of work, it's all a one-time setup procedure. For your next program, you'll just copy into the demo application folder, get into main/main.c and start coding you project. Depending on how you've configured things, you may need to set those two environment variables again (make a script/batch file!) but that is it.

On the subject of coding, there is more than a little bit of black magic in getting a dual-core microcontroller to play along with a real-time operating system. If you've never done so, stepping up to the ESP32 is going to be a bit of a learning experience. We'll cover FreeRTOS and some of its programming conventions as they apply to the ESP32 next time. Stay tuned, and let us know in the comments if you give this a try, or want to see anything else.

Some Supporting Documents

Some Supplier Links

  • AliExpress Shopping Site ~ Search for the 37 in 1 box Sensor Kit. ~$20 for a box full of sensors for doing development on microcontroller systems - just watch the voltage specifications. Some can be 5 volt and other 3.3 volt. Care is needed to keep the smoke inside the device.
  • Banggood Where to buy inexpensive electronics (and more)


Go back to top ↑