PyRaspBeta

← All practice problems

Raspberry Pi practice problem · Projects

Aquarium

HardBudget $40Python · gpiozero

Run a fish tank: a DS18B20 probe (data GPIO4, 3.3 V, 4.7 kΩ pull-up), a heater behind a high-trigger relay on GPIO26, a lamp behind a high-trigger relay on GPIO19, and a feeder servo on GPIO18 (5 V; 0.5 ms = 0°, 2.4 ms = 180°).

Three jobs run side by side, timed from when the program starts:

  • Heater: on below 24.0 °C, off at 25.0 °C or above; in between it stays as it was.
  • Light: day for 5 s (lamp on), night for 5 s (lamp off), repeating.
  • Feeder: every 4 s (at 4 s, 8 s, 12 s…) turn the servo to 90° for 1 s, then back to 0°.

A probe reading takes about 0.75 s, so it mustn't hold up the other jobs. Budget: $40 — the relay kits would blow it; loose relays wired to the loads fit. The test water is 23 °C, 24.5 °C at 3 s, 25.5 °C at 6 s, 24.4 °C at 9 s and 23.5 °C at 11 s.

More in Projects