Curriculum pack

IoT with ESP32, 6 weeks

An ESP32-C3 joins a network, serves a web page that switches a lamp, and calls an API, all on a simulated network inside the browser tab. No school WiFi, no API keys and no student data leaves the page.

  • Grades 9 to 12
  • 6 weeks
  • Three class periods a week, about 45 minutes each.
  • Teacher answer key included

Before this pack: Arduino Programming, or comfort with setup(), loop(), variables, if and millis().

The pack at a glance

WeekTopicGraded workStandards
1First light on the ESP32-C32 lessons with checkpoints2-CS-02, 2-AP-11
2Inputs and interrupts2 lessons with checkpoints2-CS-02, 3B-CS-02
3Data out, commands in2 lessons with checkpoints2-DA-08, 2-CS-02
4Joining a network1 auto-graded check2-NI-04, HS-PS4-2
5A web page that controls a lamp1 auto-graded check2-NI-04, 2-NI-05, 3A-AP-16
6Calling an API, and a connected project1 auto-graded check3B-AP-16, 3A-IC-29, HS-ETS1-2

Week by week

Each week has a lesson plan, objectives, the questions to ask, the graded work and the vocabulary. The minutes are a guide.

Week 1

First light on the ESP32-C3

A new board at 3.3 V, a GPIO number instead of a pin label, and a moving dot on six pins.

Learning objectives: students will be able to

  • Blink an LED on an ESP32-C3 GPIO
  • Explain what changes moving from a 5 V board to a 3.3 V one
  • Drive several GPIOs from an array

Lesson plan

  1. Warm up (5 min): compare the Uno and the ESP32-C3 side by side. What is different?
  2. Lesson (20 min): First light on the C3.
  3. Lesson (20 min): Six pins and a moving dot.
  4. Close (5 min): list two things the ESP32 has that the Uno does not.

Ask the class

  • Why might an LED resistor that suits a 5 V Uno be a different value on a 3.3 V board?
  • What does storing the six pin numbers in an array let the code do?

Graded work

  • First light on the C3: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.
  • Six pins and a moving dot: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.

Projects to open: Knight Rider

Vocabulary

ESP32
A family of microcontrollers with WiFi built in.
GPIO
General-purpose input/output: a pin the program controls.
3.3 V logic
A board whose high level is 3.3 volts, not 5.
Array
A numbered list of values under one name.

Standards: 2-CS-02, 2-AP-11

Week 2

Inputs and interrupts

A button at 3.3 V, and a handler that runs the instant a pin changes.

Learning objectives: students will be able to

  • Read a button on the ESP32 with a pull-up
  • Attach an interrupt to a pin edge
  • Explain what an interrupt costs and when to use one

Lesson plan

  1. Warm up (5 min): what happens to a button press while the board is busy?
  2. Lesson (20 min): Reading a pin at 3.3 V.
  3. Lesson (20 min): Interrupts, and what they cost.
  4. Close (5 min): one sentence on volatile.

Ask the class

  • Why is a variable shared with an interrupt handler marked volatile?
  • Why should an interrupt handler be short?

Graded work

  • Reading a pin at 3.3 V: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.
  • Interrupts, and what they cost: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.

Projects to open: ESP32-C3 button

Vocabulary

Interrupt
A signal that makes the processor run a handler right away.
Handler
The function an interrupt runs.
Edge
The moment a signal changes from low to high, or high to low.
volatile
Tells the compiler a variable can change outside normal code.

Standards: 2-CS-02, 3B-CS-02

Week 3

Data out, commands in

The board prints readings and takes typed commands: the start of every connected device.

Learning objectives: students will be able to

  • Print structured readings over serial
  • Parse a typed command and act on it
  • Read two sensors on one I2C bus

Lesson plan

  1. Warm up (5 min): what would a weather station need to send, and how often?
  2. Lesson (15 min): The board talks.
  3. Lesson (15 min): The board listens.
  4. Explore (15 min): open Two barometers. Two sensors share two wires; how are they told apart?

Ask the class

  • How can two sensors share the same two I2C wires?
  • Why is it useful to print readings in a fixed, labeled format?

Graded work

  • The board talks: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.
  • The board listens: a lesson whose 6 steps tick against the running circuit. Assign it from your class page under A lesson.

Projects to open: Two barometers

Vocabulary

Sensor
A part that turns something in the world into a signal.
I2C
A two-wire bus that connects several chips by address.
Address
The number that picks one chip on a shared bus.
Parse
Read text and pull out its meaning.

Standards: 2-DA-08, 2-CS-02

Week 4

Joining a network

The connect loop every ESP32 tutorial opens with, on a network that only exists in the tab.

Learning objectives: students will be able to

  • Write the WiFi connect loop and report its status
  • Handle a wrong password or a missing network
  • Explain what an IP address is for

Lesson plan

  1. Warm up (5 min): what has to happen before a device can send anything on WiFi?
  2. Build (25 min): open WiFi: join the network. Change the password and read the status it reports.
  3. Discuss (10 min): why the simulated network is safer for a class than the school one.
  4. Close (5 min): list the statuses the sketch can print.

Ask the class

  • What does the sketch print when the password is wrong, and why is that useful?
  • What is an IP address for?

Graded work

  • Rebuild WiFi: join the network on an ESP32-C3 and hand it in once it reports that it is connected. Assign WiFi: join the network as a template and add these checks. Our own build passes every one:
  • Check: The board reports it is connected (the serial monitor prints a line matching /connected/ within 9 s).

Projects to open: WiFi: join the network

Vocabulary

WiFi
A way for devices to join a network by radio.
SSID
The name of a WiFi network.
IP address
The number that identifies a device on a network.
Status
A value that reports what state the connection is in.

Standards: 2-NI-04, HS-PS4-2

Week 5

A web page that controls a lamp

The ESP32 serves a page with two buttons; press one and the LED on the breadboard follows.

Learning objectives: students will be able to

  • Describe a request and a response in HTTP
  • Serve a page from the board and act on a request
  • Inspect the requests a page makes

Lesson plan

  1. Warm up (5 min): what happens when you type an address into a browser?
  2. Build (25 min): open WiFi: a lamp on a web page. Press On in the Web panel and watch the lamp.
  3. Extend (15 min): add a third button that blinks the lamp.
  4. Close (5 min): draw the request and the response on paper.

Ask the class

  • When you press On, what travels from the browser to the board, and what comes back?
  • Why should a device like this not be reachable from the whole internet without protection?

Graded work

  • Rebuild WiFi: a lamp on a web page and hand it in with the page serving its On button. Assign WiFi: a lamp on a web page as a template and add these checks. Our own build passes every one:
  • Check: The board serves a page with an On button (the page esp1 serves at / contains “On” within 9 s).

Projects to open: WiFi: a lamp on a web page

Vocabulary

HTTP
The protocol a browser and a web server talk in.
Request
What a browser asks a server for.
Response
What the server sends back.
Web server
A program that answers HTTP requests.

Standards: 2-NI-04, 2-NI-05, 3A-AP-16

Week 6

Calling an API, and a connected project

Fetch JSON from a simulated service, then design a small connected device of their own.

Learning objectives: students will be able to

  • Make an HTTP request and read a value from JSON
  • Explain what an API is and why a key must stay secret
  • Discuss what data a connected device collects, and who sees it

Lesson plan

  1. Warm up (5 min): name a device at home that talks to the internet. What does it send?
  2. Build (20 min): open WiFi: fetch the weather. Turn the dial in the Cloud panel and watch the next fetch.
  3. Build (20 min): API lab. Edit the JSON response and see what the sketch does with it.
  4. Project (two periods): a connected device to a brief, with one paragraph on the data it collects.

Ask the class

  • What happens when the sketch asks a real internet address, and why?
  • What data could a connected device collect that its user might not notice?

Graded work

  • Rebuild WiFi: fetch the weather on an ESP32-C3 and hand it in once a fetch succeeds. Assign WiFi: fetch the weather as a template and add these checks. Our own build passes every one:
  • Check: A request to the weather service succeeds (the serial monitor prints a line matching /HTTP 200/ within 12 s).

Projects to open: WiFi: fetch the weather · API lab: fetch JSON

Vocabulary

API
A set of requests a service answers, for programs to use.
JSON
A text format for structured data.
API key
A secret that identifies who is calling an API.
Privacy
Control over who collects and sees information about you.

Standards: 3B-AP-16, 3A-IC-29, HS-ETS1-2

For teachers only

Teacher answer key

Answers to every question, how to grade each week, and the mistakes worth watching for. It opens for a signed-in teacher with a class and the class tools, and is never sent to a student.

Sign in with your teacher account to see the answer key.

Standards alignment

Each code is quoted from the published standard and cited only where the week gives students that practice. Mokxi is not certified by any standards body; check these against your state’s adoption.

CodeFrameworkThe standardWeeks
2-CS-02CSTADesign projects that combine hardware and software components to collect and exchange data.1, 2, 3
2-AP-11CSTACreate clearly named variables that represent different data types and perform operations on their values.1
3B-CS-02CSTAIllustrate ways computing systems implement logic, input, and output through hardware components.2
2-DA-08CSTACollect data using computational tools and transform the data to make it more useful and reliable.3
2-NI-04CSTAModel the role of protocols in transmitting data across networks and the Internet.4, 5
HS-PS4-2NGSSEvaluate questions about the advantages of using a digital transmission and storage of information.4
2-NI-05CSTAExplain how physical and digital security measures protect electronic information.5
3A-AP-16CSTADesign and iteratively develop computational artifacts for practical intent, personal expression, or to address a societal issue by using events to initiate instructions.5
3B-AP-16CSTADemonstrate code reuse by creating programming solutions using libraries and APIs.6
3A-IC-29CSTAExplain the privacy concerns related to the collection and generation of data through automated processes that may not be evident to users.6
HS-ETS1-2NGSSDesign a solution to a complex real-world problem by breaking it down into smaller, more manageable problems that can be solved through engineering.6
For your class

Everything this pack needs, in one class

A roster with a six-character join code, the week’s lesson or starter handed to every student, checks that grade each hand-in, a live wall of everyone’s work and this answer key. Classes come with Pro and the Teacher plan, and the free 30-day trial has every tool.

Student privacy: what is kept, and what never is

Questions teachers ask

How do I assign a week’s graded work?

From your class page, choose Assign work, then A lesson, and pick the lesson by name. Each student’s hand-in arrives with the steps they completed. For a week with checks, assign the project as a template, open Checks under the assignment, and add the checks listed for that week.

Who can see the answer key?

Only a signed-in teacher who owns a class and has the class tools: Pro, the Teacher plan, a school plan or the free 30-day class trial. The key is never part of the page a student loads, and a student account cannot open it.

Do students need accounts?

Not to open the projects and lessons from a link. To hand work in through a class they need an account, because a class is a roster, and a student under 13 joins only with the consent your school gives under COPPA.

Can I change the order or the lessons?

Yes. Each week stands on the ones before it, but you can skip, reorder or swap any lesson, and every project opens in the editor for you to change before you assign it.

Teach it with a class

Start the free 30-day class trial: one class of up to forty students, every class tool and the answer keys, with no card.