Investigating the ESP32 Microcontroller

ESP32 DevKit-C

3/14/2023

After re-introducing myself to the ESP8266 module 


I became aware of it’s successor, the ESP32. A quick search on ebay revealed a 

very inexpensive development board built around this module with on-board CH 340C 

USB-Serial converter, 3.3v power regulator and a few basic buttons and LEDs

I was able to get 3 of the boards shown for around $13. (a little more than $4 each)


Here’s a list of the microcontrollers’s features:


IDE Selection and Setup

Although the most popular way to develop code for this device is by using the 

Arduino IDE, I chose to setup an Eclipse environment since that’s what I used 

for the ESP8266 and other 32bit microcontrollers.  Espressif offers a couple of ways

to do this. First there’s an Espressif IDF Eclipse Plugin that has everything you need to

add to an existing eclipse CDC environment. Unfortunately the version of eclipse I had

installed was not supported so a fresh installation was required. This process took me 

much longer than it should simply because I didn’t follow the instructions EXACTLY 

as posted on the website. (a couple of steps seemed redundant and I skipped them so... 

don’t do that) 

The second choice is the Espressif-IDE Offline Installer.  This is a single download that

will install a customized eclipse environment already configured with all the necessary plugins and
build tools.  I tried this method on my laptop and it worked smoothly on the first try.

Other development platforms available are VS Code, LUA, MicroPython and JavaScript.

 

Disappointments (minor)

#1. One of the great things about the ESP8266 and ESP32 devices is they come loaded with 

default firmware you can use right away via AT style command over the serial port.  

One of the first things I tried was to enter a couple simple AT commands through the 

USB-Serial port on the board.  Nothing worked…  A quick trip to the ESP32 online forums 

revealed that the default firmware on this device uses the OTHER UART port for AT commands
requiring me to pull out a external USB-Serial converter and connect it to 

UART2 on pins 16 & 17 in order to issue those commands. But I had not really planned 

on using the default firmware on this board anyway, so no big deal.

#2. Take a look at the photos below and you may spot the other minor issue. Once placed in a
solderless breadboard, the board is so wide that, on one side, it leaves no breadboard pins exposed
to make connections with the board pins. I was forced to add some wires running underneath the board
to provide access to those signals at the ends of the breadboard. 


#3. The build environment consists of the Cmake tools surrounded by a number of python scripts that
don’t always talk to eclipse as expected, resulting in the IDE sometimes reporting 

a symbol as “undefined” even though the project compiles without error. Also occasionally, 

eclipse will lock up while re-configuring or index building. (this MIGHT be only on my installation though).

Cool Stuff

Once I got comfortable with the ESP IDF (IoT Development Framework) I was pleased to 

discover that most of the digital peripherals can have their I/O signals mapped to almost ANY 

GPIO pin. For instance, The default SDA pin for I2C0 is  pin 18 and SCL is pin 22. I have a 

2 pin connector on my OLED display that requires the pins to be next to one another.
It was a simple matter to configure pin 23 as SDA and everything worked as expected.
This could be a handy feature if you decided not to add those extra wires under the board and had only
the pins on one side to work with. Remapping in software is simple.

The IDF makes configuring clocks and timers very simple just supply the frequency in Hz 

and that’s it. Unlike other devices SDKs where a pre-scaler must be selected and then the 

another value must be calculated to get the desired clock or timer frequency.

Along with API functions for all the common peripherals, the IDF includes interfaces for 

things like LCDs, SD cards, PWM Motor control, and even IR remotes (like for your TV). 

Although the board comes with a ‘Boot” button you can press while resetting to get it into bootloader mode, this board has circuitry that will use the RTS & DTR outputs from the USB-Serial chip to activate the necessary signals via the flashing software.


There’s an operating system (sort of)

The underlying framework employs a Real Time Operating System (freeRTOS ) 

allowing one to assign program functionality to “tasks” that can be assigned to either of 

the two cores and also assigned a priority. Each task will be given a slice of time to execute 

The RTOS helps insure that the Wireless functions are given enough processing time to 

avoid timeouts and disconnections.

This is something new for me and I had to adjust the way I coded some functions to 

avoid stealing too much time with things like long looping style delays as this would cause an 

exception that would post an error message and reboot the device. 

For longer delays (>10ms ), the IDF provides a “task safe” delay function. Shorter delays, in the microsecond range can be accomplished using timers and interrupts. Most IDF functions take care to
not block other tasks. For example, you can configure the function that reads data from the UART
to “wait forever” and it will do so while allowing other tasks to execute and not produce an exception.    


Support

The ESP-IDF Programming Guide is over 2700 pages long and I really CANNOT say they go 

into a lot of detail describing every function. There’s just a ton of stuff going on there.

Fortunately, there’s an active community at  https://www.esp32.com/

I had best luck just making a Google search starting with “ESP32” and my issue.

This usually led me to the ESP32 forum but easier than searching the site directly.

ESP32 on a Breadboard 

Update: 09/17/2023  - Here's my solution for the breadboard width issue.
I cut the solderless breadboard in half then glued it back together with hot glue using a wider center gap.
Finally I filled the gap with a bunch more hot glue.
This exposes two rows of breadboard pins on either side of the module.

Update: 11/16/2023  - More cool stuff, The Touch Inputs.
I recently explored the ESP32's Touch Sensor support. This allows users to connect a number of pins to "Touch Pads" designed in such a way that placing a finger very near them will cause a change in capacitance which can in turn be detected by the processor. I created a DIY touch key pad by soldering wires to pads on a scrap of breadboard. Sensor input rows were placed around rows that were grounded. The whole thing was then covered with a piece of tape and black dots marked the key positions. (see photos below)
The configuration code took only 6 lines of code. In my case reading a particular touch pad that was not touched returned a value of around  1680 while a pad being touched returned around 1400.
If you plan on creating a custom printed circuit board for your project, incorporating touch pad runs should be quite easy.   I've added a new sample project "uart0_touch.zip" below in the download section.

Enjoy

D.I.Y.  touchpad connections

D.I.Y.  touchpad covered

Description of download links:
ESP32-DevKitC32B_Schematic     ESP32 Board Schematic
esp32-wroom-32e_esp32-wroom-32ue_datasheet_en.pdf       ESP32 Datasheet
DVM_demo.zip DAC/ADC/OLED LCD demo project
uart0_16x2LCD.zip 16x2 LCD demo project
uart0_softap.zip Soft Access Point demo project
uart0_touch.zip Touchpad demo project
utility_template.zip uart, timer, utility template project