
The ESP32 is the newest* super powered IoT/Arduino board you are going to want in your arsenal.
I have long been a fan of the ESP8266, especially the cheap Chinese NodeMCU boards, so when I saw the faster, more capable ESP32 had Arduino compatibility, I had to give it a try!
* Yeah, it’s been talked about since 2015, but really it’s not been convenient to play with until now ๐
ESP32 Arduino Power House
How big and capable? It’s a 32 bit board, dual-core running at … wait for it … 160mhz (or as high as 240mhz)!
There’s 128KB of ROM, 416KB SRAM, and Flash memory is external (I think mine is 4MB, max 64MB).
So it is fast, has a bunch of memory, and does wifi. Cool?
One downside of the ESP8266 was its lack of pins. Not a problem here, there are 36 GPIO pins, including:
- Up to 16 channels ADC
- 2x 8-bit DAC (actual analog!)
- 16x PWM
- 10x capacitive touch sensing
- 2x UART
- 2x I2C
- 4x SPI
- 2x I2S
Yeah, it’s not the first 32 bit board out there, but this is still serious business for Arduino IoT fans!
While I have friends who swear by the Teensy boards, I just don’t see the point in them now the ESP32 is packaged in a convenient, wifi-enabled board.
Oh, and there is more – It doesn’t just do wifi by the way, as well as wifi it also has Bluetooth/BLE!

Buying an ESP32
The board I purchased was the $15 Espressif ESP32 board from Adafruit.
Sparkfun also have a board, and I am sure there will be many more out there.
The chip is causing a lot of buzz so I have no doubt the dev board clones will be coming thick and fast too.
Arduino with the ESP32
Like with many third-party Arduino boards, you need to add hardware definitions, but right now it is still early in the development so you need to get the files from the git repo.
Download and uncompress and place in your Hardware folder.
Within the tools folder you will find a get.py python script that will install the compiler etc.
python ./get.py
How to Connect to Wifi on the ESP32
The wifi on the ESP32 is fast and is SSL compatible, which is nice because Maker Hacks just went 100% HTTPS ๐ There is a secure HTTP client available here that follows 301 redirects, as yet I haven’t got it working (I think I messed up my libraries) but I will update when I do get it running.
ESP32 has plenty of memory so can cope with the large strings that make up web pages, JSON/XML data, and everything we throw at internet of things devices nowadays.
Let’s try some code, shall we?
In this example we will connect via wifi to a website and switch on an LED when stuff is happening. Nothing too strenuous ๐
Just to make it extra fancy I placed a 3d printed Stormtrooper head over the LED ๐
ESP32 Code
// wifi library
#include <WiFi.h>
// WiFi network name and password:
const char * networkName = "YOUR_WIFI_HERE";
const char * networkPswd = "PASSWORD_HERE";
// The domain to request from:
const char * hostDomain = "chrisg.org";
const int hostPort = 80;
// whichever pin your LED is attached
const int LED_PIN = 5;
void setup()
{
// set the baud rate:
Serial.begin(115200);
// set the LED pin to output
pinMode(LED_PIN, OUTPUT);
// Function for the wifi, see below
connectToWiFi(networkName, networkPswd);
}
// do this forever
void loop()
{
// LED on
digitalWrite(LED_PIN, HIGH);
// get the web page
requestURL(hostDomain, hostPort);
// LED off
digitalWrite(LED_PIN, LOW);
// wait a second
delay(1000);
}
// function to connect
void connectToWiFi(const char * ssid, const char * pwd)
{
// init the LED state
int ledState = 0;
// connecting message
Serial.println("Connecting to your network: " + String(ssid));
// start the wifi
WiFi.begin(ssid, pwd);
// loop while not connected
while (WiFi.status() != WL_CONNECTED)
{
// Blink LED
digitalWrite(LED_PIN, ledState);
// switch state between on and off
ledState = (ledState + 1) % 2;
// wait half a second
delay(500);
// dots
Serial.print(".");
}
// blank line
Serial.println();
// yay!
Serial.println("WiFi connected!");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
// grab the html
void requestURL(const char * host, uint8_t port)
{
// status
Serial.println("Connecting to domain: " + String(host));
// Use WiFiClient to get TCP connection
WiFiClient client;
if (!client.connect(host, port))
{
Serial.println("connection failed");
return;
}
// connected!
Serial.println("Connected!");
// send the HTTP GET request
client.print((String)"GET / HTTP/1.1\r\n" +
"Host: " + String(host) + "\r\n" +
"Connection: close\r\n\r\n");
// timeout
unsigned long timeout = millis();
while (client.available() == 0)
{
if (millis() - timeout > 5000)
{
Serial.println(">>> Client Timeout !");
client.stop();
return;
}
}
// Read + print to serial monitor
while (client.available())
{
String line = client.readStringUntil('\r');
Serial.print(line);
}
// all done
Serial.println();
Serial.println("closing connection");
client.stop();
}