← Back to projects
Completed project — Instituto Velázquez

CO2 Monitoring — Instituto Velázquez

Research, design and deployment of a CO2 monitoring system across 40 classrooms at Instituto Velázquez during the pandemic: scientific motivation, prototyping, results, a usage guide and DIY-replica firmware.

Medusa_CO2 meter with battery
Fig. 1 — Medusa_CO2 meter with battery, ready to deploy in a classroom.

Why measure CO2

01

Based on Harvard University and CSIC guidelines, a room is considered well-ventilated between 800-950 ppm CO2 (outdoor air is around 400-420 ppm); above 1000 ppm ventilation is insufficient. Recommended air changes per hour (ACH) for a 100m² classroom with 25 students aged 5-8 is 5-6 ACH.

CO2 itself isn't the pathogen, but works as an indirect indicator: at 800 ppm, roughly 1% of the air breathed has already been exhaled by someone else. Studies from the University of Seville confirm Mediterranean naturally-ventilated classrooms typically exceed WHO-recommended maximums.

800-950 ppm well-ventilated 5-6 ACH recommended Harvard / CSIC guidance

The problem at the school

02

Infections forced students and staff into isolation, creating inequality between those attending in person and those following classes from home. With ratios of up to 30 students per classroom, CO2 could reach critical levels.

It was also framed as an educational opportunity: senior students could assess ventilation as a STEM project.

Design and prototypes

03
COMPLETED
NDIR sensors
MH-Z19 · MH-Z14
Precision sensor
Sensirion SCD30 · ±30 ppm
Placement
> 2m from occupants

Several prototypes were built using NDIR (non-dispersive infrared) sensors: MH-Z19 and MH-Z14 on Arduino, and a third using the Sensirion SCD30 sensor (more accurate, ±30 ppm) on a TTGO ESP32 + color OLED board. A case was designed via CAD and 3D printed.

The classroom placement was chosen away from windows/doors and air currents, over 2m from occupants, at seated student height.

MH-Z19 / MH-Z14 / SCD30 NDIR sensor technology TTGO ESP32 + OLED 3D-printed CAD case
MH-Z19B CO2 sensor
MH-Z19B
MH-Z14A CO2 sensor
MH-Z14A
CAD prototype case
Case — CAD prototype
Classroom placement
Classroom placement
Sensirion SCD30 prototype
SCD30 + OLED prototype
Fig. 2 — MH-Z19B/MH-Z14A NDIR sensors, 3D-printed prototype case, classroom placement and the final prototype with the Sensirion SCD30 sensor.

Deployment and data logging

04
COMPLETED
Analyzed classroom
30 students · 6.65×6.80×3.40m
Peak recorded
400 → 1370+ ppm
ACH experimental
7.41 vs. 7.59 theoretical

Beyond automatic ThingSpeak logging, each class's delegate manually recorded CO2 concentration, student count, and door/window status every hour. Analysis of a typical classroom (30 students, 6.65×6.80×3.40m) showed CO2 rising from 400 to over 1370 ppm when doors and windows closed, dropping back to 400 ppm during breaks.

The air changes per hour (ACH) rate was experimentally validated via linear regression on the CO2 decay curve, yielding 7.41 changes/hour versus 7.59 from the theoretical guide.

Manual hourly logging ACH via linear regression Exportable CSV/XLS data
CO2 chart for classroom 11
CO2 trend — classroom 11
Linear regression on the decay curve
Linear regression — ACH
Fig. 3 — Hourly CO2 trend in a typical classroom and linear regression on the decay curve to compute the real ACH.

Expected results and limitations

05

The goal: improve academic performance, reduce infection risk and increase thermal comfort, through a sensor network mapping the school's CO2 in real time (classrooms, hallways, library, staff room).

Acknowledged limitations: CO2 doesn't degrade the same way as an airborne virus, particle emission from talking/shouting/singing isn't proportional to CO2 output, and per-person CO2 emission varies with age, sex, weight and metabolic activity — CO2 is a useful proxy, not a direct measure of infection risk.

Final product: MedusaCO2

06
COMPLETED
Medusa_CO2
40×83×21mm · 40g
Medusa_CO2_battery
40×83×40mm · 93g
Sensor
Sensirion SCD30

Two final models: Medusa_CO2 (Sensirion SCD30 sensor, LILYGO TTGO T-Display ESP32 board, 1.14" color display, USB-C, 40×83×21mm, 40g) and Medusa_CO2_battery (same base with a rechargeable 18650 Li-ion 3000mAh battery via USB-C, 40×83×40mm, 93g).

Case designed and 3D printed screw-free for easy assembly.

Sensirion SCD30 LILYGO TTGO T-Display 40x83x21mm · 40g Optional 18650 battery
→ Download manual (PDF)
Finished Medusa_CO2 meter
Medusa_CO2
Medusa_CO2 meter with battery module
Medusa_CO2_battery
Fig. 4 — The two final models: Medusa_CO2 and Medusa_CO2_battery, with a screw-free 3D-printed case.

The device

07
COMPLETED
Power-on
~30s warm-up
Yellow threshold
700 PPM
Alarm threshold
900 PPM

The meter powers on and after a 30-second sensor warm-up shows CO2, temperature, humidity, battery, alarm and wifi status on screen. The reading shifts from green to yellow at 700 PPM and to red with an audible alarm at 900 PPM (configurable thresholds).

It has three buttons: A and B on the front, R (reset) on top. The alarm is disabled by holding B for over 10 seconds.

CO2 · Temp · Humidity Battery + WiFi status Audible alarm
Meter screen
Screen — CO2 reading
Meter buttons
Buttons A / B / R
Button and battery manual
Manual — buttons and battery
Fig. 5 — Status screen, layout of the three buttons and a summarized use/battery manual.

Calibration

08
COMPLETED
Reference
410 PPM
Self-calibration
ASC · ~7 days
Manual
Button A · 10s / remote IP

Calibration must be done in a clean environment (410 PPM reference). The sensor includes automatic self-calibration (ASC) over roughly 7 days without unplugging, with periodic exposure to clean air.

Manual calibration is done by holding A for over 10 seconds, or remotely via the device's IP address (found with a short press of A) on the same network.

Automatic ASC Remote calibration by IP
Manual calibration, button A
Manual calibration — button A
Remote calibration by IP
Remote calibration — IP
Fig. 6 — Manual calibration via button A and remote calibration through the device's IP on the network.

Wifi connection

09
COMPLETED
Config mode
Double press R
Temporary network
MedusaIoT
Panel
192.168.0.4

Pressing R twice enters configuration mode, which creates an open «MedusaIoT» wifi network. Connecting opens (or manually browsing to 192.168.0.4) a panel to select the target wifi network, set alarm thresholds, and enter the ThingSpeak channel credentials (Write API Key and Channel ID).

WiFiManager ThingSpeak Write Key Channel ID
Configuration mode
Configuration mode
Wifi network selection
Network selection
Thresholds and ThingSpeak credentials
Thresholds and credentials
Fig. 7 — Configuration sequence: AP mode, network selection and the thresholds/ThingSpeak credentials panel.

Sending to ThingSpeak

10
COMPLETED
Platform
ThingSpeak
Per sensor
1 channel + 1 write key
Alerts
Email by threshold

Data is sent to ThingSpeak (free tier), which assigns a channel and write key per sensor. Automatic email alerts were configured for when a channel exceeds a set CO2 value.

ThingSpeak API Email alerts
ThingSpeak channel with classroom CO2 data
ThingSpeak channel
ThingSpeak Write API Key
Write API Key
Email alert configured in ThingSpeak
Email alert
Fig. 8 — ThingSpeak channel assigned per sensor, write key and email alert configuration.

Dashboard and analysis

11
COMPLETED
Classrooms
40
URL
medusaiot.org/medidas-co2
History
Last hour per classroom

To visualize all 40 classrooms, a custom dashboard was built (medusaiot.org/medidas-co2) showing each classroom's status and, on selection, its CO2 trend over the last hour.

Custom dashboard 40 classrooms
Classroom map
Overview
Per-classroom status
Per-classroom status
CO2 trend
Trend — last hour
Classroom detail
Classroom detail
Fig. 9 — Dashboard of the 40 classrooms at Instituto Velázquez, with per-classroom CO2 trend detail.

Automated calibration with Python

12
COMPLETED
Libraries
requests + Selenium
Threshold
< 410 PPM
Distribution
PyInstaller (.exe)

Periodic calibration (outside school hours, ventilated rooms) was automated with a Python script: it uses requests against the ThingSpeak API to read each sensor's PPM by IP, and Selenium to press the calibration button on each device's web page if below 410 PPM.

It generates a log and emails it. Packaged with PyInstaller as an executable so the machine running the scheduled task doesn't need Python installed.

Python Selenium PyInstaller Email log
Automated calibration script
Fig. 10 — Automated calibration script run: reading by IP, comparison against the threshold and logging.

Build your own device

13
DIY
Controller
NodeMCU Lolin V3
Sensor
MH-Z14A
Display
OLED 1.3" 128×64

ESP8266/ESP32-based analyzer with the MH-Z14A sensor. Materials: NodeMCU Lolin V3, MH-Z14A sensor, 1.3" 128×64 OLED display, RGB LED, 4× 220Ω resistors, calibration pushbutton.

Firmware (Arduino) is available for download, along with the same wiring applicable to the MH-Z19B sensor.

ESP8266 / ESP32 MH-Z14A / MH-Z19B OLED 1.3" 128×64 Arduino firmware
→ Download firmware (.zip)
Wiring diagram
Wiring diagram
Final assembly
Final assembly
Fig. 11 — NodeMCU + MH-Z14A + OLED wiring diagram and the final DIY analyzer assembly.

Acknowledgements

This project would not have been possible without the involvement of Antonio Barrios, Mercedes García de Casasola, Adolfo Martínez, Manuela Gordillo and Fernando Carrillo, as well as the students at the school who actively took part in its development and deployment, and the school's Parents' Association (AMPA).

The project was also supported by a crowdfunding campaign on Goteo, driven by the school's Parents' Association (AMPA).