CircuitPlanning:
Arduino UNO R3 --> MQ2 Sensor
Pins--> Vin-->Vcc
Pins--> GND --> GND
Pins--> A0 --> A0
Code://Coded and tested by :
// Sheekar Banejee, AI-ML-IOT Solution Engineer and Researcher
int smokeA0 = A0;
// Your threshold value
int sensorThres = 700;
void setup() {
pinMode(smokeA0, INPUT);
Serial.begin(9600); //Streaming 9600 bits of Sensor Data per Second
}
void loop() {
int analogSensor = analogRead(smokeA0);
Serial.println("Sensor Value: ");
Serial.println(analogSensor);
// Checks if it has reached the threshold value
if (analogSensor > sensorThres)
{
Serial.println("Alert! Smoke Detected!");
}
else
{
Serial.println("Normal...");
}
delay(3000);
}
Results:Serialmonitor:
0 projects • 6 followers
A motivated Computer Scientist & Engineer with years of experience over IoT, Robotic Systems, Machine Learning Algorithms and Software.
Comments
Please log in or sign up to comment.