It has been a busy week with Halloween and some unforeseen breakdowns on the farm. we will be catching up on a slow week today.


CO2 is an important factor in plant growth, in some instances sealed grow rooms run at a artificiality elevated CO2 concentration. We wont be doing this in the greenhouse but it would be nice to have a fully defined set of growing conditions for comparing experiments.


DfRobot have been kind enough to send me out a PH sensor and CO2 sensor to keep the project moving along quickly, so we will be using the parts from them:


CO2 Sensor (Arduino compatible)

[You can most likely source the parts from elsewhere]


I will wire the sensor up and talk about how it performs in the next blog on CO2, I think we need to find a cheap way to calibrate the sensors as not everyone is going to have access to CO2 calibration gases [I certainly dont]. Looking at the spec sheet[for the MG811] it might not need calibration, a real life test will be needed to confirm this.


Wiring diagram:




Header 1


   CO2 Sensor Gas:


This script allows you to use a analog c02 gas sensor [like the one in the link below]:






>warm sensor up and take a reading of two known c02 solutions  [note down ADC readout and c02 ppm]

>plug the numbers into the top of the code [Lines 28-31]

>see if it works with a amonia solution between the min and max you calibrated with.





other info:

>Burn Sensor in for a hour or so before stable readings will be had

>Sensor needs time to warm up after being powered up








   25/10/2015  Michael   Ratcliffe



          This program is free software: you can redistribute it and/or modify

    it under the terms of the GNU General Public License as published by

    the Free Software Foundation, either version 3 of the License, or

    (at your option) any later version.



    This program is distributed in the hope that it will be useful,

    but WITHOUT ANY WARRANTY; without even the implied warranty of


    GNU General Public License for more details.



    You should have received a copy of the GNU General Public License

    along with this program.  If not, see <>.


Sensors and useful info:

>Gas Sensor needs burning in before first use







int GasPin=A0;

float CO2MinADC=0;

float CO2MaxADC=0;

float CO2MinPPM=0;

float CO2MaxPPM=0;



//We will proberbly have to correct for temperature in the long run [not used yet]

float Temperature=0;

float Temp_Coef=0;

float Offset=0;



//[Im guessing it will be liner with a offset]



int i=0;

int SensorBuffer=0;

float CO2PPM=0;

float Gas_Readout=0; //Float incase we attempt to change ADC to PPM

// ************************ Setup Routine ********************************//

void setup() {



  Serial.begin(9600);// turn serial coms on for sending data to pc






//************************** Main Loop ***********************************//


void loop() {

      //Taking ten readings and averaging for accuracy




      Gas_Readout= analogRead(GasPin);





      Gas_Readout=SensorBuffer/i;  // cheack that my maths is correct her, I usssualy cock up this bit by one iteration











//*************** Printing dome useful info to seerial on boot up *********//

void Setup_Info(){

Serial.println("This script is a proof of concept that we can get useful representation of amonia in water by measuring its gas off");

Serial.println("Gas Sensor needs burning in before first use [30 mins minimum]");

Serial.println("Calibrate, take ADC read out at MAX CO2 and Min and put them in the top od code");











//****************Maps Results after we have Calibration values************//

void Map_Results(){



// Map only gives integers, we will need to modify to get better readings  [thats what all the *100 are about

CO2PPM = map(Gas_Readout*100, CO2MinADC*100, CO2MaxADC*100, CO2MinPPM*100, CO2MaxPPM*100);






//********************Print something useful to Serial here****************//

void Print_Results(){

Serial.println("NEW RESULTS ");

Serial.print("ADC Gas Sensor: ");


Serial.print("Amonia PPM: ");








Check out the home page for updates:


Automated Green House Blog's Home Page