Loading
Loading
IoT Lab content is currently available in Arabic only. We're working on an English version.
عرض بالعربية →Detecting toxic or flammable gases as part of an alarm system.
MQ sensors usually come with a module having both analog (A0) and digital (D0) outputs. Connect VCC to 5V (not 3.3V) because the heater requires power.
void setup() {
Serial.begin(9600);
}
void loop() {
int gasLevel = analogRead(A0);
Serial.print("Gas Level: ");
Serial.println(gasLevel);
if(gasLevel > 400) {
Serial.println("ALARM: High Gas Concentration!");
}
delay(1000);
}Not giving the sensor time to warm up (Burn-in Time). MQ sensors need several minutes of operation (and sometimes 24 hours for accurate first-time calibration) before their readings stabilize.