ESP32-S2 Thing Plus Hookup Guide

Pages
Contributors: QCPete, santaimpersonator
Favorited Favorite 3

Introduction

The ESP32-S2 Thing Plus is a feather form-factor development board with the improved ESP32-S2 module, from Espressif. The new ESP32-S2 module addresses the security flaws in the original ESP32. While the ESP32-S2 does include improved security features, it lacks the Bluetooth capabilities of the original ESP32 module.

SparkFun Thing Plus - ESP32-S2 WROOM

SparkFun Thing Plus - ESP32-S2 WROOM

WRL-17743
$21.50
3

Not Yet Implemented: The Arduino core for the ESP32 microcontroller are still a work in progress. There are a handful of peripherals and features that have yet to be implemented, including:

The peripherals are available (if, also, still in their infancy) in the IoT Development Framework for the ESP32. If your application requires any of the features above, consider giving the ESP-IDF a try! (Updated: June 2022.)

Required Materials

To get started, users will need a few items. Now some users may have a few of these items, feel free to modify your cart accordingly.

  • ESP32-S2 Thing Plus
  • USB 3.1 Cable A to C - 3 Foot - The USB interface serves two purposes: it powers the board and allows you to upload programs to it. (*If your computer doesn't provide a USB-A slot, then you will need to choose an appropriate cable or purchase an adapter as well.)
  • Computer with the an operating system (OS) that is compatible with all the software installation requirements.
SparkFun Thing Plus - ESP32-S2 WROOM

SparkFun Thing Plus - ESP32-S2 WROOM

WRL-17743
$21.50
3
USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$5.50
4

Click the buttons above to toggle the additional materials based on the options you
wish to use. Feel free to modify the items in your cart to fit your needs.


Li-Po Battery

For mobile applications, users will want to pick up a single-cell LiPo battery from our catalog. Below, are a few available options:

Lithium Ion Battery - 400mAh

Lithium Ion Battery - 400mAh

PRT-13851
$5.50
11
Lithium Ion Battery - 2Ah

Lithium Ion Battery - 2Ah

PRT-13855
$13.95
9
Lithium Ion Battery - 110mAh

Lithium Ion Battery - 110mAh

PRT-13853
$5.50
4

Lithium Ion Battery - 1Ah

PRT-13813
8 Retired

Jumper Modification

To modify the jumpers, users will need soldering equipment and/or a knife.

Solder Lead Free - 100-gram Spool

Solder Lead Free - 100-gram Spool

TOL-09325
$9.95
8
Chip Quik No-Clean Flux Pen  - 10mL

Chip Quik No-Clean Flux Pen - 10mL

TOL-14579
$7.95
4
Hobby Knife

Hobby Knife

TOL-09200
$3.50
2

Weller WLC100 Soldering Station

TOL-14228
2 Retired

Headers & Accessories

Headers are great for development purposes, letting users swap parts with just a set of jumper wires. If you would like to add headers to your board, check out some of the options for the Thing Plus or Feather form factor boards below. For a full selection of our available Headers or Soldering Tools, click on the associated links.

Break Away Headers - Straight

Break Away Headers - Straight

PRT-00116
$1.75
20
Feather Stackable Header Kit

Feather Stackable Header Kit

PRT-15187
$1.75
Header - 8-pin Female (PTH, 0.1")

Header - 8-pin Female (PTH, 0.1")

PRT-11895
$0.75
Female Header - 12-Pin

Female Header - 12-Pin

PRT-14321
$0.75

SparkFun Beginner Tool Kit

TOL-14681
Retired

New to soldering? Check out our Through-Hole Soldering Tutorial for a quick introduction!

How to Work with Jumper Pads and PCB Traces

April 2, 2018

Handling PCB jumper pads and traces is an essential skill. Learn how to cut a PCB trace, add a solder jumper between pads to reroute connections, and repair a trace with the green wire method if a trace is damaged.

JTAG Functionality

Users interested in JTAG applications (i.e. programming and debugging the ESP32) will need an JTAG Programmer and need to solder on a JTAG header. We recommend these programmers from our catalog:

Header - 2x5 Pin (Male, 1.27mm)

Header - 2x5 Pin (Male, 1.27mm)

PRT-15362
$1.75

J-Link EDU Mini Programmer

PGM-15345
1 Retired

J-Link EDU Base Programmer

PGM-15346
2 Retired

J-Link BASE Compact Programmer

PGM-15347
Retired
JTAG 20 Pin 0.1 In. To 10 Pin 0.05 In. Adapter

JTAG 20 Pin 0.1 In. To 10 Pin 0.05 In. Adapter

PGM-18421
Retired

Suggested Reading

As a more professionally oriented product, we will skip over the more fundamental tutorials (i.e. Ohm's Law and What is Electricity?). However, below are a few tutorials that may help users familiarize themselves with various aspects of the board.

How to Solder: Through-Hole Soldering

This tutorial covers everything you need to know about through-hole soldering.

Serial Communication

Asynchronous serial communication concepts: packets, signal levels, baud rates, UARTs and more!

Serial Peripheral Interface (SPI)

SPI is commonly used to connect microcontrollers to peripherals such as sensors, shift registers, and SD cards.

Pulse Width Modulation

An introduction to the concept of Pulse Width Modulation.

Logic Levels

Learn the difference between 3.3V and 5V devices and logic levels.

I2C

An introduction to I2C, one of the main embedded communications protocols in use today.

Analog vs. Digital

This tutorial covers the concept of analog and digital signals, as they relate to electronics.

How to Work with Jumper Pads and PCB Traces

Handling PCB jumper pads and traces is an essential skill. Learn how to cut a PCB trace, add a solder jumper between pads to reroute connections, and repair a trace with the green wire method if a trace is damaged.

Installing Arduino IDE

A step-by-step guide to installing and testing the Arduino software on Windows, Mac, and Linux.

ESP32 Thing Plus Hookup Guide

Hookup guide for the ESP32 Thing Plus (Micro-B) using the ESP32 WROOM's WiFi/Bluetooth system-on-chip in Arduino.

Installing Board Definitions in the Arduino IDE

How do I install a custom Arduino board/core? It's easy! This tutorial will go over how to install an Arduino board definition using the Arduino Board Manager. We will also go over manually installing third-party cores, such as the board definitions required for many of the SparkFun development boards.

Qwiic Connect System

One of the new, advanced features of the board is that it takes advantage of the Qwiic connect system. We recommend familiarizing yourself with the Logic Levels and I2C tutorials. Click on the banner above to learn more about Qwiic products.

Hardware Overview

Board Dimensions

The board dimensions are illustrated in the drawing below. The listed measurements are in inches and the two mounting holes are compatible with 4-40 standoff screws.

Board Dimensions
Board dimensions (PDF) for the ESP32-S2 Thing Plus, in inches. (Click to enlarge)

USB-C Connector

The USB connector is provided to power and program the board. For most users, it will be the primary programing interface for the ESP32-S2.

USB-C Connector
USB-C connector on the ESP32-S2 Thing Plus. (Click to enlarge)

TC7USB40MU USB Switch

The TC7USB40MU is used to switch the data lines for the USB-C connection, between the ESP32-S2 module's native USB pins or its UART pins, through a CP2102 Serial-to-UART bridge. There is a jumper on the back of the board to control the USB switch; by default, the data lines from the USB-C connector are tied to the CP2102 Serial-to-UART bridge.

USB Switch
Functional block diagram for the TC7USB40MU USB switch. (Click to enlarge)

CP2102 Serial-to-UART

The CP2102 allows the ESP32-S2 to communicate with a computer/host device through its USB-C connection. This allows the board to show up as a device on the serial (or COM) port of the computer. Users will need to install the latest drivers for the computer to recognize the board (see Software Overview section).

Power

The ESP32-S2 Thing Plus only requires 3.3V to power the board. However, the simplest method to power the board is with the USB-C connector. There are additional power pins available on the board:

  • 3.3V - A regulated 3.3V voltage source.
    • Regulated from the USB 5V power and/or battery connection.
    • Used to power the ESP32-S2 module and Qwiic I2C bus.
  • USB - The voltage from the USB-C connector, usually 5V.
  • VBAT - The voltage from the JST battery connector; meant for single cell LiPo batteries.
  • GND - The common ground or the 0V reference for the voltage supplies.

Power connections
ESP32-S2 Thing Plus power connections. (Click to enlarge)

Charging Circuit

The charging circuit utilizes the MCP73831 linear charge management controller and is powered directly from the USB-C connector or USB. The controller is configured for a 500mA charge rate by default; there is a jumper on the back of the boards for users to lower the charge rate to 100mA. Battery charging is indicated when the yellow, CHG LED. If the charge controller is shutdown or charging is complete, the CHG LED will turn off. For more information, please refer to the MCP73831 datasheet.

ESP32-S2 Module

The ESP32-S2 WROOM module from Espressif is the brains of the ESP32-S2 Thing Plus. While the new ESP32-S2 module does include improved security features to addresses the security flaws in the original ESP32, it lacks the Bluetooth capabilities of the original module. For more details check out the datasheets for the ESP32-S2 chipset and the ESP32-S2 WROOM module.

  • Xtensa® Single-Core 32-bit LX7 Microprocessor (up to 240MHz)
    • RISC-V ULP Coprocessor
    • 128KB ROM and 320KB SRAM
    • 4MB of Embedded SPI Flash Storage
  • Cryptographic Hardware Accelerators
    • AES, ECB/CBC/OFB/CFB/CTR, GCM, SHA, RSA, and ECC (Digital Signature)
  • Physical Security Features
    • Transparent external flash and RAM encryption (AES-XTS)
    • Secure Boot feature ensures only signed firmware (with RSA-PSS signature) is booted
    • HMAC and Digital Signature modules use software inaccessible keys to generate SHA-MAC and MAC signatures
  • Integrated 802.11 b/g/n WiFi 2.4GHz Transceiver (up to 150Mbps)
  • Integrated Temperature Sensor (-20°C to 110°C)
  • 34 GPIO (excluding strapping pins)
    • 1x USB OTG Interface
    • 1x DVP Camera Interface
    • 1x LCD Interface
  • Operating Voltage: 3.0 to 3.6V
    • WiFi: 310mA (peak)
    • Light-Sleep: 550µA
    • Deep-Sleep: 20-235µA
ESP32-S2
ESP32-S2 module on the ESP32-S2 Thing Plus. (Click to enlarge)

Note: Users should be aware of the following nuances and details of this board

Note: While most users will utilize the USB connection for serial programming, the ESP32-S2 can also be programmed through its JTAG or SWD pins. This might is useful for individuals developing and debugging firmware that would be flashed directly onto the module, such as in production for commercial applications.

ESP32-S2 Thing Plus's JATG pins
The JTAG pins on the ESP32-S2 Thing Plus. (Click to enlarge)

Users can also utilize the ESP32-S2 as a JTAG bridge; check out the project from Espressif for more information.

Peripherals and I/O

Note: Users should be aware of the following nuances of this board

The pins from the ESP32-S2 module are broken out into a feather form factor layout. There are 21 I/O pins broken out on this board, with 8 I/O pads on the back of the board. All of the ESP32-S2 Thing Plus pins are broken out with .1" pitch spacing for headers. With the ESP32's pin multiplexing, various pins will be capable of several functionalities. For more technical specifications on the I/O pins, you can refer to the ESP32-S2 datasheet.

  • 16x 12-bit ADC Channels
  • 2x 8-bit DAC
  • 14x Capacitive Touch Sensing
  • 4x SPI (only one is configured by default in the Arduino IDE)
  • 1x I2S
  • 2x I2C (only one is configured by default in the Arduino IDE)
  • 2x UART (both are configured by default in the Arduino IDE, but one UART is used for bootloading/debug)
  • 8x PWM Channels
  • 1x DVP Camera Interface
  • 1x LCD Interface

Graphical datasheet
Graphical datasheet for the ESP32-S2 Thing Plus. (Click to enlarge)

Note: Users should be aware of the following limitations for the board in the Arduino IDE.

  • Not all of the features, listed above, are available in the Arduino IDE. For the full capabilities of the ESP32-S2, the Espressif IDF should be utilized.
  • Only one I2C bus is defined.
  • Only two UART interfaces are available.
    • UART (USB): Serial
    • RX1/TX1 Pins: Serial1
  • Only one SPI bus is defined.
  • The bit-width for the ADC2 channels needs to be set when reading ADC values.
    • Setting the bit-width before taking any ADC readings doesn't work; the bit-width must be set, when the making ADC readings.
    • The example code below, properly demonstrates how to read values from the ADC2 channels.

    Download the ADC Example Code

Buttons

There are two buttons on ESP32-S2 Thing Plus; a Reset and IO0 button.

Reset Button

The reset (RST) button allows users to reset the program running on the ESP32-S2 module without unplugging the board.

Reset Button
Reset button on the ESP32-S2 Thing Plus. (Click to enlarge)

User Button

Note: In order to utilize the user button, connected to IO 0, the pin mode will need to be configured as an input with an internal pullup (i.e. INPUT_PULLUP); see an example below.

pinMode(D0, INPUT_PULLUP);

The user (0 ) button allows users to short IO 0 to ground (GND).

IO 0 Button
IO 0 button on the ESP32-S2 Thing Plus. (Click to enlarge)

Indicator LEDs

There are two indicator LEDs on the ESP32-S2 Thing Plus:

  • Status/Pin 13 (Blue)
  • Battery Charging (Yellow)

Battery Charging LED

The yellow, CHG LED will light while a battery is being charged through the charging circuit. The LED will be off when no battery is present (*dimmed), when the charge management controller is in standby (after the battery charging has been completed), or when the charge management controller is shutdown. The LED will be on when the charge management controller is in the process of charging the battery. For more information, please refer to the MCP73831 datasheet.

Charge LED
The battery charging (CHG) LED indicator on the ESP32-S2 Thing Plus. (Click to enlarge)
Charge Cycle State STAT1
Shutdown
  • Thermal Shutdown
  • VDD < VBAT
Off (High Z)
No Battery Present Dimmed (High Z)
Charge Complete – Standby Off (H)
Preconditioning On (L)
Constant-Current Fast Charge On (L)
Constant Voltage On (L)

STAT LED

The blue, status (13) LED is typically used as a test or status LED to make sure that a board is working or for basic debugging. This indicator is connected to GPIO 18.

Status LED
The status (13) LED indicator on the ESP32-S2 Thing Plus. (Click to enlarge)

Jumpers

There are three jumpers on the back of the board that can be used to easily modify the hardware connections on the board.

  • USB - This jumper can be used to control the USB-C data line connections through the TC7USB40MU USB switch.
    • By default, the data lines are connected to the CP2102 Serial-to-UART bridge; and therefore, tied to the ESP32-S2's UART pins.
  • CHG - This jumper can be used to modify the charging rate to the LiPo JST connector.
    • By default, the charge rate is configured to 500mA.
  • GPIO18PU - This jumper can be used to disconnect the pull-up resistor on GPIO18.
Jumpers
The jumpers on the back of the ESP32-S2 Thing Plus. (Click to enlarge)

Never modified a jumper before? Check out our Jumper Pads and PCB Traces tutorial for a quick introduction!

How to Work with Jumper Pads and PCB Traces

April 2, 2018

Handling PCB jumper pads and traces is an essential skill. Learn how to cut a PCB trace, add a solder jumper between pads to reroute connections, and repair a trace with the green wire method if a trace is damaged.

Primary I2C Bus

The Qwiic connector is attached to the primary I2C bus. The primary I2C bus for this board utilizes the pin connections, detailed in the table below:

Connection VDD GND SCL SDA
Pad Number
(ESP32-S2 module)
3.3V GND IO2 IO1

Qwiic Connector

A Qwiic connector is provided for users to seamlessly integrate with SparkFun's Qwiic Ecosystem.

qwiic connector
Qwiic connector and I2C pins on the ESP32-S2 Thing Plus. (Click to enlarge)

What is Qwiic?

The Qwiic system is intended a quick, hassle-free cabling/connector system for I2C devices. Qwiic is actually a play on words between "quick" and I2C or "iic".

Features of the Qwiic System

Keep your soldering iron at bay.

Cables plug easily between boards making quick work of setting up a new prototype. We currently offer three different lengths of Qwiic cables as well as a breadboard friendly cable to connect any Qwiic enabled board to anything else. Initially you may need to solder headers onto the shield to connect your platform to the Qwiic system but once that’s done it’s plug and go!

Qwiic Cable and Board

Qwiic cables connected to Spectral Sensor Breakout

Minimize your mistakes.

How many times have you swapped the SDA and SCL wires on your breadboard hoping the sensor will start working? The Qwiic connector is polarized so you know you’ll have it wired correctly, every time, from the start.

The PCB connector is part number SM04B-SRSS (Datasheet) or equivalent. The mating connector used on cables is part number SHR04V-S-B or equivalent. This is a common and low cost connector.

JST Connector

1mm pitch, 4-pin JST connector

Expand with ease.

It’s time to leverage the power of the I2C bus! Most Qwiic boards will have two or more connectors on them allowing multiple devices to be connected.

Software Overview

Installing the CP2104 USB Driver

Note: Make sure to manually install the driver for the CP210X with the following instructions. The driver that Windows auto-installs will not work with the auto-reset circuit on the board and cause serial uploads to fail.

Users will need to install the SiLabs CP2104 Driver, which can be found here: USB to UART Bridge VCP Driver

Note: If applicable, make sure you are using the proper driver files for your CPU architecture. This is usually indicated by a folder or file name with "x86" for 32-bit processors or "x64" for 64-bit processors.

Arduino IDE

Note: For first-time users, who have never programmed before and are looking to use the Arduino IDE, we recommend beginning with the SparkFun Inventor's Kit (SIK), which includes a simpler board like the Arduino Uno or SparkFun RedBoard and is designed to help users get started programming with the Arduino IDE.

Most users may already be familiar with the Arduino IDE and it's use. However, for those of you who have never heard the name Arduino before, feel free to check out the Arduino website. To get started with using the Arduino IDE, check out our tutorials below:

Installing an Arduino Library

How do I install a custom Arduino library? It's easy! This tutorial will go over how to install an Arduino library using the Arduino Library Manager. For libraries not linked with the Arduino IDE, we will also go over manually installing an Arduino library.

What is an Arduino?

What is this 'Arduino' thing anyway? This tutorials dives into what an Arduino is and along with Arduino projects and widgets.

Installing Arduino IDE

A step-by-step guide to installing and testing the Arduino software on Windows, Mac, and Linux.

Installing Board Definitions in the Arduino IDE

How do I install a custom Arduino board/core? It's easy! This tutorial will go over how to install an Arduino board definition using the Arduino Board Manager. We will also go over manually installing third-party cores, such as the board definitions required for many of the SparkFun development boards.

Install Board Definition

Update: Espressif has released a new Arduino core supporting the ESP32-S2. Users who previously installed the ESP32 development Arduino core, will need to Remove the Arduino core through the Board Manager and then, manually delete the Arduino core files; before re-installing the latest board definitions.

Install the latest ESP32 board definitions in the Arduino IDE.

Installing Board Definitions in the Arduino IDE

September 9, 2020

How do I install a custom Arduino board/core? It's easy! This tutorial will go over how to install an Arduino board definition using the Arduino Board Manager. We will also go over manually installing third-party cores, such as the board definitions required for many of the SparkFun development boards.

Note: For more instructions, users can follow this tutorial on Installing Additional Cores provided by Arduino. Users will also need the .json file for the Espressif Arduino Core:

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

Hardware Assembly

USB Programming

The USB connection is utilized for programming and serial communication. Users only need to plug their ESP32-S2 Thing Plus into a computer using a USB-C cable.

ESP32-S2 Thing Plus USB connection
The ESP32-S2 Thing Plus with USB-C cable attached. (Click to enlarge)

Battery

For remote IoT applications, a Li-Po battery can be connected. Additionally, users may be interested in utilizing a solar panel and USB-C cable to recharge their battery.

Battery connected to the ESP32-S2 Thing Plus
The ESP32-S2 Thing Plus with a battery connected. (Click to enlarge)
Solar Panel Charger - 10W

Solar Panel Charger - 10W

PRT-16835
$18.95 $14.21
1
USB 3.1 Cable A to C - 3 Foot

USB 3.1 Cable A to C - 3 Foot

CAB-14743
$5.50
4

Note: DO NOT remove batteries by pulling on their wires. Instead, it is recommended that pair of dikes (i.e. diagonal wire cutters), pliers, or tweezers be used to pull on the JST connector housing, to avoid damaging the battery wiring.

Disconnect battery w/ dikes
Using a pair of dikes to disconnect a battery. (Click to enlarge)

Headers

The pins for the ESP32-S2 Thing Plus are broken out to 0.1"-spaced pins on the outer edges of the board. When selecting headers, be sure you are aware of the functionality you need. If you have never soldered before or need a quick refresher, check out our How to Solder: Through-Hole Soldering guide.

Soldering headers
Soldering headers to the ESP32-S2 Thing Plus.

The Feather Stackable Header Kit is a great option as it allows users to stack shields (w/ Feather footprint) or it can be placed on the a breadboard; while, the pins are still accessible from the female/male headers.

Qwiic Devices

The Qwiic system allows users to effortlessly prototype with a Qwiic compatible I2C device without soldering. Users can attach any Qwiic compatible sensor or board, with just a Qwiic cable. (*The example below, is for demonstration purposes and is not pertinent to the board functionality or this tutorial.)

Qwiic devices connected to ESP32-S2 Thing Plus
The Qwiic XA110 GPS and distance sensor boards connected to the ESP32-S2 Thing Plus.

Arduino Examples

Blink

To verify the toolchain and board are properly set up on their computer, users can upload the simplest of sketches -- Blink! The LED attached to GPIO 13 is perfect for this test. Plus, with the ESP32 attached to your computer, this is a good time to test out serial communication. Copy and paste the example sketch below into a fresh Arduino sketch:

language:c
int ledPin = 13;

void setup()
{
    pinMode(ledPin, OUTPUT);
    Serial.begin(115200);
}

void loop()
{
    Serial.println("Hello, world!");
    digitalWrite(ledPin, HIGH);
    delay(500);
    digitalWrite(ledPin, LOW);
    delay(500);
}

With everything setup correctly, upload the code! Once the code finishes transferring, open the serial monitor and set the baud rate to 115200. Users should see Hello, world!'s begin to fly by.

If the blue LED remains dimly lit, it's probably still sitting in the bootloader. After uploading a sketch, users may need to tap the RESET button to get your ESP32-S2 Thing Plus to begin running the sketch.

Example serial port output

When the ESP32 boots up, it prints out a long sequence of debug messages. These are emitted every time the chip resets -- always at 115200 baud.

WiFi

The ESP32 Arduino core includes a handful of WiFi examples, which demonstrate everything from scanning for nearby networks to sending data to a client server. Users can find the examples under the File > Examples > WiFi menu.

Here's another example using the WiFi library, which demonstrates how to connect to a nearby WiFi network and poll a remote domain (http://example.com/) as a client.

language:c
#include <WiFi.h>

// WiFi network name and password:
const char * networkName = "YOUR_NETWORK_HERE";
const char * networkPswd = "YOUR_PASSWORD_HERE";

// Internet domain to request from:
const char * hostDomain = "example.com";
const int hostPort = 80;

const int BUTTON_PIN = 0;
const int LED_PIN = 13;

void setup()
{
  // Initilize hardware:
  Serial.begin(115200);
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  pinMode(LED_PIN, OUTPUT);

  // Connect to the WiFi network (see function below loop)
  connectToWiFi(networkName, networkPswd);

  digitalWrite(LED_PIN, LOW); // LED off
  Serial.print("Press button 0 to connect to ");
  Serial.println(hostDomain);
}

void loop()
{
  if (digitalRead(BUTTON_PIN) == LOW)
  { // Check if button has been pressed
    while (digitalRead(BUTTON_PIN) == LOW)
      ; // Wait for button to be released

    digitalWrite(LED_PIN, HIGH); // Turn on LED
    requestURL(hostDomain, hostPort); // Connect to server
    digitalWrite(LED_PIN, LOW); // Turn off LED
  }
}

void connectToWiFi(const char * ssid, const char * pwd)
{
  int ledState = 0;

  printLine();
  Serial.println("Connecting to WiFi network: " + String(ssid));

  WiFi.begin(ssid, pwd);

  while (WiFi.status() != WL_CONNECTED) 
  {
    // Blink LED while we're connecting:
    digitalWrite(LED_PIN, ledState);
    ledState = (ledState + 1) % 2; // Flip ledState
    delay(500);
    Serial.print(".");
  }

  Serial.println();
  Serial.println("WiFi connected!");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
}

void requestURL(const char * host, uint8_t port)
{
  printLine();
  Serial.println("Connecting to domain: " + String(host));

  // Use WiFiClient class to create TCP connections
  WiFiClient client;
  if (!client.connect(host, port))
  {
    Serial.println("connection failed");
    return;
  }
  Serial.println("Connected!");
  printLine();

  // This will send the request to the server
  client.print((String)"GET / HTTP/1.1\r\n" +
               "Host: " + String(host) + "\r\n" +
               "Connection: close\r\n\r\n");
  unsigned long timeout = millis();
  while (client.available() == 0) 
  {
    if (millis() - timeout > 5000) 
    {
      Serial.println(">>> Client Timeout !");
      client.stop();
      return;
    }
  }

  // Read all the lines of the reply from server and print them to Serial
  while (client.available()) 
  {
    String line = client.readStringUntil('\r');
    Serial.print(line);
  }

  Serial.println();
  Serial.println("closing connection");
  client.stop();
}

void printLine()
{
  Serial.println();
  for (int i=0; i<30; i++)
    Serial.print("-");
  Serial.println();
}

Make sure to fill in the networkName and networkPswd variables with the name (or SSID) and password of your WiFi network! Then upload the code, open the Serial Monitor.

WiFi example serial terminal output

After the ESP32-S2 connects to the WiFi network, it will wait for users to press the 0 button. Tapping that will cause the ESP32 to make an HTTP request to example.com. You should see a string of HTTP headers and HTML similar to the screenshot above.

Troubleshooting Tips

Resources and Going Further

For more inspiration, check out these other ESP32 tutorials:

ESP32 Thing Hookup Guide

An introduction to the ESP32 Thing's hardware features, and a primer on using the WiFi system-on-chip in Arduino.

SparkFun ESP32 DMX to LED Shield

Learn how to utilize your DMX to LED Shield in a variety of different ways.

Using Home Assistant to Expand Your Home Automations

An introduction to Home Assistant, an open source home automation hub.

ESP32 Relay Web Server

The goal of this project is to have a website hosted on an ESP32 that controls any relay controlled device connected to a local network and keeps a dynamically updated state of those devices.