MicroPython on the ESP32 lesson plan
Python on an ESP32 DevKit: the REPL and blink, pins and PWM, the ADC, timers and interrupts, I2C sensors, WiFi in five lines, and a lamp you switch from a web page.
Objectives and materials
By the end, students can
- Blink and the REPL, then buttons and PWM brightness.
- Read a knob with the ADC, and let timers and interrupts do the waiting.
- Two chips on I2C, then WiFi, JSON and HTTP.
- A web lamp with a button, a socket server and a self-test.
Materials for the whole unit
- ESP32 DevKit V1
- LED x 2
- OLED display, 128x64
- Potentiometer
- Pressure, humidity and temperature, BME280
- 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.
First Python on the ESP32
Blink and the REPL, then buttons and PWM brightness.
| Lesson | Time | What students do |
|---|---|---|
| REPL and blinkBlink an LED from main.py, then type Python straight into the ESP32: math, a pin by hand, and a question for the chip itself. | 45 min |
|
| Pins and PWMRead a button with the pin’s own pull-up, catch the moment it is pressed, and set an LED to any brightness with PWM. | 45 min |
|
Materials
- ESP32 DevKit V1
- LED x 2
- Pushbutton
- Resistor x 2
Check for understanding
Each student finishes "Pins and PWM" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Your levels".
Sensors and time
Read a knob with the ADC, and let timers and interrupts do the waiting.
| Lesson | Time | What students do |
|---|---|---|
| The ADC: volts in, numbers outA knob makes a voltage, the ADC turns it into a number, and that number drives an LED. Then the trap every ESP32 beginner falls in: attenuation. | 45 min |
|
| Timers and interruptsA hardware timer blinks an LED on its own, an interrupt counts button presses the instant they happen, and you meet contact bounce and beat it. | 45 min |
|
Materials
- ESP32 DevKit V1
- LED
- Potentiometer
- Pushbutton
- Resistor
Check for understanding
Each student finishes "Timers and interrupts" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Beat the bounce".
Buses and networks
Two chips on I2C, then WiFi, JSON and HTTP.
| Lesson | Time | What students do |
|---|---|---|
| I2C sensorsTwo chips share two wires: scan the bus, read a register by hand, turn a BME280’s raw numbers into weather, and draw it on an OLED. | 45 min |
|
| WiFi in five linesJoin a network, get an address, read the signal, fetch JSON from a server, post your own, and see what a wrong password looks like. | 45 min |
|
Materials
- ESP32 DevKit V1
- OLED display, 128x64
- Pressure, humidity and temperature, BME280
Check for understanding
Each student finishes "WiFi in five lines" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Your turn: what time is it?".
Project
A web lamp with a button, a socket server and a self-test.
| Lesson | Time | What students do |
|---|---|---|
| Project: a web lampEverything at once: a socket server on port 80, a page that switches a lamp, a button that does too, and a self-test that proves the logic before the server starts. | 45 min |
|
Materials
- ESP32 DevKit V1
- LED
- Pushbutton
- Resistor
Check for understanding
Each student finishes "Project: a web lamp" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Make it yours".
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.