This is the SCD4X produced and developed by SENSIRION, a next-generation of a Carbon Dioxide (CO2) Sensor . This sensor is based on photoacoustic NDIR ( Nondispersive Infrared ) sensing principle that offers high accuracy. In other words, this sensor works by an infrared (IR) lamp directing waves of light through a tube filled with a small amount of air. CO2 is a main chemical compound indicator for indoor air quality will be calculated. For instance, if the CO2 is high levels it will compromise mental performance and well-being.
This sensor enables a smart VAC system or ventilation system to regulate airflow in the most efficient way and can help maintain low CO2 concentrations indoors for a healthy productive atmosphere. The SCD4X high accuracy includes an integrated humidity and temperature sensor, it is in one sense for your indoor environment sensing. for more technical reading and specs please refer to the datasheet below.
Testing Requirements
- Arduino IDE | PlatformIO
- Test Boards :
- Note: The Diagram below is using Arduino NANO Microcontroller (please refer to your MCU’s respective pin-outs & bus configuration)
- Resistors (See below diagram for required value)
- Capacitor(See below diagram for required value)
Wiring Diagram & Schematics
Source Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
#include <Arduino.h> //Built-in Arduino IDE #include <SensirionI2CScd4x.h> // This library can be downloaded below #include <Wire.h> //Built-in Arduino IDE SensirionI2CScd4x scd4x; void printUint16Hex(uint16_t value) { Serial.print(value < 4096 ? "0" : ""); Serial.print(value < 256 ? "0" : ""); Serial.print(value < 16 ? "0" : ""); Serial.print(value, HEX); } void printSerialNumber(uint16_t serial0, uint16_t serial1, uint16_t serial2) { Serial.print("Serial: 0x"); printUint16Hex(serial0); printUint16Hex(serial1); printUint16Hex(serial2); Serial.println(); } void setup() { Serial.print("14CORE | Testing SCD4X - CO2 SENSOR ...... "); delay(1000); Serial.begin(115200); while (!Serial) { delay(100); } Wire.begin(); Serial.print("14CORE | Starting Serial Communication .... "); delay(2000); uint16_t error; char errorMessage[256]; scd4x.begin(Wire); // stop potentially previously started measurement error = scd4x.stopPeriodicMeasurement(); if (error) { Serial.print("14CORE | Error trying to execute stopPeriodicMeasurement(): "); errorToString(error, errorMessage, 256); Serial.println(errorMessage); } uint16_t serial0; uint16_t serial1; uint16_t serial2; error = scd4x.getSerialNumber(serial0, serial1, serial2); if (error) { Serial.print("14CORE | Error trying to execute getSerialNumber(): "); errorToString(error, errorMessage, 256); Serial.println(errorMessage); } else { printSerialNumber(serial0, serial1, serial2); } // Start Measurement error = scd4x.startPeriodicMeasurement(); if (error) { Serial.print("14CORE | Error trying to execute startPeriodicMeasurement(): "); errorToString(error, errorMessage, 256); Serial.println(errorMessage); } Serial.println("14CORE | Waiting for first measurement... (5 sec)"); } void loop() { uint16_t error; char errorMessage[256]; delay(100); // Read Measurement uint16_t co2 = 0; float temperature = 0.0f; float humidity = 0.0f; bool isDataReady = false; error = scd4x.getDataReadyFlag(isDataReady); if (error) { Serial.print("14CORE | Error trying to execute readMeasurement(): "); errorToString(error, errorMessage, 256); Serial.println(errorMessage); return; } if (!isDataReady) { return; } error = scd4x.readMeasurement(co2, temperature, humidity); if (error) { Serial.print("14CORE | Error trying to execute readMeasurement(): "); errorToString(error, errorMessage, 256); Serial.println(errorMessage); } else if (co2 == 0) { Serial.println("14CORE | Invalid sample detected, skipping."); } else { Serial.print("Co2 :"); Serial.print(co2); Serial.print("\t"); Serial.print("Temperature:"); Serial.print(temperature); Serial.print("\t"); Serial.print("Humidity:"); Serial.println(humidity); } } |