Gas Sensor(MQ2) module is useful for gas leakage detection. This particular version is suitable for detecting H2, LPG, CH4, CO, Alcohol, Smoke or Propane. Due to its high sensitivity and fast response time, measurements can be taken as soon as possible. The sensitivity of the sensor can be adjusted by using the potentiometer which is present on the module
Code
In this example we simply connect the AOUT to Analog pin 1 and read in the value and output this via the serial monitor. Note that since the Chipkit Uno is 3.3v that Vcc must be connected to 3.3v. We also use that in the calculation below.
You could of course just use the reading, you would need to have a cutoff value that would trigger an alarm if this was exceeded, in other words if any gas was detected.
[cpp]
void setup() { Serial.begin(9600); } void loop() { float sensor_volt; float sensorValue; sensorValue = analogRead(A1); sensor_volt = sensorValue/1024*3.3; Serial.print("sensor_volt = "); Serial.print(sensor_volt); Serial.println("V"); delay(1000); }
[/cpp]
Links
CG312 MQ2 Smoke Gas Sensor Module for Arduino (Works with Official Arduino Boards)