Smoke Detector with Alarm and LED Indicators

While the MQ-2 gas sensor is one among a range of gas sensor types, it is roughly suitable for coarse experimentation for substances other than smoke. This sensor is sensitive to smoke and Liquid Petroleum Gas (LPG), Butane, Propane, Methane, Alcohol, and Hydrogen, but this project is set up for smoke detection to further explore its functionality, capabilities, and limitations.

The project includes a sensor to detect smoke as an input source that senses the presence of flammable gases or the origination of smoke and smoke itself in its immediate environment. The circuit is assembled to also include a buzzer alarm and two LEDs to indicate status (red for alarm and green for normal). While the sensor sits in its free space, it detects normal levels of air as a comparison to any gases or smoke that might be mixed in. That normal level is a threshold set with a sensitivity setting on the sensor itself (a small trim potentiometer).

The alarm and status LED changes are triggered from a threshold set within code according to the sensitivity setting trimmed as a configuration at the sensor. The range of high or low sensitivity is limited to the specifications of the sensor.

Project Schematic:

Assembly of this project is a simple effort to connect all relevant components. Three 330-ohm resistors, 1 active buzzer, 1 green LED, 1 red LED, 1 MQ-2 gas sensor, and an Arduino Nano with a USB-Mini connection to a computer for programming support. The Arduino Nano also provides power for the circuit as a whole while it is in operation.

Smoke Detector Circuit using the MQ-2 Gas Sensor.

Project Review:

An incense stick was safely lit to produce the smoke necessary to run this test. As smoke is presented to the sensor from the incense stick, the detector sets off the alarm and illuminates the LED as expected. When the smoke is removed from the sensor’s proximity, the system automatically returns to normal as expected.


Code Example:

While this code is for generic evaluation use, it is further expected to calibrate the detector’s sensor by first setting it into free air within its environment and establish a low/high condition with respect to ambient humidity and temperature. As a range, the threshold level set within code and trimmed on the sensor should take into account normal air conditions excluding the presence of smoke. The calibration level within a +/- range is not set within this project, but it is important to take these conditions into account for more precise applications. This project is simply for rough experimentation with a default threshold value trimmed with a wide latitude for variability in air quality or conditions.

//For MQ-2 Gas Sensor

int redLed = 12;
int greenLed = 11;
int buzzer = 10;
int smoke = A5;

/* Set threshold value then trim sensor value (read from Serial Monitor) at a % below to account for the range of variation in humidity and temperature. */

int sensorThreshold = 400;

void setup()
{
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(smoke, INPUT);
Serial.begin(9600);
}

void loop()
{
int analogSensor = analogRead(smoke);

Serial.print(“Sensor Reading: “);
Serial.println(analogSensor);
// Checks if it has reached the threshold value
if (analogSensor > sensorThreshold)
{
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, LOW);
tone(buzzer, 1000, 200);
}
else
{
digitalWrite(redLed, LOW);
digitalWrite(greenLed, HIGH);
noTone(buzzer);
}
delay(100);
}


About

Servant of Christ Jesus. U.S. Military Veteran, Electrical Engineer, Pepperdine MBA, and M.A. Biblical and Theological Studies.

, ,

Comments are closed.