Carbon dioxide levels serve as a dependable measure of indoor air quality in spaces like workplaces, educational settings, or homes.

Outdoor air typically contains about 400 parts per million of CO2, meaning 400 molecules of the gas for every million air particles overall. Even at just 0.04%, this amount influences human well-being noticeably.

Inside buildings, CO2 builds up swiftly from people exhaling. In venues such as cinemas during showings, concentrations can soar to thousands of parts per million in short order. Elevated CO2 can cause reduced focus, fatigue, and migraines when thresholds are exceeded.

An at-home CO2 monitor helps identify moments to ventilate by alerting when levels surpass 1500 ppm, signaling the need for fresh air influx.

Start with a Raspberry Pi running a current version of Raspberry Pi OS; any model of the board will suffice.

Acquire a CO2 detection module, specifically the MH-Z19C from Winsen Electronics Technology in China for this guide, though the MH-Z19B functions similarly.

Opt for a variant with pre-attached pins to avoid soldering; these pins facilitate easy linkage to the Pi. Such pre-pinned editions are obtainable on platforms like Amazon.

Additionally, gather female-to-female jumper cables for sensor integration.

The total expense stays under $40, far below the price of commercial CO2 units which can run several multiples higher.

Note that the Pi's serial port, essential for sensor data retrieval, is disabled initially. Activate it via the configuration utility under Interface Options by selecting Serial Port.

The MH-Z19C (or B) employs non-dispersive infrared technology (NDIR), relying on how CO2 absorbs infrared light at particular wavelengths.

An internal light emitter sends IR beams through the sample gas toward the detector, with a filter permitting only the relevant absorption band to proceed.

Higher CO2 density boosts absorption per the Lambert-Beer principle, weakening the detected signal proportionally. The device then translates this intensity drop into a ppm reading.

For wiring the sensor to the Pi, examine its bottom side for pin labels.

Power down the Pi and unplug it first. Use four female-ended jumper wires to link the components.

The sensor's bottom indicates pin roles. Link sensor pin 6 (VCC or Vin) to Pi GPIO pin 4 for 5V power—the second pin down on the right edge of the header.

Attach sensor pin 7 (GND) to Pi pin 6 for grounding, right below pin 4.

On the sensor's opposite edge with five pins, route sensor pin 2 (Rx) to Pi pin 8, beneath pin 6.

Connect sensor pin 3 (Tx) to Pi pin 10, under pin 8. Refer to diagrams for the full assembly, then repower the Pi to boot up.

With connections made, a Python program reads CO2 data. A script from a Japanese coder simplifies this; install via terminal with the command git clone https://github.com/ Patsan/mh-z19.git.

Navigate to the ~/mh-z19 directory and run sudo python setup.py install for dependencies.

To fetch readings, execute sudo python bin/mh_z19.py --single. Output resembles {"co2": 3128}, denoting ppm.

Online visualization automates tracking, highlighting ventilation impacts over time.

Manual checks grow cumbersome; instead, log data to a web platform accessible from devices. Register at monitor3.uedasoft.com with email and password; ignore the view_id provided.

In the Elements menu, note the eight-character code like 'prgrvpqg' from the list, activate it, and save changes.

Back in Pi terminal, from ~/mh-z19, run sudo python tools/mh_z19_monitor.py --id prgrvpqg (substitute your code) to verify setup—'true' in output confirms success.

For ongoing logging every five minutes, use sudo python tools/mh_z19_monitor.py --id prgrvpqg --loop 5. The monitor site's chart updates accordingly; adjust display count in Settings for preferred duration.

Ten hours requires 120 data points; the plot quickly reveals if airing occurred during absences like meals or errands.

Access the chart on mobiles too, and export to CSV via Download for spreadsheet review like in Excel. The script auto-relaunches post-reboot.

Enhance by adding a red LED with 330-ohm resistor and script tweak: it illuminates when CO2 tops a set limit.

This piece adapts content from our affiliate site PC-WELT, originally in German and adjusted for English audiences.