Learning Goals 5 min
Bluetooth is point-to-point and ~10 m. WiFi puts your Arduino on the same network as every laptop, phone and printer in the building — and through a router, on the public internet. The cheap, popular WiFi-capable boards are the ESP8266 family (2014) and the ESP32 family (2016, much more capable). Today you compare them and install the toolchain. By the end of this lesson you will:
- Identify the two boards: NodeMCU/Wemos D1 mini for ESP8266; ESP32 DevKit / WROOM for ESP32. Spot the differences (pin count, CPU cores, presence of Bluetooth).
- Install the ESP8266 and/or ESP32 board support packages in Arduino IDE.
- Upload a "Hello WiFi" sketch that boots, lists nearby WiFi networks, and prints them to Serial — no router login needed yet.
Warm-Up 10 min
Pull out your ESP-class board. The two most common in classrooms:
| Board | What to look for |
|---|---|
| NodeMCU ESP8266 | Long blue PCB, micro-USB, two rows of pins labelled D0..D8 + A0 + 3V3 + GND. Reset button on one end, FLASH button on the other. |
| Wemos D1 mini (ESP8266) | Tiny black board, micro-USB, single row each side. Same chip as NodeMCU, just smaller and pin-labelled D0..D8. |
| ESP32 DevKit (WROOM-32) | Bigger blue/black PCB, micro-USB, 30+ pins. Two rows of GPIO numbered 0..39 (not all usable). |
| ESP32-S3 / ESP32-C3 | Newer; USB-C, fewer pins, native USB instead of CH340. The 2024+ standard. |
One important question first
The ESP8266 and ESP32 are not Arduinos — they're different microcontroller families. We program them through the Arduino IDE thanks to the "Arduino core" project that adapts Arduino-style APIs (pinMode, digitalWrite, etc.) to the ESP's hardware.
So an ESP-flavoured sketch looks Arduino-y but uses ESP-specific libraries for WiFi, Bluetooth, etc. The basic APIs you learned in L01 carry over; the WiFi APIs are new.
New Concept · Two boards compared 20 min
The spec sheet, side by side
| Feature | ESP8266 (NodeMCU) | ESP32 (DevKit) |
|---|---|---|
| CPU | 80 MHz single core (Tensilica L106) | 240 MHz dual core (Xtensa LX6 — or RISC-V on C3) |
| RAM | 80 KB | 520 KB |
| Flash | 4 MB | 4 MB (some 16 MB) |
| WiFi | 2.4 GHz b/g/n (no 5 GHz) | 2.4 GHz b/g/n (no 5 GHz) |
| Bluetooth | None | Yes (Classic + BLE on most variants) |
| GPIO pins | ~11 usable | ~24 usable |
| ADC | 1 channel, 10-bit | 15+ channels, 12-bit |
| DAC | None | 2 channels, 8-bit |
| Logic level | 3.3 V (not 5 V tolerant on inputs) | 3.3 V (not 5 V tolerant on inputs) |
| Active current | ~80 mA | ~150 mA |
| Deep sleep | ~20 µA | ~10 µA |
| Price (2026) | Very cheap | A little more |
Which one to pick
For most school WiFi projects, either works fine. Choose based on:
- ESP8266 if: cheaper, smaller footprint, only need WiFi (no BLE), only need a few GPIO pins, just want to learn the basics.
- ESP32 if: need WiFi + BLE simultaneously, more GPIO needed, want to run TensorFlow Lite Micro (L04-34), want 12-bit ADC, want dual-core for advanced tasks.
For Cluster F's WiFi-only lessons, the ESP8266 is plenty.
The 3.3 V gotcha
Both boards are 3.3 V logic only. Plugging a 5 V signal into a GPIO can damage the chip. When connecting to 5 V sensors or 5 V Arduinos:
- 3.3 V → 5 V direction: usually fine (3.3 V is "HIGH" on 5 V inputs).
- 5 V → 3.3 V direction: must use a level shifter or voltage divider (1 kΩ + 2 kΩ resistor pair).
Two ways to use ESP boards in a project
- Standalone: the ESP is your main microcontroller. You write the whole sketch for it; no UNO involved. This is the modern, simpler path.
- WiFi co-processor: the ESP runs special firmware that exposes WiFi as AT commands. The UNO is the main brain; it sends AT commands over UART to the ESP. Older pattern; mostly obsolete now since standalone ESPs are cheaper and faster.
From L03-30 onwards we go standalone.
Installing the board support
In Arduino IDE: File → Preferences → "Additional boards manager URLs". Add (comma-separated if you want both):
https://arduino.esp8266.com/stable/package_esp8266com_index.json https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
Then Tools → Board → Boards Manager → search "esp8266" (install "esp8266 by ESP8266 Community") and "esp32" (install "esp32 by Espressif Systems").
After install, the Board menu has "NodeMCU 1.0", "Wemos D1 R2 & mini", "ESP32 Dev Module", etc. Pick the one matching your board.
Worked Example · Hello, WiFi scanner 25 min
This sketch boots, scans for nearby WiFi networks, and lists them to Serial. No router login needed — just power + USB.
Step 1 — select your board
Tools → Board → ESP8266 → "NodeMCU 1.0 (ESP-12E)" (or your specific board). Set the COM port. Set CPU frequency to 80 MHz (default).
Step 2 — the scanner sketch
// L03-29 · WiFi scanner (works on both ESP8266 and ESP32)
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#elif defined(ESP32)
#include <WiFi.h>
#endif
void setup() {
Serial.begin(115200);
delay(500);
Serial.println();
Serial.println("# Boot.");
// Disconnect from any previous AP; switch into station (client) mode
WiFi.mode(WIFI_STA);
WiFi.disconnect();
delay(100);
}
void loop() {
Serial.println("# Scanning...");
int n = WiFi.scanNetworks();
if (n == 0) {
Serial.println("# No networks found.");
} else {
Serial.print("# Found ");
Serial.print(n);
Serial.println(" networks:");
for (int i = 0; i < n; i++) {
Serial.print(" ");
Serial.print(WiFi.SSID(i));
Serial.print(" RSSI: ");
Serial.print(WiFi.RSSI(i));
Serial.print(" dBm ");
// Encryption: 0 = open, 7 (ESP8266) / others = WEP/WPA/WPA2/...
Serial.println(WiFi.encryptionType(i) == 0 /* OPEN */ ? "(open)" : "(secured)");
}
}
Serial.println();
delay(10000);
}The #if defined(ESP8266) / ESP32 block at the top is a one-time compile-time switch — the right WiFi library is included depending on which board you compiled for. The rest of the API is identical.
Step 3 — upload + open Serial Monitor at 115200 baud
(Note: ESP boards default to 115200, not 9600. Watch out — set Serial Monitor to match.)
You should see something like:
# Boot. # Scanning... # Found 7 networks: Home-WiFi RSSI: -42 dBm (secured) Neighbour-5G RSSI: -78 dBm (secured) MiaPhone RSSI: -64 dBm (secured) Cafe-Guest RSSI: -82 dBm (open) ...
Step 4 — understand RSSI
RSSI = Received Signal Strength Indicator, in dBm (decibels relative to 1 milliwatt). A more-negative number = weaker signal.
| RSSI | Quality |
|---|---|
| −30 to −50 dBm | Excellent (in the same room as the router) |
| −50 to −70 dBm | Good |
| −70 to −85 dBm | Poor but usable |
| < −85 dBm | Connection drops, retransmissions |
Move the ESP closer to your router — the RSSI for your home network should improve. Move it into the next room — it drops.
Step 5 — try to find your phone's hotspot
On your phone, turn on the personal hotspot (Settings → Hotspot). Re-run the scanner. Your phone's hotspot SSID should show up in the list — the ESP will see it from across the room. Useful in classrooms with no managed WiFi.
Step 6 — quick comparison if you have both boards
Upload the same sketch to an ESP8266 and an ESP32. Both list the same networks. The ESP32 typically completes a scan faster (~2 s vs ~5 s) and finds slightly more (better radio sensitivity). For most uses the difference is invisible.
Basic 5 min
Goal: Light the on-board LED (NodeMCU: D4 active-low; ESP32 DevKit: GPIO2) when scanning, off when waiting. Visible "heartbeat".
Challenge 1 5 min
Goal: Sort the scan results by RSSI so the strongest network appears first.
Challenge 2 5 min
Goal: Turn the scanner into a signal-strength finder for one network.
- Put the network's name in a
const char* TARGET_SSID. - Scan every 2 seconds instead of every 10.
- Print only that network's RSSI, plus its quality word from the Step 4 table:
Excellent,Good,PoororDropping. - If the network is not in the scan, print
NOT FOUND.
Then walk the board around on a laptop. Find the weakest spot in the room.
It works if the Serial Monitor shows one line every 2 s, such as Home-WiFi -58 dBm Good, and the word changes as you move.
Challenge 3 · Protect a 3.3 V pin 10 min
You want an ESP8266 to read the ECHO pin of an HC-SR04. The sensor runs on 5 V, so ECHO goes up to 5 V. The ESP's GPIO pins only take 3.3 V.
- Use the 1 kΩ + 2 kΩ divider from the New Concept section. Calculate the voltage the ESP pin sees when ECHO is 5 V. Use Vout = Vin × Rbottom ÷ (Rtop + Rbottom).
- A classmate wired the same two resistors the other way round: 2 kΩ on top, 1 kΩ to GND. Calculate their voltage. Will the ESP read a clear HIGH? (A HIGH needs more than about 2.5 V.)
- Write a wiring table for the correct circuit: ECHO, both resistors, the ESP pin and GND.
- The TRIG pin goes the other way, from ESP to sensor. Does it need a divider?
It works if your correct divider gives about 3.3 V, and your table puts the tap between the two resistors.
Recap 5 min
ESP8266 = cheap and simple, WiFi only. ESP32 = more powerful, WiFi + BLE. Both program through the Arduino IDE via board support packages you install once. Both run 3.3 V logic — protect inputs from 5 V signals with a level shifter. The WiFi scanner sketch is the first useful demo: it confirms the board boots, the library compiles, and the radio works. Tomorrow we actually connect to a network, deal with credentials, and start being a real WiFi client.
- ESP8266
- Espressif's 80 MHz WiFi-only microcontroller (2014). Used in NodeMCU, Wemos D1 mini, and many cheap modules.
- ESP32
- Espressif's 240 MHz dual-core successor (2016). WiFi + Bluetooth Classic + BLE; many more GPIO; 12-bit ADC. The classroom standard now.
- NodeMCU
- A widely-cloned ESP8266 dev board with a CH340 USB-serial chip and a pin layout convention (D0..D8 + A0).
- WROOM
- The shielded module containing the ESP32 chip + flash + antenna. Most ESP32 dev boards have a WROOM-32 in the middle.
- Station mode (WIFI_STA)
- The board acts as a WiFi client — connects to an existing access point. The default for our lessons.
- Access Point mode (WIFI_AP)
- The board acts as its own WiFi router — other devices connect to it. Useful for captive-portal config, standalone setups.
- RSSI
- Received Signal Strength Indicator, in dBm. More negative = weaker. The most common signal-quality metric.
- 3.3 V logic
- All ESP boards run their GPIO at 3.3 V. Plugging a 5 V signal into them can damage the chip. Use a level shifter or voltage divider for 5 V → 3.3 V.
- Board support package
- The plugin you install via the Boards Manager that adds support for a chip family to the Arduino IDE. ESP8266 and ESP32 each need their own package.
Extra Mission 5 min
Part 1 — Design a WiFi-aware gadget
An ESP board can tell which WiFi networks are nearby, even without logging in. Design a gadget that uses this. Ideas: a lamp that knows you are home, a bag tag that beeps when it leaves school, a bike light that knows it is in the garage.
Your design must include:
- The gadget's name and its one job.
- Which network it watches for, and the RSSI that counts as "near".
- Your board choice, ESP8266 or ESP32, with two reasons from the comparison table.
- Its outputs, with a pin for each one.
Part 2 — Make it
Build the core of your gadget with the scanner sketch. Light an LED when your chosen network is found with an RSSI above your "near" level. Turn it off when it is not. Your phone's hotspot makes a good test network.
Bring back next class: your design, your uploaded sketch, and a Serial Monitor screenshot showing the LED state change as the network appears and disappears. Also bring your WiFi name and password for L03-30.