Connected devices lesson plan
WiFi, APIs, a web server, MQTT, ESP-NOW and BLE on the ESP32, and a device that keeps going when the network does not.
Objectives and materials
By the end, students can
- Join WiFi, call an API, and serve a page of your own.
- MQTT through a broker, and ESP-NOW with no router at all.
- A Bluetooth LE server a phone can find, write and listen to.
- The time from the network, and a device that rejoins on its own.
Materials for the whole unit
- ESP32 DevKit V1 x 2
- ESP32-C3-DevKitM-1
- Four-digit display, TM1637
- Full-size breadboard
- LED x 2
- Pushbutton
- Resistor x 2
Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.
On the network
Join WiFi, call an API, and serve a page of your own.
| Lesson | Time | What students do |
|---|---|---|
| Joining WiFiThe connect loop every connected device starts with: WiFi.begin, the states a station walks through, the address DHCP hands out, and what a wrong password and a wrong network name look like. | 40 min |
|
| Calling an APIHTTPClient against a JSON API: a GET, the status code, the body, a different endpoint, and what a request that cannot reach its server returns. | 35 min |
|
| A web serverThe board serves a page: a WiFiServer on port 80 reads the browser’s request a line at a time, switches two LEDs from the path, and prints the page back. | 35 min |
|
Materials
- ESP32 DevKit V1
- ESP32-C3-DevKitM-1
- Full-size breadboard
- LED x 2
- Resistor x 2
Check for understanding
Each student finishes "A web server" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Who can reach it".
Messages
MQTT through a broker, and ESP-NOW with no router at all.
| Lesson | Time | What students do |
|---|---|---|
| MQTT with PubSubClientPublish and subscribe through a broker: topics, payloads, QoS and retained messages, the PubSubClient connect loop with its error codes, and the same reading sent over HTTP where the simulator has no broker. | 35 min |
|
| ESP-NOWTwo ESP32s and no router: a button on one switches an LED on the other over ESP-NOW, the sender hears the acknowledgment, and a wrong MAC address shows what no answer looks like. | 35 min |
|
Materials
- ESP32 DevKit V1 x 2
- ESP32-C3-DevKitM-1
- Full-size breadboard
- LED
- Pushbutton
- Resistor
Check for understanding
Each student finishes "ESP-NOW" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "When to use it".
Talk to a phone
A Bluetooth LE server a phone can find, write and listen to.
| Lesson | Time | What students do |
|---|---|---|
| BLE: a lamp your phone can findBluetooth Low Energy the way phones see it: a GATT server with the Nordic UART service, a characteristic to write, notifications back, and advertising again after a phone leaves. | 25 min |
|
Materials
- ESP32 DevKit V1
- LED
- Resistor
Check for understanding
Each student finishes "BLE: a lamp your phone can find" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Give it your name".
Stay connected
The time from the network, and a device that rejoins on its own.
| Lesson | Time | What students do |
|---|---|---|
| Reconnecting and NTP timeA clock that gets the time from NTP, keeps counting on its own, shows your time zone, and notices when WiFi drops and joins again without a reset. | 35 min |
|
Materials
- ESP32 DevKit V1
- Four-digit display, TM1637
Check for understanding
Each student finishes "Reconnecting and NTP time" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "When WiFi drops".
Teach this unit as a class
Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.
The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.