How to make an indoor CO2 monitor?

Does the office have suitable environment although it’s warm? Concerning the greenhouse effect, we may detect the concentrations of carbon dioxide in our environment to check whether it exceeds the standard. My CO2 monitor based on Arduino is very simple. Only four hardware equipment are required. You may try to make one right away!
Component:
DFRduino UNO R3 (same as Arduino UNO R3) *1
LCD12864 Shield for Arduino *1
Gravity: Analog CO2 Gas Sensor For Arduino *1
7.4V Lipo 2500mAh Battery *1
Please remember to put U8g library into Arduino’s library before directly use the codes below.
After detected, the indoor concentration of CO2 is <400 ppm at present. Don't worry. It’s suitable for survival.
Effect Picture
Code
Code: Select all/* # This Sample code is for display the CO2 sensor output on LCD12864. # Editor : Phoebe # Date : 2014.1.15 # Ver : 0.1 # Product: LCD12864 Shield for Arduino # SKU : DFR0287 # Hardwares: 1. Arduino UNO 2. LCD12864 Shield for Arduino 3. CO2 Sensor #Steps: 1.Connect the CO2 Sensor to the Analog pin 0 2.Power the UNO board with 7~12V */ #include "U8glib.h" U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8); // SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8 #define MG_PIN (1) //define which analog input channel you are going to use #define BOOL_PIN (2) #define DC_GAIN (8.5) //define the DC gain of amplifier #define READ_SAMPLE_INTERVAL (50) //define how many samples you are going to take in normal operation #define READ_SAMPLE_TIMES (5) //define the time interval(in milisecond) between each samples in #define ZERO_POINT_VOLTAGE (0.324) //define the output of the sensor in volts when the concentration of CO2 is 400PPM #define REACTION_VOLTGAE (0.020) //define the voltage drop of the sensor when move the sensor from air into 1000ppm CO2 float CO2Curve[3] = { 2.602,ZERO_POINT_VOLTAGE,(REACTION_VOLTGAE/(2.602-3))}; int percentage; float volts; /***************************** LCD12864 display *********************************** Display the voltage & ppm data on the LCD12864 ************************************************************************************/ void draw() { u8g.setFont(u8g_font_unifont); u8g.drawStr( 0,11,"Voltage:"); u8g.setPrintPos(70,11); u8g.print(volts); u8g.drawStr( 110, 11,"V" ); u8g.drawStr(0,30,"CO2:"); if (percentage == -1) { u8g.drawStr( 40,30,"<400" ); } else { u8g.setPrintPos(40,30); u8g.print(percentage,DEC); } u8g.drawStr( 80,30,"ppm" ); u8g.drawStr( 3, 63,"www.DFRobot.com" ); } /***************************** MGRead ********************************************* Input: mg_pin - analog channel Output: output of CO2 Sensor Remarks: This function reads the output of CO2 Sensor ************************************************************************************/ float MGRead(int mg_pin) { int i; float v=0; for (i=0;i<READ_SAMPLE_TIMES;i++) { v += analogRead(mg_pin); delay(READ_SAMPLE_INTERVAL); } v = (v/READ_SAMPLE_TIMES) *5/1024 ; return v; } /***************************** MQGetPercentage ********************************** Input: volts - CO2 Sensor output measured in volts pcurve - pointer to the curve of the target gas Output: ppm of the target gas Remarks: By using the slope and a point of the line. The x(logarithmic value of ppm) of the line could be derived if y(MG-811 output) is provided. As it is a logarithmic coordinate, power of 10 is used to convert the result to non-logarithmic value. ************************************************************************************/ int MGGetPercentage(float volts, float *pcurve) { if ((volts/DC_GAIN )>=ZERO_POINT_VOLTAGE) { return -1; } else { return pow(10, ((volts/DC_GAIN)-pcurve[1])/pcurve[2]+pcurve[0]); } } void setup() { u8g.setRot180();// rotate screen, if required } void loop() { volts = MGRead(MG_PIN); percentage = MGGetPercentage(volts,CO2Curve); u8g.firstPage(); do { draw(); } while( u8g.nextPage() ); delay(200); }