Arduino projects: Gas detector

One of the most popular sensors almost everyone has at home is the gas detectors. It makes your home a little smarter than usual by adding to it the ability to detect dangerous gases. This can actually save lives.

Making yours can provide a lot a fun and will actually help understand more about these type of sensors.

Let’s build a project that detects gases like CO and afterdamp.

Keep in mind that our sensor wouldn’t be certified and tested professionally as the one you have at home but it does not remove the usefulness of it.

We are going to use the very popular gas sensor: MQ-7. But you can also use the CO2 sensor or the alcohol sensor. They are all very similar and you can use them almost the same way.

Parts needed

Making

So as always we will start by connecting everything as shown in the schematic below.

Make sure you connect the analog output of the sensor to the Arduino.

It is a really good idea to use both the LED and the buzzer (visual + sound) as the output signal because it increases the probability of the signal to be noticed.

Before powering it on, I want to mention this one thing: this sensor heats up to measure gas in the air. It is normal that it gets hot or smell like it was burning.

Upload the code when you are done with the wiring.

The project simply reads the output values from the sensor and base on that, blink the LED faster or slower. At some value above the threshold, the buzzer should turn ON.

Beyond the visual and sound output using the LED and the buzzer, it also sends the output information to the Serial monitor so you can see what is happening and eventually adjust the code accordingly.

void setup() {
Serial.begin(9600);
pinMode(5, OUTPUT);
pinMode(8, OUTPUT);
}

void loop() {
Serial.println(analogRead(A0));
digitalWrite(5, !digitalRead(5));
if(analogRead(A0) > 150 || digitalRead(8))
{
digitalWrite(8, !digitalRead(8));
}
delay(map(analogRead(A0), 50, 200, 5000, 200));
}

The easiest way to check how this sensor works is to blow on it, you should see how the values on the serial monitor are increasing, the LED starts to blink faster and the buzzer turning ON.

tchouken2

Related Posts