Gas / smoke sensor MQ-2 with TinkerPie
Detects LPG, smoke and alcohol vapour. Let it warm up for a minute.
| Type | Analog sensors |
|---|---|
| Connect to | P10-P13 |
| Gives | 0-100 % (more gas = high) |
| Simulator | Yes: a control appears under the simulated board |
How it works
The MQ-2 has a heated sensing layer that reacts to burnable gases (LPG, propane, methane, hydrogen), smoke and alcohol vapour. More gas changes its resistance and raises the reading.
How to wire it
Plug the module's A0 / OUT into P10 (or P11-P13 when Wi-Fi is off), VCC to 3.3 V, GND to GND.
Code
In blocks: Accessories category in TinkerPie Studio. As code:
// JavaScript
sensors.gasMQ2(Pin.P10)
// Arduino C++
sensors::gasMQ2(Pin::P10) Good to know
- Warm it up for at least a minute before testing.
- Test with a cotton bud dipped in hand sanitiser, never with a real gas leak.
- It is for learning, not a certified safety alarm.
Projects with the Gas / smoke sensor MQ-2
Similar modules
- Potentiometer (knob)
- Soil moisture sensor
- Light sensor module (LDR)
- Sound sensor module
- Air quality sensor MQ-135
- Rain drop sensor
- Water level sensor
- Force sensor (FSR)
More projects to try
Questions
Can I try the Gas / smoke sensor MQ-2 without buying one?
Yes. In TinkerPie Studio the simulator shows a control for it under the board, so you can test your program before you build it.
Can I use the MQ-2 as my home gas alarm?
No. It is a great way to learn how gas alarms work, but homes need a certified gas detector. If you ever smell gas, tell an adult at once.