Ardino Gas Sensors

January 31, 2024 | No comments

 


//#include 

#define MQ2pin (0)
//https://robu.in/mq2-sensor-interfacing-with-arduino-gas-and-smoke-detection/
float sensorValue;  //variable to store sensor value

void setup()
{
  Serial.begin(9600); // sets the serial port to 9600
  Serial.println("Gas sensor warming up!");
  Serial.println("I can detect 300 - 10000ppm");

  delay(20000); // allow the MQ-2 to warm up
}

void loop()
{
  sensorValue = analogRead(MQ2pin); // read analog input pin 0
  
  Serial.print("Sensor Value: ");
  Serial.print(sensorValue);
  
  Serial.println("");
  delay(2000); // wait 2s for next reading
}

No comments :

Post a Comment

Please leave your message queries or suggetions.