Skip to content

Commit 9954244

Browse files
committed
feat: add mq2-gas-sensor
1 parent c21520e commit 9954244

File tree

3 files changed

+283
-0
lines changed

3 files changed

+283
-0
lines changed

docs/parts/wokwi-mq2-gas-sensor.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: wokwi-mq2-gas-sensor Reference
3+
sidebar_label: wokwi-mq2-gas-sensor
4+
---
5+
6+
MQ2 Gas Sensor module
7+
8+
<wokwi-gas-sensor />
9+
10+
## Pin names
11+
12+
| Name | Description |
13+
| ---- | --------------------- |
14+
| VCC | Positive power supply |
15+
| GND | Ground |
16+
| DO | Digital output |
17+
| AO | Analog output |
18+
19+
## Attributes
20+
21+
| Name | Description | Default value |
22+
| --------- | ------------------------------------- | ------------- |
23+
| ppm | part per million | "400" |
24+
| threshold | Digital output threshold voltage | "4.4" |
25+
26+
## Operation
27+
28+
The MQ2 Gas Sensor is a semiconductor sensor that can detect the presence of various combustible gases including LPG, Propane, Hydrogen, Methane, and Carbon Monoxide. The sensor has both analog and digital outputs:
29+
30+
- The analog output (AO) provides a continuous voltage reading that corresponds to the gas concentration(ppm). Higher gas concentration results in higher voltage output.
31+
- The digital output (DO) acts as a threshold detector - it goes LOW when gas concentration exceeds the threshold set by the potentiometer.
32+
33+
To use the MQ2 sensor:
34+
35+
1. Connect VCC to 5V power supply
36+
2. Connect GND to ground
37+
3. For analog readings:
38+
- Connect AO to an analog input pin
39+
- Read the analog value to get relative gas concentration
40+
4. For threshold detection:
41+
- Connect DO to a digital input pin
42+
- The pin will read LOW when gas concentration exceeds threshold
43+
- Adjust threshold using the `threshold` attribute
44+
45+
Note: In real hardware, the sensor needs a pre-heating time of about 20-30 seconds before taking readings. The simulator provides readings immediately.
46+
47+
48+
### Digital output
49+
50+
The digital output (DO) pin will read LOW when gas concentration exceeds the threshold. The threshold is set by the `threshold` attribute. The default threshold is 4.4V.
51+
52+
53+
## Simulator examples
54+
55+
- [MQ2 Gas Sensor Digital Example](https://wokwi.com/projects/424318978955716609)

docs/parts/wokwi-mq2-gas-sensor.svg

Lines changed: 227 additions & 0 deletions
Loading

sidebars.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ module.exports = {
5454
'parts/wokwi-membrane-keypad',
5555
'parts/wokwi-microsd-card',
5656
'parts/wokwi-mpu6050',
57+
'parts/wokwi-mq2-gas-sensor',
5758
'parts/wokwi-nlsf595',
5859
'parts/wokwi-nokia-5110-screen',
5960
'parts/wokwi-ntc-temperature-sensor',

0 commit comments

Comments
 (0)