Hello. I am working on my first Arduino project. I have limited knowledge of arduino, microcontrollers, and the likes, but I am learning the best I can. I would appreciate help with this roadblock, as I have not been able to find a solution.
I have received the MG-811 CO2 sensor attached to the op-amp available from sandbox(SEN-000007). I have read the product data sheet and have tried to understand it to the best of my abilities. I have a 9V power supply for the heating element. I understand the VCC will connect to 5V on the UNOR3. I know the GND will be the ground on uno.
I am assuming the VOUT could connect to any available analong in (A0,A1...A5)? Is this correct?
I have not been able to understand the connection for BOOL. It says comparator output. This is new to me and anything I have found searching has not been helpful. Later in the data sheet it says I should add a pull-up resistor to BOOL. This is great but...what size?
still looking for help. Ive been searching everywhere and can't find any concrete information. I found someone using the same sensor and based on the picture it appeared the BOOL was left unconnected. This doesnt seem right to me though based on my understanding of what it does.
To start the data sheet says you need between 6-12 volts into the sensor...i used an mq sensor before and you need to 'burn it in' as it uses a heating element for readings. Just connect power ground and vout to an analog pin and read off the values in the s.monitor.
My co2 sensor was an NDIR teleaire 5004 or something like that. It uses a laser and optic filter to analyse co2 what could be more accurate if set up properley.
Have you figured this out? I am in the same boat as you. I also purchased the MG811 carbon dioxide sensor module for Arduino from Sandbox Electronics. I hooked up my 6V power supply to the barrel connector on the Sandbox board. I connected the black wire (GND) from the Sandbox board to Gnd on my Arduino Uno. I connected the red wire (VCC) from the Sandbox board to 5V on my Arduino Uno. I connected the yellow wire (VOUT) from the Sandbox board to A0 (analog pin 0) on my Arduino Uno. I connected the green wire (BOOL) from the Sandbox board to digital pin 0 on my Arduino Uno. Then I copied the Arduino code that was included in the Sandbox datasheet http://sandboxelectronics.com/store/images/SEN-000007/SEN-000007_Source.php
The code compiled, but when I ran it, the following kept scrolling on the Serial Monitor:
=====BOOL is LOW=====
SEN-00007: 0.00V CO2: -18346ppm
This isn't right, but what have I done wrong? I didn't understand the part about the pull-up resistors that was mentioned in the datasheet. Is that the problem? If so, what do I need to do? Any suggestions are welcome! Also, I noticed that the MG811 got really hot when I was running the Arduino code. Is that what is supposed to happen, or have I broken the sensor?
The MG-811 needs to be run in before use. Power up the heater and leave it over night.
The boolean output simply compares the analog output agains a voltage set by the tiny variable resistor next to the 4-pin connector. Its an open drain output which means you need to enable the pullup on your digital input pin, ie: pinMode(X, INPUT_PULLUP);
where X is the pin you want to use.
Don't use pin 0 if you are also using the Serial port.
Personally I just use the analog output.
I use the following code to convert the adc reading to ppm, and then to a percentage, where 0% is 400ppm and 100% is 40000ppm. (this makes it easier read and understand for my application)
The variables v400ppm and v40000ppm are the voltages output by the amplifier at the corresponding CO2 levels. 400ppm is roughly ambient, and 40000ppm is roughly exhaled breath. Place the sensor in a plastic bag, squash out the air, exhale into it and close the neck of the bag to get a value for v40000ppm. It takes a couple of minutes at most to heat up (after running in), and about 30-60 seconds to respond to large changes in CO2.
SandboxElectronics MG-811 page contains a selection of useful resources including the (rather poor) data sheet for the MG-811, and full circuit diagrams and notes on the voltage regulator, amplifier and comparator circuits of the Sandbox board.
//================ CO2 ==============================
float v400ppm = 1; //MUST BE SET ACCORDING TO CALIBRATION
float v40000ppm = 0.25; //MUST BE SET ACCORDING TO CALIBRATION
float deltavs = v400ppm - v40000ppm;
float A = deltavs/(log10(400) - log10(40000));
float B = log10(400);
int getCo2(int adcValue){
float voltage = (float)adcValue/204.6; //convert adc value to voltage
// Calculate co2 from log10 formula (see sensor datasheet)
float power = ((voltage - v400ppm)/A) + B;
float co2ppm = pow(10,power); //at this point we have ppm
int val = map(co2ppm,400,40000,0,100); //now we have a percentage
return constrain(val,0,999); //prevent silly readings from messing up my lcd
}
Okay, finally back to working on this project. Very useful information curator23. My only issue now is while calibrating I've noticed the voltage creeps up continually. I've burnt in for 48 hours, and it is still creeping. Relocated sensor to outdoors and same results. I don't have the BOOL pin connected as it appears unnecessary.
After over 48 hours burning in I turned off for a day and started a data logger:
Plug-in volts = 2.28
1 hour later volts = 2.63
1 hour later volts = 2.74
1 hour later volts = 2.79
Data shows volts begin to stabilize after 2+ hours, but still creeping. Using with a data logger to make sure its not my breath causing the increase. Wondering if I should switch to a different sensor or if this sensor can be trusted. I don't need exact ppm, but I do need some sort of accuracy.