ESP32 (with Arduino)

ESP32 microcontroller

ESP32 is a series of cheap microcontrollers with itegrated WI-Fi and Bluetooth.  They run either 160MHZ or 240MHZ and therefore much more capable that the standard Arduino Uno v3.

There are many different actual physical formfactor boards with the chip embedded. It can be quite overwhleming to choose which one to use. In general they all work and what is most confusing is the pin mapping. 


Technical differences between Arduino Uno and ESP32

The ESP32 Mini form factor

This formfactor version of ESP32 is called Wemos D1 ESP32 or MH ET LIVE ESP32DevKIT or ESP32 Mini kit.

One version of the ESP32 board  matches the Wemos D1 Mini footprint. This version works with some of the small wemos shields.

The small formfactor and the avaliability of shields makes it a good starting point and we will use this version for the toturials here. 

Getting started

For ESP32 to run as an Arduino board we need to install the board definition in the Arduino IDE and we need to install USB serial drivers.

1.

Install Arduino

Download Arduino ide from here wwww.arduino.cc -> Download -> Arduino IDE (not Online version).

2.

Add the board to settings

Start Arduino and open the Preferences window (Arduino or Files -> Preferences).

Enter the following line into the Additional Board Manager URLs field:

https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

3.

Install ESP32 Board specifications

Open Boards Manager from Tools > Board menu and install ESP32 platform.

Select your ESP32 board from Tools > Board menu after installation

4.

Choose the board

Open Boards Manager from Tools > Board menu and install ESP32 platform.

Select your ESP32 board from Tools > Board menu after installation

"MH ET LIVE ESP32MiniKIT"


5.

Choose the right port

For Mac OSX / LINUX: It will usually be called something like USBUart (see image).

For Windows: I will usually be the largest port number. 

In both cases, the simplest way to find the right port is to unplug the board. Se which ports are available. Then plug-in the board and choose the port that showed up.

If the port does show up then try to restart your computer. Look in your device-manager to see if the driver has been installed and look online for a more recent or alternative driver.

While you are at it, you can also change the upload speed to "921600". It will make the upload significantly quicker.

6.

OPTIONAL: Install USB Serial driver if port does NOT show up

To be able to communicate with the Wemos board you will need to install the Serial drivers. On the following link you can find the latest driver:

https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers

USE THIS DRIVER FOR MAC: http://www.wch.cn/downloads/CH34XSER_MAC_ZIP.html 

Restart your computer - and check step 5 again 

For cp2104 use this driver: https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers?tab=downloads



7.

Verify that everything is setup properly

When you have gone through the different steps then your Board configuration should look like this:

8.

Upload test code

Copy the code below into the editor

void setup() {

 Serial.begin(9600);

}


void loop() {

 Serial.println(millis());

 delay(1000);

}

Press the right pointing arrow button in the icon menu. 

If everything works the status bar below should say "Done Uploading" as seen on the image.

9.

Show the serial monitor


10.

Show the serial plotter


11.

Understanding the pin naming convention

The board has two rows of pins on each side. E.g. pin IO25 would be the third pinholde from the top on the the outer row on the right side. The pins with a IO + number can be used as either an input or an output. To read a digital input (e.g. a button) from  pin IO25 you would write something like:

void setup() {

 Serial.begin(9600);

 pinMode(25, INPUT_PULLUP);

}


void loop() {

 boolean value = digitalRead(25);

 Serial.println(value);

 delay(1000);

}

Below is the diagram of a button connected to IO25 and ground.

Congratulations

You now have ESP32 running as an Arduino board and you can now use the board in the same ways as you would with a normal Arduino board. As you dig into the details you find that there integrate differences (see below).

Have a look in the files->Examples menu in the ESP32 section. It is filled with eamples of what you can do with the board.

Also, have a look in the Arduino section of the website for how to use input and output.

Also, have look that smart light toturial get started with working with wi-fi and browser based control.

The pin maping of the ESP32 Mini

This is a relatively technical diagram. You will not need this in the beginning but at a later state this will help you to look up the different pins and what they can do. The green boxes indicate the the pin can be used to read analog signals (0v to 3.3v). The pink boxes indicates that the pin can be used as touch sensor.