Lesson plan

Firmware capstone: your own device lesson plan

Take your own device from an idea to a tagged release: a brief, testable requirements, a layered architecture, a driver from the datasheet, self-tests and unit tests, a watchdog and a power budget, then the write-up.

4 chapters, 7 lessons, about 8 hours, on the ESP32-C3-DevKitM-1. Every lesson runs in the browser, with nothing to install.

The unit

Objectives and materials

By the end, students can

  • Choose the device, prove the parts, and write requirements you can test.
  • Layers, a state machine, a command shell and a driver from the datasheet.
  • Self-tests, unit tests, a watchdog, recovery and a power budget.
  • A version, release notes, a demo and the write-up for your portfolio.

Materials for the whole unit

  • ESP32-C3-DevKitM-1
  • Full-size breadboard
  • LED
  • Piezo speaker
  • Pressure, humidity and temperature, BME280
  • Pushbutton
  • Resistor
  • Slide switch

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 25 min

Plan it

Choose the device, prove the parts, and write requirements you can test.

LessonTimeWhat students do
Pick a deviceThe brief, the reference device and the bring-up: scan the I2C bus, check the chip id, predict a reading, and prove the LED, the buzzer and the button all work before writing a single feature.65 min
  1. The brief, and the first scan
  2. Is it the chip you think it is?
  3. Predict the reading
  4. Every output, on purpose
  5. And the input
  6. Your version: pick your device
RequirementsFive numbered requirements, each one testable: an alarm above a limit, hysteresis so it does not chatter, a button that silences the buzzer, and a change request handled by editing one constant.80 min
  1. A requirement is a test you have not run yet
  2. Predict the alarm
  3. Hear it
  4. R4: silence, not cancel
  5. R3: why the alarm needs a gap
  6. A change request
  7. Your version: write your requirements

Materials

  • ESP32-C3-DevKitM-1
  • Full-size breadboard
  • LED
  • Piezo speaker
  • Pressure, humidity and temperature, BME280
  • Pushbutton
  • Resistor
  • Slide switch

Check for understanding

Each student finishes "Requirements" 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: "Your version: write your requirements".

Chapter 2. About 2 h 10 min

Build it

Layers, a state machine, a command shell and a driver from the datasheet.

LessonTimeWhat students do
ArchitectureThree layers that only talk downward: drivers, a state machine with IDLE, ALARM and FAULT, and a serial command shell with a table of commands you extend with one of your own.65 min
  1. Three layers
  2. Ask it
  3. Change it from the shell
  4. The third state
  5. Add a command
  6. Your version: draw your architecture
DriversA BME280 temperature driver written straight from the datasheet: registers, calibration, the integer compensation formula, error codes instead of wrong numbers, a configurable address and a plausibility check that catches a chip that reset.65 min
  1. From the datasheet
  2. Predict the compensation
  3. Errors, not wrong numbers
  4. A board strapped differently
  5. Catch the chip that reset
  6. Your version: write a driver

Materials

  • ESP32-C3-DevKitM-1
  • Full-size breadboard
  • LED
  • Piezo speaker
  • Pressure, humidity and temperature, BME280
  • Pushbutton
  • Resistor
  • Slide switch

Check for understanding

Each student finishes "Drivers" 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 version: write a driver".

Chapter 3. About 2 h 10 min

Prove it

Self-tests, unit tests, a watchdog, recovery and a power budget.

LessonTimeWhat students do
TestsSelf-tests at boot that print PASS or FAIL, a test command for the bench, and unit tests of a pure state machine function that run on the chip, catch a real hysteresis bug, and grow by one case.65 min
  1. Self-tests at boot
  2. Fail one on purpose
  3. The unit tests found a bug
  4. Fix it, and watch it go green
  5. Write a test for the edge
  6. Your version: a test plan
Power and reliabilityA task watchdog that reboots a stuck loop and says why, a FAULT state that recovers by itself when the sensor comes back, and a battery budget worked out from the firmware's own measured awake time.65 min
  1. Why did it start?
  2. Hang it on purpose
  3. Recover by itself
  4. Where the current goes
  5. Spend less on the LED
  6. Your version: failure modes and a budget

Materials

  • ESP32-C3-DevKitM-1
  • Full-size breadboard
  • LED
  • Piezo speaker
  • Pressure, humidity and temperature, BME280
  • Pushbutton
  • Resistor
  • Slide switch

Check for understanding

Each student finishes "Power and reliability" 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 version: failure modes and a budget".

Chapter 4. About 1 h 5 min

Ship it

A version, release notes, a demo and the write-up for your portfolio.

LessonTimeWhat students do
Release and write-upGreenhouse guard 1.0.0: a version string, a version command, release notes with known issues, a version bump, a demo run, and the README, demo script and shared project link that make it a portfolio piece.65 min
  1. One version, printed first
  2. Ask for it
  3. Release notes, with the bad news
  4. Cut 1.1.0
  5. Run the demo
  6. Your version: ship it and write it up

Materials

  • ESP32-C3-DevKitM-1
  • Full-size breadboard
  • LED
  • Piezo speaker
  • Pressure, humidity and temperature, BME280
  • Pushbutton
  • Resistor
  • Slide switch

Check for understanding

Each student finishes "Release and write-up" 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 version: ship it and write it up".

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.