Lessons and the learning game

Build a thermal camera

A thermal camera on an Uno that paints heat in color, finds hot and cold spots, saves snapshots to a card, and ends as a tool that finds drafts in a house.

What you build

One circuit carries the whole course. Every lesson opens on the same wiring and changes only the sketch:

  • The sensor: an AMG8833 Grid-EYE on I2C (A4 and A5): an 8x8 grid of thermopiles, sixty-four temperatures ten times a second, 0 to 80 C in quarters of a degree.
  • The screen: a 240x320 ILI9341 on pins 9 to 5, driven in software SPI.
  • The card: a microSD module on the hardware SPI pins (13, 12, 11) with its select on 10.
  • SNAP: a pushbutton on pin 3.
  • The brain: an Arduino Uno.

How it works

Sixty-four pixels. The frame is an array of 64 floats, row by row from the top left, so pixel i is row i / 8 and column i % 8. A warm object spills onto its neighbors, so it shows as a small blob.

Color maps. The course uses its own palette, ember (black, purple, red, orange, pale yellow), and a plain gray. An automatic range stretches each frame from its coldest to its hottest pixel, which shows small differences; a fixed range (15 to 45 C) keeps colors comparable from picture to picture.

Interpolation. The picture is upscaled to 29 by 29 with bilinear interpolation: blend along x on the rows above and below, then blend those along y. It makes a smoother picture of the same 64 measurements, and it cannot find anything smaller than a pixel.

The hot spot. The hottest pixel and its eight neighbors, each weighted by how much warmer than the coldest pixel it is, give a centroid finer than the grid. At the edge of the frame the missing neighbors pull it inward. Over 50 C the camera raises an alarm.

Snapshots. SNAP writes the frame to the card as a CSV file of eight lines of eight temperatures, named SNAP001.CSV, SNAP002.CSV and so on, by finding the first name that does not exist yet. A missing card is reported, not a crash.

Finding drafts. The room temperature is the median of the frame, which a draft in the picture barely moves. A pixel 3 C or more below it is a draft, 5 C or more above it a warm spot, each boxed on the screen.

The course

Build a thermal camera takes six lessons:

  1. 64 heat pixels: reading the Grid-EYE, the hottest pixel, a flat frame.
  2. Color maps: ember and gray, automatic and fixed ranges.
  3. Interpolation: bilinear upscaling, worked by hand.
  4. Hot spot: a centroid finer than a pixel, the edge effect, and an alarm.
  5. Snapshots: CSV files on microSD, names that never collide, no card.
  6. Project: find the drafts: the median, cold drafts and warm spots, and snapshots for the record.

Every step but the last is checked against the running circuit.