Source: https://mokxi.com/teachers/plans/micropython-iot
Updated: 2026-11-19

Lesson plan

# Connected devices in MicroPython lesson plan

Network-ready MicroPython on the Pico W: every WiFi state and failure, HTTP status codes and headers, a web server from a bare socket, JSON both ways, asyncio servers, backoff and the watchdog, ending in an ocean buoy dashboard.

4 chapters, 7 lessons, about 7 hours, on the Raspberry Pi Pico W. Every lesson runs in the browser, with nothing to install.

Start a class from this course

The unit

## Objectives and materials

### By the end, students can

- The network module and HTTP requests, failures included.
- A web server from a socket, and JSON for programs.
- asyncio servers, and recovering from every failure.
- An ocean buoy dashboard on a Pico W.

### Materials for the whole unit

- Pressure, humidity and temperature, BME280
- Raspberry Pi Pico W

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.

Chapter 1. About 2 h 5 min

## The board as a client

The network module and HTTP requests, failures included.

Lesson | Time | What students do

The network module Past "connected": every state a station passes through, a connect function with a timeout that fails fast, the address, mask, gateway and DNS server, the hostname and MAC, and names that do not resolve. | 60 min

- Run it: watch the states
- Four numbers from DHCP
- A name and a MAC
- Names that do not resolve
- A wrong password
- Rename the board
- Leases and fixed addresses

urequests in depth Every answer has a status: 200 and 201 for success, 4xx for your mistake, 5xx for the server’s. Headers, bodies, a fetch() that always closes, failures before any answer, and a POST with your own headers. | 65 min

- Run it: a careful fetch
- Status and headers
- The body
- The server’s problem
- Our mistake
- No answer at all
- A POST with headers
- Memory on a microcontroller

### Materials

- Raspberry Pi Pico W

### Check for understanding

Each student finishes "urequests in depth" on their own, without opening the hints. The simulator checks 8 of its 8 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Memory on a microcontroller".

Chapter 2. About 1 h 50 min

## The board as a server

A web server from a socket, and JSON for programs.

Lesson | Time | What students do

A tiny web server The board as the server, from a bare socket: bind, listen, accept, read the request line, route the path, send a status line, headers and a page, and switch the Pico W’s LED from a browser. | 50 min

- Run it: listening
- A browser asks
- Routes
- Not found
- Click it yourself
- Who can reach it

JSON both ways The language devices and dashboards speak: parse a space weather feed into dicts and lists, survive bad JSON and missing keys, turn your own readings into JSON, and serve them at /api. | 60 min

- Run it: a space weather feed
- Text to data
- Lists inside
- Not JSON at all
- A missing key
- Data to text
- Serve it at /api

### Materials

- Raspberry Pi Pico W

### Check for understanding

Each student finishes "JSON both ways" on their own, without opening the hints. The simulator checks 7 of its 7 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Serve it at /api".

Chapter 3. About 1 h 55 min

## Robust devices

asyncio servers, and recovering from every failure.

Lesson | Time | What students do

asyncio servers A server that does not stop the world: asyncio.start_server with one coroutine per connection, a blinker task that never pauses, and the rule that makes it all work: await, never sleep. | 50 min

- Run it: serving and blinking
- Three jobs at once
- A request in the middle
- Two visitors
- Blink faster
- Never block

Error recovery A device that keeps working when the network does not: retries with exponential backoff for joining and for requests, running on the last good value, and a hardware watchdog that restarts a hung board. | 65 min

- Run it: a device for the real world
- The watchdog
- The server is busy
- It comes back
- Down for good
- Backoff on joining
- Hang it
- Layers of defense

### Materials

- Raspberry Pi Pico W

### Check for understanding

Each student finishes "Error recovery" on their own, without opening the hints. The simulator checks 8 of its 8 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Layers of defense".

Chapter 4. About 1 h 5 min

## Boss project

An ocean buoy dashboard on a Pico W.

Lesson | Time | What students do

Boss: an ocean buoy dashboard A Pico W on a buoy: a BME280 read by an asyncio task, a sea forecast fetched with backoff, an HTML dashboard and a JSON API served at once, and a storm light driven by the forecast and the pressure. | 65 min

- Run it: buoy 7 online
- The forecast
- The dashboard
- The API
- A storm forecast
- Falling pressure
- The forecast goes down
- Tune the storm line

### Materials

- Pressure, humidity and temperature, BME280
- Raspberry Pi Pico W

### Check for understanding

Each student finishes "Boss: an ocean buoy dashboard" on their own, without opening the hints. The simulator checks 8 of its 8 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Tune the storm line".

Your class

## 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.

Start a class from this course See the demo class

More units

## Other lesson plans

Electronics basics 20 lessons, about 10 h. Embedded on the Arduino Uno 16 lessons, about 12 h. Embedded on the ESP32-C3 13 lessons, about 11 h. Embedded on the Raspberry Pi Pico 7 lessons, about 6 h. Build your own fight stick 5 lessons, about 4 h. Embedded on the STM32F411 6 lessons, about 6 h. C++ on a board 13 lessons, about 10 h. Digital logic and memory 4 lessons, about 4 h. Interactive devices on the Uno 9 lessons, about 8 h. From gates to a computer 23 lessons, about 16 h. Build a claw machine 8 lessons, about 6 h. Every unit All the courses as ready-made units, on the teachers page.
