Lessons and the learning game

Build a space habitat controller

Life support for a small Mars base on one Uno: CO2 and its scrubber, cabin pressure and leaks, an airlock that cannot open wrong, and loud alarms.

What you build

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

  • CO2: an SCD41 on I2C. It measures CO2 by the faint sound infrared light makes in a tiny chamber of air, every five seconds.
  • Pressure: a BME280 on the same bus, reading the cabin pressure.
  • The crew panel: a 128x64 SSD1306 OLED, the third device on the bus.
  • The scrubber: a fan module on A2 and A3.
  • The airlock pump: a relay on A1, so a 5 V pin can switch a motor.
  • The alarm: an active buzzer on A0.
  • The brain: an Arduino Uno.

How it works

Air in a sealed room. Fresh air is about 420 ppm of CO2. Over 1000 a room feels stuffy, and 5000 ppm is the eight-hour workplace limit. A resting adult breathes out about 0.018 cubic meters of CO2 an hour, so in a sealed 100 cubic meter habitat each person adds 180 ppm an hour. Four crew starting at 600 ppm reach the limit in about six hours.

Scrubbing. A fan pushes cabin air through a scrubber. Apollo used lithium hydroxide (2 LiOH + CO2 -> Li2CO3 + H2O): 1.09 kg of it for every kilogram of CO2. The fan switches on at 1500 ppm and off below 1000, two thresholds so it never chatters.

Pressure. The cabin is kept at 1013 hPa against about 6 hPa outside on Mars. The sketch reads it once a second and turns the change into hPa per minute: falling faster than 2 hPa a minute is a leak, and under 950 hPa is low pressure. Oxygen is 21 percent of the air, so what the lungs feel is its partial pressure, 213 hPa at sea level. Under about 160 hPa people struggle.

The airlock. The outer door opens only with the inner door shut and the lock pumped down to 7 hPa; the inner door only with the outer door shut and the lock back at 1013 hPa. Every door command goes through one function that checks this, and a state machine (idle, pumping, filling) runs the cycle without ever waiting. The lock pressure is modeled at 200 hPa a second, much faster than a real pump.

Alarms. CAUTION (CO2 over 2500 ppm, cabin under 990 hPa) chirps every two seconds; WARNING (5000 ppm, under 950 hPa) beeps fast. Alarms latch until the crew types ack, which silences an alarm that is still going on and clears one that has gone. The worst alarm is always at the top.

The course

Build a space habitat controller takes six lessons:

  1. Air in a sealed room: CO2 levels, the 5000 ppm limit and how fast a crew gets there.
  2. CO2 scrubbing: a fan with hysteresis, and the chemistry a mission carries.
  3. Pressure: leaks by rate, low pressure, and oxygen partial pressure.
  4. Airlock logic: an interlock in one function and a state machine for the pump.
  5. Alarms: two levels, latching, acknowledging and the worst one first.
  6. Project: a Mars hab panel: everything on one panel, with a status report, an EVA and a hull breach.

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