Smoke and Carbon Monoxide Detector Using Arduino, the MQ2 Gas Sensor and a OLED Display

by 734361 in Circuits > Arduino

317 Views, 1 Favorites, 0 Comments

Smoke and Carbon Monoxide Detector Using Arduino, the MQ2 Gas Sensor and a OLED Display

IMG_0773.jpg
IMG_0770.jpg
IMG_0769.jpg

In this instructable I am going to be making a carbon monoxide and smoke detector.

In this version of a smoke detector we are going to have 3 buttons, that controls different aspects of the smoke and CO detector.

If high levels of smoke or CO is detected by the MQ2 gas sensor the LED flashes and the buzzer makes an alarm noise, alerting others if its presence. Its very important to have one of these as CO, carbon monoxide has no odor, color or taste and is virtually impossible to sense, and has the capability of giving us carbon monoxide poisoning.

If the sensor detects more than 100 PPM of either smoke or CO, the alarm goes off, the amount of smoke or CO will be displayed on the OLED display for you to see exactly how much CO or smoke is around you in PPM.

Supplies

IMG_0759_(1).jpg

1x Arduino Uno

1x Small Solderless Breadboard

1x MQ2 Gas Sensor

1x 0.96" I2C OLED Display

1x Buzzer

3x Push Buttons

3x 10k Ohm Resistors

1x 330 Ohm Resistor

1x Red LED

Wires (Any Color)

Assembly and Wiring

Screenshot 2024-01-18 231550.png
IMG_0763.jpg
IMG_0772.jpg

This is where the bulk of your time is going to be spent, the wiring and assembly. Yours doesn't have to look like mine you can assemble in anyway you would like.

Start with adding your OLED, 3 buttons, 1 red LED and 1 buzzer to ap[propriate places on your breadboard.

OLED: To wire the OLED add a jumper cable from the power and ground rail into the VCC and GND pins of the display. Furthermore put the SCL pin in the A5 pin on the Arduino, and put the SDA pin in A4 on the Arduino, and that's all for the the OLED display.

LED: Put a 330 OHM resistor in the cathode side of the LED. Make a wired connection to the LED with Digital Pin 12 on the Arduino, making sure this wire goes into the anode side. Now, your LED is nice and wired

Push Buttons: Start by putting a 10k OHM resistor in each button from the negative rail of the breadboard. After doing so add a power jumper cable from the power rail to the opposite side that you put the resistor. Lastly, in Button 1 (The one on the furthest left), connect the same side that you put the resistor to with Digital Pin #3 on the Arduino, repeat steps for other buttons, and connect Button 2 (Middle) to the Digital Pin #4, and make the last button connected to Digital Pin #6.

Buzzer: For the buzzer add a ground jumper cable from the negative rail of the breadboard to the ground side of the buzzer, next connect a wire coming form Digital Pin #2 to the positive side of the buzzer.

MQ2 Gas Sensor: For the Gas Sensor, add a positive and negative jumper cable from each respective rail of the breadboard, the the positive in VCC and the ground in GND. To finish off put a wire in the A0 pin of the Arduino and connect it to the A0 pin of the MQ2 Gas Sensor.

To conclude make sure your wiring is neat and will connected to reduce risk of wires coming out, and you should be all set to run the code!


Upload the Code!

The libraries needed are listed below.

Code is provided below. To explain briefly:

In void setup, we initialize the serial monitor, OLED Display, LED, Buzzer, & Buttons. Then Calibrate the MQ2 Sensor.

In the loop section, we read the button state and display different modes on OLED Display. Then We calculate Smoke and CO from the MQ2 sensor and store those values on ppm and ppm1 variables. Now, Arduino sends these values to the OLED Display for Monitoring. At the same time, It also checks if these values are above the safe level then it sends a command to the buzzer and a LED. IF values are above safe levels then the buzzer starts alarming with a flashing LED.

How It Works!

IMG_0769.jpg
IMG_0770.jpg

The smoke detector has 3 buttons, the furthest left makes the CO appear as the main gas that's being measures, the middle button make Smoke the main gas measured on the OLED, and lastly the button on the very left, turns the alarm on and off. Now to activate the buttons you have to press and hold for 2 seconds, let go and wait 1-2 seconds, and it should change. Above are 2 pictures showing the circuit in 2 modes, CO and smoke, they measure at the same time, but one or the other can be set as the main one.

Demonstration

Smoke and Carbon Monoxide Detector Using Arduino, the MQ2 Gas Sensor and a OLED Display

Extension!

IMG_0788.jpg
IMG_0787.jpg
IMG_0791.jpg
IMG_0792.jpg

This is an optional extension that adds a 7 Segment Display, and a Green LED

The display goes from numbers 1-9, depending on the concentration (PPM) of the smoke or CO. This is a fun extension just to show how severe the concentration of CO or Smoke is in your environment, and this adds an extra challenge.

The green LED is an extra indication that there is power going to the carbon monoxide detector, as CO is an invisible gas we need to make sure that is has power and is working. It not working would be worse than being safe.