You wire that module right to your Arduino, all needed components are on the module.
Here is a tutorial for that family of sensors,use the AOUT pin on the MQ-7 module.
The trim cap is for adjusting DOUT.
Accurate calibration is difficult at home, the datasheet tells you to allow the module to pre-heat "No Less Than 48 Hours".
A good way to self calibrate is:
Set your project up in the location that needs monitoring in a place where no one will be breathing on it.
Allow the 48+ hour pre-heat.
View the readings on the IDE serial monitor, that will be the areas "natural CO level" reading.
(Tricky part here) Determine the level of CO (IDE serial reading) needed to trigger an action.
Put your "trigger value" in the tutorial code here:
if (sensorValue >= 750)// Change 750 to your CO trigger limit
No and no, like I said here "You wire that module right to your Arduino, all needed components are on the module."
Gnd pin -> Gnd on module, 5V pin -> VCC pin on module, Analog pin -> AOUT pin on module.
i am using this module, too and solved the calibration this way:
after the pre-heating time (which the sensor really needs - you can see that on the values written via serialMonitor or so) i got the then readed values, built a middle value and created a multiplier.
For that i got from several pages in the net where the "normal" concentration is published (here normally between 1.8 and 2.4 - i used 2.1) and used that value to find my multiplier.
i also set some warning range - values between 2.4 and ~ 3.3 are dangerous for health, values above that are dangerous for life.
I am still not sure when to do the reading. The sensor is connected and I see the analog readings in the Serial, but they are random numbers going up and down. I have tried using a CO source, but this didn't make any difference. Is the DOUT any useful and it needs to be connected or not?
If someone has any code example or calibration notes, please share!
// CO2 Gas Sensor
const int GasSensorPin = A5; // Analog input pin that the Sensor is attached to
int GasSensorValue = 0;
float GasFactor = 24.57143; //28571428571428571428571429
void_loop()
{
// read the analog in value:
GasSensorValue = analogRead(GasSensorPin);
Serial.print("CO2-Sensor : ");
Serial.println(GasSensorValue / GasFactor);
delay(1750);
}
i think, like as many sensor this one also needs some time to read the datas.
The delay(1750) is the minimum on a MEGA
The sensors are very sensitive, to the "wild" numbers are OK.
If you use a divider like me you'll see, that that then stops (of course)
How did you manage to do the 60s @ 5v and 90s @ 1.4v? I read a lot about the MQ7 and it says that you heat the sensor for 60 seconds at 5v and you don't read and then you power it at 1.4 volt for 90s and then you read values..
Did you do that or you just power it at 5v and get the readings with the factor etc?
I see that this module you got (same have I) has some resistors and an LM393 chip. Do they have to do with the voltage levels we need? What are they for? LM393 is for comparing voltages but I can't understand why it is needed in that moudle.
How did you manage to do the 60s @ 5v and 90s @ 1.4v? I
Dont know how exact your results must be, but in the datasheet also is written, that it needs approx. 24 h to heat up, but it works correctly after 1 one hour or so.
I am reading that sensor only all 5 minutes, so no problem with time manegement
This is the mq7 module that i have. It has 4 PINS. Do i used them all? How about the calibration part, do i have place any other device or it does it by itself? Please, im new with this and i really appreciate your answer to be very ''ABC'', like step by step that a 10 years old can understand.
I'm still kind of confused. I know that you're saying that all you're supposed to need to do is hook this directly up to the Arduino, but that doesn't really make sense. The datasheet for the sensor says that it needs heater time at both 5v and 1v4 in order for the sensor to be accurate, but the components on the board don't seem to be able to provide something like that. And, the LM 393 datasheets say that they need at least 2v to operate. So, does that mean that I won't ever be able to get real accuracy out of the SainSmart board?
If all I need to do is hook the board directly to the Arduino, and give it straight 5v, please help me understand why this is the case, when the datasheets seem to state otherwise?
I'm not sure about the Sainsmart module, but I put my sensor on a SF breakout and used a PWM to change the voltage through a transistor.
//An NPN transistor must be used to power the heater-
//I am using a BC547
//Additionally, specs require alternating voltage, so we are
//going to cycle with a switching BOOL, and read our samples
//when the sensor is at high voltage output.
#define heater 11
#define ind 13//used for debugging
int COval = 0;
boolean heatstage = false;
long lowV = 60000;
long highV = 90000;
long sensorRead = 1000;
unsigned long time = 0;
unsigned long sensorTime = 0;
void setup(){
Serial.begin(9600);
pinMode(ind, OUTPUT);//for testing
analogWrite(heater, 71);
}
void loop(){
COval = analogRead(0); // read analog input pin 0
unsigned long currentTime = millis();
if (heatstage == false){
if (currentTime - time > lowV){
time = currentTime;
heatstage = true;
analogWrite(heater, 71);
digitalWrite(ind, HIGH);
}
}
if (heatstage == true){
if (currentTime - time > highV){
time = currentTime;
heatstage = false;
analogWrite(heater, 255);
digitalWrite(ind, LOW);
}
}
if (currentTime - sensorTime > sensorRead){
Serial.println(COval, DEC);
sensorTime = currentTime;
}
}
ndawg:
I'm not sure about the Sainsmart module, but I put my sensor on a SF breakout and used a PWM to change the voltage through a transistor.
//An NPN transistor must be used to power the heater-
//I am using a BC547
//Additionally, specs require alternating voltage, so we are
//going to cycle with a switching BOOL, and read our samples
//when the sensor is at high voltage output.
#define heater 11 #define ind 13//used for debugging
int COval = 0;
boolean heatstage = false;
long lowV = 60000;
long highV = 90000;
long sensorRead = 1000;
unsigned long time = 0;
unsigned long sensorTime = 0;
Module is wrong connection to ANY MQ sensor .... Take measure since cleaning the grid. continuous 5volt on Heating coil. Impossible to have true reading.
I'm working on a 5 pin breakout
Vcc 5v ( continuous voltage input)
Vh 1.4v to 5v:( using pwm pin for heating) [on board self timer 60/90 and stop reading in 5volt heating phase in long term development]
DO digital output (alarm signal)
AO analog output
GND.
Just move sensor to a new PCB.
You control voltage to heater with an I/O pin.
I used pin A3 for analog and Digital pin 3 for transistor control in this example code
(copy your 'serial output' to excel - do a graph to see..)
(also attached MY graph)
// sensor MQ7. alternate heater 5V/1.4V 60sec/90sec
// read sensor @ 88sec(of 90-period)
// Kn.Ny '16
// This program to be used as CO-alarm in tents wintertime during night. (gasoline or firewood burners)
// ****************************************************************************************************
#define a_pin A3
#define powerpin 3
#define lotime 90000UL // 90 sek lav
#define hitime 60000UL // 60 sek høy
int start_val, end_val; // read analog value
unsigned long next_time,read_time;
boolean low_now,done_reading; // remember status
void setup()
{
Serial.begin(9600);
pinMode(powerpin, OUTPUT);
pinMode(13, OUTPUT); // may be omitted
}
void loop()
{
if (millis() >= next_time) // switch voltage 5V <-> 1.4V
{
if (low_now) // then switch to high
{
next_time += hitime; // set next change to 90 sec
digitalWrite(powerpin, HIGH); // => 5V
digitalWrite(13, HIGH); // LED may be omitted
low_now = false;
}
else
{
next_time += lotime;
read_time=next_time-2000; // read 2 sek ahead of end low period
done_reading=false; // note: ready for new reading @ end of this period
digitalWrite(powerpin,LOW); // => 1.4V
digitalWrite(13, LOW); // LED - optional
low_now = true;
}
}
if (!done_reading & (millis()>read_time)) // then do a reading now
{
int co_eqv=1023-analogRead(a_pin); // with this code: alarm @ level 235 (ca. 100 ppm CO)
Serial.println(co_eqv); // should be range 15..25 after 30 min runtime
done_reading=true;
// check for alarm. In MY setup 100ppm CO will give reading 235+-
if (co_eqv > 235) ; // take action - sound alarm
}
}
@knut_ny Thanks for the setup. After burning the mq-7 for 48 hours @ 5V, the readings are consistent with the ones you provided. I used an IRLB8721PBF for the switching.
So will just connecting mq7 sensor MODULE to arduino at 5V for 48hrs be fine to preheat it?
If not.. how to apply alternating 5V and 1.4 V as described in datasheet?