Lessons and the learning game

Build a smart bird feeder

A feeder that keeps a diary, on an Uno: motion, a scale for visitors and seed, a squirrel guard, a microSD visit log and an evening report.

The feeder

Every lesson opens on the same wiring:

  • Motion: a PIR sensor on pin 2.
  • Weight: the feeder hangs from a 5 kg load cell on an HX711, 429.5 counts a gram.
  • The squirrel gate: a servo on pin 9, used in the squirrel guard lesson.
  • Time: a DS3231 clock.
  • The log: a microSD card, chip select on pin 10.

The catalog lists this course on an ESP32-C3. It is built on the Uno.

How it works

Visits. A PIR's OUT holds high while something warm moves. A visit is one rising edge, and nothing new counts for 5 seconds.

Weight. The bare cell's reading is written into the sketch, so the scale reads the feeder from power-up: 300 g of feeder and up to 800 g of seed. A baseline follows the weight while nothing is perched; anything 8 g above it is a visitor, sized as small (under 20 g), medium (20 to 60), large (60 to 150), very large, or squirrel (300 g and up). The drop after it leaves is the seed it ate.

The squirrel guard. Over 300 g on the perch swings the gate shut, and it reopens after 10 seconds of clear perch.

The log. Each visit is a CSV line in VISITS.CSV with the time, weight, size and how long it stayed, flushed every visit.

The report. At 20:00: visits by size, seed eaten, the share left, the busiest hour, and a refill reminder under a quarter full.

The course

Build a smart bird feeder gets there in six lessons, each a sketch on the same wiring:

  1. Visit detection: a PIR and its edges.
  2. Seed weight: the feeder and every visitor on a scale.
  3. Squirrel guard: a threshold and a gate.
  4. Logging visits: a timed CSV on microSD.
  5. Daily report: the evening summary.
  6. Project: a bird diary: the whole feeder.

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