Build a Wireless CO2 Sensor with Arduino


Posted May 10, 2016 by industryfans

Indoor Air Quality (IAQ) monitoring is growing trend in the home automation space. And one way to measure air quality is to measure the carbon dioxide (CO2) that is present in your home.

 
Indoor Air Quality (IAQ) monitoring is growing trend in the home automation space. And one way to measure air quality is to measure the carbon dioxide (CO2) that is present in your home. Indeed, high levels of CO2 in your home can lead to getting drowsy, having headaches, and functioning at lower activity levels. In this article, I will show you how to use this sensor with Arduino and how to interface it with the CC3000 WiFi chip to build a wireless CO2 sensor. Let’s dive in!
Hardware requirements
The whole project is based on the Arduino platform, so of course you will need an Arduino board. I really recommend using the Arduino Uno board for this project, as it is the only board that is currently compatible with the CC3000 library at the time this article was written.
Then, you need the CC3000 chip. I recommend is using the Adafruit CC3000 breakout board, which is the only one I tested that worked without problem. It is nice and compact, has voltage regulators onboard, as well as an onboard antenna.
Finally, you need a breadboard and some jumper wires to make the connections between the different parts.
Software requirements
For this project, you need the usual Arduino IDE. You will also need the Adafruit’s CC3000 library, as well as the library for the K30 sensor. Download the K30 CO2 sensor library (zip) here. To install a library, just download the folders, and put them into your /Arduino/libraries/ folder.
You will also need a web server running on your computer. There are thousands of tutorial for that, but I recommend using MAMP if you are on OS X.
The complete code for this project can be found on our GitHub repository.
Hardware configuration
The hardware configuration for this project is actually not that complicated, thanks to the good information that you will find about the CC3000 breakout board. Connect the IRQ pin of the CC3000 board to pin number 3 of the Arduino board, VBAT to pin 5, and CS to pin 10. Then, you need to connect the SPI pins to the Arduino board: MOSI, MISO, and CLK go to pins 11,12, and 13, respectively. Finally, take care of the power supply: Vin goes to the Arduino 5V, and GND to GND.
The K30 sensor is qui easy to connect: you need to connect two power pins (5V and GND) and two pins for the serial connection. The following picture summarises the hardware connections for the K30 sensor:

Testing the K30 sensor
We will now test the K30 sensor individually, just to be sure that your hardware connections are correct and that the sensor is functioning correctly. The kSeries library that you installed at the beginning of this tutorial handles most of the hard work to interface with the sensor. You first have to include the library:
1. #include "kSeries.h"
You then need to create an instance of the sensor. It uses the software serial library internally, so you also need to specify which pins you used for the serial connection:
1. kSeries K_30(6,7);
Then, reading the CO2 value from the sensor is actually easy:
1. double co2 = K_30.getCO2('p');
The rest of the sketch simply consists in printing out the value to the serial monitor. This is the complete sketch to test the K30 sensor:
1. #include "kSeries.h"
2.
3. // Create K30 instance on pin 6 & 7
4. kSeries K_30(6,7);
5.
6. void setup()
7. {
8. Serial.begin(9600);
9. }
10.
11. void loop()
12. {
13. // Get CO2 value from sensor
14. double co2 = K_30.getCO2('p');
15.
16. // Print the value on Serial
17. Serial.print("Co2 ppm = ");
18. Serial.println(co2);
19.
20. // Wait 2 seconds
21. delay(2000);
22. }
You can then upload the sketch to your Arduino board, and open the serial monitor. You should see the CO2 reading being printed every 2 seconds. The value should be between 500 ppm and 700 ppm if you are indoors.
-- END ---
Share Facebook Twitter
Print Friendly and PDF DisclaimerReport Abuse
Contact Email [email protected]
Issued By Sherry
Website Industry sourcing & Wholesale industrial products
Country China
Categories Retail
Tags co2 gas sensor , co2 sensor , co2 sensors , infrared co2 sensor , ndir co2 sensor , ndir gas sensor , ndir sensor , semiconductor gas sensor
Last Updated May 10, 2016