How to use MG811

Hi.

I got the sensor MG811 that senses carbon dioxide, you can see an image of the sensor here

I googled to use that sensor properly but i have doubts about the wiring with arduino and the proper way to calibrating.

So, i got think i can got the data from AOUT pin, but i really don't know if i can use the 5V pin from arduino to connect in vdd or i need another source (around 12V).
So, what are the function of the other pins DOUT and TCM?

I tried with this article, but i cannot identify what pin is BOOL conected to Arduino.
Also, thers Heat pin and vcc pin, so, is there two source pins?

thanks.

Are you connecting directly to the Arduino or through a breakout board with amplifier and other components.

If connecting direct then see this. If throught a breakout board then supply links to the board your using.

Hi Riva.

I'm not using the sensor directly, is on a board with an amplifier, twi trimpot and other components, as you can see here: http://blog.hunabsys.com/wp-content/uploads/2016/01/sensor-de-co2-dioxido-de-carbono-mg811-arduino-avr-pic-524201-MLM20295577058_052015-O.jpg

The Back view is like this: https://http2.mlstatic.com/sensor-gas-co2-mg811-ideal-invernaderos-arduino-pic-etc-S_605801-MEC20404119258_092015-F.jpg

My questions if about wiring and some example code i can use, i guided in this link: MG-811 CO2 Sensor Module | Sandbox Electronics

There i cannot identify what is the bool pin in the driver i'm using.

Thanks.

This eBay link seems to show the same breakout board your using and in the description there is an image that details what the pins are.

The bool pin will be Dout on the board and is pin 2 in the example sketch you linked to here. As the module has a TTL level adjust pot you will need to adjust it to get the desired on/off level from the sensor.

Thanks Riva.

I Wired the Module to Arduino as Follows:

VDD -> 5v Arduino
DOUT -> 2 Arduino
AOUT -> A0 Arduino
GND -> GND Arduino
Tcm -> A1 Arduino (Just to read and print value)

Also I run the example sketch that linked before and the result is:

MG-811 Demostration
SEN-00007:0.04V           CO2:-12194ppm
=====BOOL is LOW======
Temperature: 537

SEN-00007:0.04V           CO2:24900ppm
=====BOOL is LOW======
Temperature: 536

SEN-00007:0.04V           CO2:-26839ppm
=====BOOL is LOW======
Temperature: 537

SEN-00007:0.04V           CO2:-26839ppm
=====BOOL is LOW======
Temperature: 537

SEN-00007:0.04V           CO2:-26839ppm
=====BOOL is LOW======
Temperature: 537

SEN-00007:0.04V           CO2:13156ppm
=====BOOL is LOW======
Temperature: 537

SEN-00007:0.04V           CO2:-26839ppm
=====BOOL is LOW======
Temperature: 537

SEN-00007:0.04V           CO2:13156ppm
=====BOOL is LOW======
Temperature: 537

SEN-00007:0.04V           CO2:13156ppm
=====BOOL is LOW======
Temperature: 537

SEN-00007:0.04V           CO2:-1079ppm
=====BOOL is LOW======
Temperature: 537

SEN-00007:0.04V           CO2:-1079ppm
=====BOOL is LOW======
Temperature: 537

SEN-00007:0.04V           CO2:-26839ppm
=====BOOL is LOW======
Temperature: 537

SEN-00007:0.04V           CO2:13156ppm
=====BOOL is LOW======
Temperature: 538

SEN-00007:0.04V           CO2:-1079ppm
=====BOOL is LOW======
Temperature: 537

SEN-00007:0.05V           CO2:11924ppm
=====BOOL is LOW======
Temperature: 537

SEN-00007:0.05V           CO2:15833ppm
=====BOOL is LOW======
Temperature: 538

SEN-00007:0.02V           CO2:-3352ppm
=====BOOL is LOW======
Temperature: 538

SEN-00007:0.00V           CO2:28620ppm
=====BOOL is LOW======
Temperature: 537

SEN-00007:0.01V           CO2:12407ppm
=====BOOL is LOW======
Temperature: 536

SEN-00007:0.00V           CO2:28620ppm
=====BOOL is LOW======
Temperature: 536

SEN-00007:0.00V           CO2:-4300ppm
=====BOOL is LOW======
Temperature: 536

SEN-00007:0.00V           CO2:28620ppm
=====BOOL is LOW======
Temperature: 536

SEN-00007:0.00V           CO2:-4300ppm
=====BOOL is LOW======
Temperature: 536

SEN-00007:0.01V           CO2:29371ppm
=====BOOL is LOW======
Temperature: 536

SEN-00007:0.00V           CO2:-20713ppm
=====BOOL is LOW======
Temperature: 536

SEN-00007:0.00V           CO2:28620ppm
=====BOOL is LOW======
Temperature: 536

SEN-00007:0.00V           CO2:-20713ppm
=====BOOL is LOW======
Temperature: 535

SEN-00007:0.01V           CO2:29371ppm
=====BOOL is LOW======
Temperature: 535

SEN-00007:0.01V           CO2:-31369ppm
=====BOOL is LOW======
Temperature: 535

SEN-00007:0.01V           CO2:16204ppm
=====BOOL is LOW======
Temperature: 535

SEN-00007:0.01V           CO2:-31369ppm
=====BOOL is LOW======
Temperature: 535

SEN-00007:0.01V           CO2:24017ppm
=====BOOL is LOW======
Temperature: 535

SEN-00007:0.01V           CO2:-22552ppm
=====BOOL is LOW======
Temperature: 535

As you can see theres not consistent values so i can say the sketch works fine, so, what do you think i am missing on wire or Sketch?

Thanks.

BOOL never changes so the little potentiometer on the back of the module will need slowly turning until it changes to high at your required CO2 level.

Now the BOOL is HIGH but the values aren't consistent, so, do i need to change the potenciometers?

MG-811 DemostratiVoltaje: 0.00
MG-811 Demostration
Voltaje: 0.00
SEN-00007:V           CO2:-4300ppm
=====BOOL is HIGH======
Temperatura: 600

Voltaje: 0.01
SEN-00007:V           CO2:12407ppm
=====BOOL is HIGH======
Temperatura: 599

Voltaje: 0.02
SEN-00007:V           CO2:27839ppm
=====BOOL is HIGH======
Temperatura: 599

Voltaje: 0.03
SEN-00007:V           CO2:13053ppm
=====BOOL is HIGH======
Temperatura: 599

Voltaje: 0.04
SEN-00007:V           CO2:24900ppm
=====BOOL is HIGH======
Temperatura: 598

Voltaje: 0.05
SEN-00007:V           CO2:26769ppm
=====BOOL is HIGH======
Temperatura: 598

jpill:
Now the BOOL is HIGH but the values aren't consistent, so, do i need to change the potenciometers?

The idea of the BOOL output is that with the trimmer pot you can set it to change LOW/HIGH at a specific voltage so instead of reading an analogue value and converting it to a CO2 level using maths you can just use BOOL to give a simple answer to if the CO2 is above/below a set level. That way you would be able to use simple electronics instead of a MCU. As a theoretical example you have a test chamber with the sensor in and when the CO2 level goes above a certain level the BOOL output would turn on a fan to extract the CO2.

You do need to give these sensors a few minutes to warm up properly before taking readings (they do have a heater in them). As to why your code is not putting out consistent value I have no idea.
Are you using the exact same code as linked in your first post or are you using your own?
How is all this wired up and what other things are connected to the system?

It's going clear now Riva, in this case i don't need activate something, just need to get ppm

Yes, im using the exact code that is in the link, i let it running around 3 hours but the results is the same

I still have some questions, hope don't bother:

  • That sensor can work with the 5V of arduino?
  • Do i need the Tcm pin of the module?
  • Do i need to adjust the both trimmers?

Thanks a lot Riva.

Hi.

I change the Volt input to 6V, then i noted that the conditional of the volts over the DC_GAIN never turn true

if ((volts/DC_GAIN )>=ZERO_POINT_VOLTAGE)

So i changed the ZERO_POINT_VOLTAGE value from 0.22 to 0.39 , so i get ppm values that "seems" consistent.

so, do you think that change is fine or can give bad values?

Thanks

jpill:
So i changed the ZERO_POINT_VOLTAGE value from 0.22 to 0.39 , so i get ppm values that "seems" consistent.

so, do you think that change is fine or can give bad values?

Sorry jpill but I have no idea. The module your using is different to the one used for the demo program your also using so I would expect the values to be different but in what way I do not know.
As your now using 6V power then be careful in using the DOut & AOut output as they may swing between 0V & 6V now and that might damage your Arduino pins.

Hi jpill, now I am using the same module to your. If you were working fine with that, Please share me about that. thank you.

Hey everyone I have been using mg811 sensor for past two months but I haven't preheated it at all still it is showing me readings. I have connected my sensor to my laptop and i'm running the sensor on arduino ide on my laptop. Would it be alright If I preheat it now? And what should be the preheating period for my sensor to work properly?

Here is the link from where I have referred the code and connections -
https://navody.arduino-shop.cz/navody-k-produktum/detektor-oxidu-uhliciteho-co2-mg811.html

Thank You.