Swapnil Verma's Arduino, Edge Impulse TinyML Project Estimates CO₂ Levels via Person Recognition

Eschewing direct measurement of carbon dioxide as a ventilation warning system, Verma's approach leans on computer vision instead.

Software engineer Swapnil Verma has put together a carbon dioxide monitor with a difference: lacking a direct way to actually measure carbon dioxide concentrations, it instead estimates them based on recognizing the number of people in a room.

The need to ventilate a room when the concentration of carbon dioxide becomes too high is well known, as is the correlation between carbon dioxide levels and ventilation requirements for other reasons — such as reducing the likelihood of infection from coronaviruses like SARS-CoV-2, responsible for COVID-19. Rather than directly tracking CO₂ levels, though, Verma's project, brought to our attention by the Arduino team, turns to an alternative approach: Estimation via population.

"My solution uses a TinyML based algorithm to detect and count the people in an indoor environment," Verma writes. "The algorithm will be deployed on a microcontroller. The microcontroller will capture an image or stream of images using a camera and then perform inference on the device to count people."

The hardware is a simple two-part setup: An Arduino Portenta H7 board with a Vision Shield add-on. On the software side, the TinyML implementation for person-recognition and occupancy monitoring is developed using Edge Impulse Studio — meaning, as Verma points out, it's wholly portable from the Portenta H7 to any other compatible device including smartphones.

"This system is quite simple. The Vision shield (or any camera) captures a 240×240 image of the environment and passes it to the FOMO model prepared using Edge Impulse," Verma explains. "This model then identifies the people in the image and passes the number of people to the CO₂ level estimation function every minute."

Trained in Edge Impulse Studio, the person-recognition model performs impressively in a novel environment. (📹: Swapnil Verma)

"The average human exhales about 2.3 pounds of carbon dioxide on an average day, and the magic number 0.02556 comes by dividing 2.3 by 24×60 (minutes in a day) and converting it into ounces," Verma continues. "The equation calculates the amount of CO₂ in ounces per minute. The person detection model can be used with any other application for example occupancy detection etc. The system then repeats this process again."

In testing, detailed in Verma's write-up on the Edge Impulse site, the system showed an 86.4 percent accuracy with the PIROPO dataset — and proved portable to a previously-unseen environment: Verma's living room.

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles