There are some very low cost MQ-2 sensors ($3-$5) that can be used to measure common combustible gases such as hydrogen, butane, methane, propane and liquid petroleum gas (LPG).
My goal for this project was to make a handheld monitor that we could use to measure potential leaks in our propane BBQ or natural gas leaks in and around our furnace.
Setup
For our setup we used:
- a MQ-2 sensor
- 4 digit LED display ($3)
- Arduino Nano
- Small bread board
- USB battery charger
- jumpers and duct tape
Some duct tape can be used to secure the bread board to the USB battery unit. We used a low cost 4 digit display and we mounted it direct to the bread board.
Code
We were only interested in a “GAS” or “NO GAS” reading, so because of this our code was super simple.
#include <Arduino.h> #include <TM1637Display.h> // Module connection pins (Digital Pins) #define CLK 2 #define DIO 3 TM1637Display display(CLK, DIO); int smokeA0 = A0; // Your threshold value int sensorThres = 400; void setup() { pinMode(smokeA0, INPUT); Serial.begin(9600); display.setBrightness(0x0f); } void loop() { int analogSensor = analogRead(smokeA0); Serial.print("Pin A0: "); Serial.println(analogSensor); display.showNumberDec(analogSensor, false); delay(1000); }
If you want to get accurate gas measurements then you’ll need to do some calibration. We were only interested in a seeing something above a “clear air” reading. For our setup a “clear air” reading was about 100-115. To test our project we used a butane lighter and we open it very quickly (<1 second).