My wife has (more than) a good property: even in bad weather, the window is regularly opened and aired. So pay attention to me and I rarely have headaches with this fresh air supply. When I went for a walk, I met Asian tourists, who were with a typical mouthguard - as I knew this from the hospital - on the way. This startled me: how is the air quality precisely regulated?
The ideaWith the purchase of a cheap MQ-7 sensor from the country of the tourist visitors it had to me at least possible to determine the carbon monoxide content. With the help of the data sheet I have elicited values from the sensor and output this at the serial interface.
Oh something else, no, I do not know why the MQ-7 is also called "Flying Fish". I assume that the inventor of the sensor was not only talented, but also creative.
SchematicFollow at first this easy Schematic:
A0 = signal: read analog values and Ground to GND and Plus to VIN. I powered my Photon over USB.
// MQ-7 wiring
#define analogMQ7 A0 // Signal
#define ledPin D7 // Device internal LED
int MQ7sensorValue = 0; // value read from the sensor
PreparationI am going to stabilize the processes within the loop, since some preparation is necessary before the analog value can be read in via A0. Interestingly, the MQ-7 provides a "mini-heater". I can not go into detail physically here, but I have taken the times from the data sheet and tried to work out in the chapter Preparation.
// A) preparation
// turn the heater fully on
analogWrite(analogMQ7, HIGH); // HIGH = 255
// heat for 1 min
delay(60000);
// now reducing the heating power: turn the heater to approx 1,4V
analogWrite(analogMQ7, 71.4); // 255x1400/5000
// heat for 90 sec
delay(90000);
Even in the case of wholesalers, the preparatory phase is dispensed with and examples are shown which convey the usual reading of the values.
ReadingSubsequently, the value is read in as described in chapter Reading.
// B) reading
// CO2 via MQ7: we need to read the sensor at 5V, but must not let it heat up. So hurry!
analogWrite(analogMQ7, HIGH);
delay(50); // Getting an analog read apparently takes 100uSec
MQ7sensorValue = analogRead(analogMQ7);
OutputAfter output to the serial interface, the values are interpreted as follows:
// C) print the results to the serial monitor
Serial.print("MQ-7 PPM: ");
Serial.println(MQ7sensorValue);
// D) interpretation
// Detecting range: 20ppm-2000ppm carbon monoxide
// air quality-cases: < 200 perfect, 200 - 800 normal, > 800 - 1800 high, > 1800 abnormal
if (MQ7sensorValue <= 200)
{
Serial.println("Air-Quality: CO perfect");
}
else if ((MQ7sensorValue > 200) || (MQ7sensorValue <= 800)) // || = or
{
Serial.println("Air-Quality: CO normal");
}
else if ((MQ7sensorValue > 800) || (MQ7sensorValue <= 1800))
{
Serial.println("Air-Quality: CO high");
}
else if (MQ7sensorValue > 1800)
{
digitalWrite(ledPin, HIGH); // optical information in case of emergency
Serial.println("Air-Quality: ALARM CO very high");
delay(3000);
digitalWrite(ledPin, LOW);
}
else
{
Serial.println("MQ-7 - cant read any value - check the sensor!");
}
Serial MonitorIf the Particle CLI is installed on the desktop PC, the access to the serial monitor can be done using the following command:
particle serial monitor --follow
The values can now be transferred via the smartphone with Blynk or into various cloud services for recording. The acoustic warning in case of high CO content with the aid of a buzzer would also be conceivable.
ConclusionsLike my description? You will find more under my account. Follow me to be notified when I publish new projects!
Here is my Paypal link.
Comments