Skip to main content

How to: CO₂ Module

With CO₂ Module you can easily measure the concentration of carbon dioxide.

It is a low-power module that can be battery-powered for a long period. Remember that the device can need a few days before the best results are achieved.

The module uses infrared light for measurements.

References​

info

In this example, CO₂ levels will be measured and sent over the radio every 2 minutes.

CO₂ Over Radio Code Example

#include <application.h>

#define CO2_UPDATE_INTERVAL (2 * 60 * 1000)

void co2_event_handler(twr_module_co2_event_t event, void *event_param)
{
(void) event_param;
float value;

if (event == TWR_MODULE_CO2_EVENT_UPDATE)
{
if (twr_module_co2_get_concentration_ppm(&value))
{
twr_radio_pub_co2(&value);
}
}
}

void application_init(void)
{
twr_module_co2_init();
twr_module_co2_set_update_interval(CO2_UPDATE_INTERVAL);
twr_module_co2_set_event_handler(co2_event_handler, NULL);
}

Calibration​

Automatic calibration​

The SDK asks the sensor for an ABC (automatic baseline correction) calibration every 8 days of operation. ABC expects the sensor to see fresh air (about 400 ppm) from time to time, which is why the readings settle only after a few days.

Calibration in fresh air​

For a calibration on demand, put the device in fresh outdoor air (about 400 ppm) and call:

twr_module_co2_calibration(TWR_LP8_CALIBRATION_BACKGROUND_FILTERED);

The CO₂ Monitor firmware calls it 32 times, once a minute, after a 4-minute warm-up. With this firmware:

  1. Take the device outside, ideally without its enclosure, so that the air flows around the sensor.
  2. Hold the button on the Core Module until the LED starts blinking fast. The node publishes node/{id}/co2-meter/-/calibration "start".
  3. After 4 minutes, the LED blinks slowly and the node publishes a countdown from 32 to 1, once a minute. CO₂ is measured and published every minute meanwhile.
  4. After about 36 minutes, the node publishes "end" and the LED turns off.

Holding the button again during the calibration cancels it.