Sensor – K30 – CO2 meting
Hardware
De K30 is een CO2 sensor die kan worden gebruikt voor diverse meet- en controle toepassingen. Dit platform is ontworpen als OEM module om ingebouwd te worden in bestaande apparaten. De K30 is een sensor met 2 analoge en 2 digitale Output signalen.
Informatie (ENG)
Measurement range CO2 | 0 to 5000 ppm / 0 to 3%vol |
Accuracy | ±30 ppm ±3% of reading |
Dimensions | 57 mm x 51 mm x 14 mm |
Operation temperature range | 0 to 50 °C |
Power supply | 4.5 to 14.0 V DC |
Communication | Uart ( Modbus) |
Outputs | |
OUT 1 linear output | 0 to 4 V DC = 0 to 2000 ppm |
OUT 2 linear output | 1 to 5 V DC = 0 to 2000 ppm |
OUT 3 digital output | 700/800 ppm |
OUT 4 digital output | 900/1000 ppm |
Why the K-30?
- The K-30 is an non-dispersive infrared (NDIR) CO2 sensor. Unlike electrochemical CO2 sensors, NDIR sensors use light to measure the wavelength of CO2 molecules. Electrochemical sensors last a few years. With normal care, the K-30 will last upwards of 15 years.
- NDIR sensors tend to be more accurate and have a faster response rate than electrochemical sensors.
- The K-30 is easy to talk to. It uses an industry-standard UART TXD-RXD connection.
All this having been said, electrochemical sensors are cheaper. If you only want to know if CO2 levels are high/medium/low, a low-cost electrochemical sensor is a reasonable alternative. But if you want to accurately measure CO2 levels in parts-per-million over time, the K-30 is a great sensor.
Pinout
Arduino
Aansluiten op de Arduino (Analoog)
Het is ook mogelijk de K30 sensor uit te lezen via een analoge uitgang, deze bied een 5mv resolutie tot 2000 PPM.
Sluit de K30 module aan op de Arduino volgens onderstaand overzicht:
K30 pin: | Arduino pin: | Voeding: |
---|---|---|
OUT 2 | A0 | |
4 - GND | GND | GND |
5 - VCC (3v - 6v) | VCC (3v - 6v) |
Script Analoog
Onderstaand script geeft het aantal PPM weer van de CO2 in de lucht (tot max. 2000 ppm).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
int analogPin = 0; int val = 0; int volt; int waarde; void setup() { Serial.begin(9600); } void loop() { volt = analogRead(analogPin); waarde = map(volt, 0, 1023, 0, 2000); Serial.print("PPM Waarde: "); Serial.println(waarde); delay(1000); } |
Het resultaat
1 2 3 4 5 6 |
PPM Waarde: 515 PPM Waarde: 511 PPM Waarde: 511 PPM Waarde: 511 PPM Waarde: 505 PPM Waarde: 511 |
Aansluiten op de Arduino (I2C)
Pinout:
Sluit de K30 module aan op de Arduino volgens onderstaand overzicht:
K30 pin: | Arduino pin: | Voeding: |
---|---|---|
2 - SDA (Serial Data) | A4 | |
3 - SDL (Serial Clock) | A5 | |
4 - GND | GND | GND |
5 - VCC (3v - 6v) | VCC (3v - 6v) |
Script I2C
Wat heb je nodig?
– Arduino K30 Co2 sensor bibliotheek
Onderstaand script geeft het aantal PPM weer van de CO2 in de lucht.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
#include <K30_I2C.h> void setup() { Serial.begin(9600); } K30_I2C k30_i2c = K30_I2C(0x68); int co2 = 0; int rc = 1; void loop() { Serial.print("Reading K30 sensor ...... \n"); rc = k30_i2c.readCO2(co2); if (rc == 0){ Serial.print("Succesful reading\n"); Serial.print(co2); Serial.print(" ppm"); } else{ Serial.print("Failure to read sensor\n"); } Serial.println("\n"); delay(3000); //time between readings } |
Het resultaat
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
Reading K30 sensor ...... Succesful reading 573 ppm Reading K30 sensor ...... Succesful reading 573 ppm Reading K30 sensor ...... Succesful reading 574 ppm Reading K30 sensor ...... Succesful reading 577 ppm Reading K30 sensor ...... Succesful reading 578 ppm |
Bronnen:
create.arduino.cc
Aansluiten op de Arduino (UART)
Het is ook mogelijk de K30 sensor uit te lezen via RX/TX , echter krijg ik hem niet aan de praat, ook niet op een Arduino MEGA op serial1/2 en verschillende baud rates geprobeerd!
Sluit de K30 module aan op de Arduino volgens onderstaand overzicht:
K30 pin: | Arduino pin: | Voeding: |
---|---|---|
RX | 13 (TX) | |
TX | 12 (RX) | |
4 - GND | GND | GND |
5 - VCC (3v - 6v) | VCC (3v - 6v) |
Script UART
Onderstaand script geeft het aantal PPM weer van de CO2 in de lucht.
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 |
// AN-126 Demo of K-30 using Software Serial #include <SoftwareSerial.h> /* Basic Arduino example for K-Series sensor Created by Jason Berger Co2meter.com */ #include "SoftwareSerial.h" SoftwareSerial K_30_Serial(12, 13); //Sets up a virtual serial port, using pin 12 for Rx and pin 13 for Tx byte readCO2[] = {0xFE, 0X44, 0X00, 0X08, 0X02, 0X9F, 0X25}; //Command packet to read Co2 (see app note) byte response[] = {0,0,0,0,0,0,0}; //create an array to store the response //multiplier for value. default is 3. set to 3 for K-30 and 10 for K-33 ICB int valMultiplier = 3; void setup() { Serial.begin(9600); //Opens the main serial port to communicate with the computer K_30_Serial.begin(9600); //Opens the virtual serial port with a baud of 9600 Serial.println("Demo of AN-126 Software Serial and K-40 Sensor"); } void loop() { sendRequest(readCO2); unsigned long valCO2 = getValue(response); Serial.print("Co2 ppm = "); Serial.println(valCO2); delay(2000); } void sendRequest(byte packet[]) { while(!K_30_Serial.available()) { //keep sending request until we start to get a response Serial.println("waiting for Software.serial port availability"); K_30_Serial.write(readCO2,7); delay(50); } int timeout=0; //set a timeout counter while(K_30_Serial.available() < 7 ) {//Wait to get a 7 byte response timeout++; if(timeout > 10) { //if it takes too long there was probably an error while(K_30_Serial.available()) //flush whatever we have K_30_Serial.read(); break; //exit and try again } delay(50); } for (int i=0; i < 7; i++) { response[i] = K_30_Serial.read(); } } unsigned long getValue(byte packet[]) { int high = packet[3]; //high byte for value is 4th byte in packet in the packet int low = packet[4]; //low byte for value is 5th byte in the packet unsigned long val = high*256 + low; //Combine high byte and low byte with this formula to get value return val* valMultiplier; } |
Bronnen:
instructables.com
community.particle.io
Arduino Library
K30 CO2 sensor module I2C Library
This is an Arduino Library for K30 CO2 NDIR module from Senseair. The sensor module is connected to Arduino using I2C. The sensor module is powered by an external power supply (5V or higher) capable of 1000mA.
The library contains two example sketches for two configurations:
- Arduino connected to K30. Sensor readings go to SerialMonitor.
- Arduino connected to K30 and LCD1602-I2C. Sensor readings are displayed on LCD1602.
Schema
GEEN GEGEVENS
Teardown
GEEN GEGEVENS
Datasheet
Fritzing
Downloads
GEEN GEGEVENS