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 to the computer over USB 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);}