Skip to content
This repository was archived by the owner on Jun 9, 2026. It is now read-only.

Commit 2d3630a

Browse files
committed
v1.0.0 initial release
0 parents  commit 2d3630a

17 files changed

Lines changed: 491 additions & 0 deletions

BACA.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?style=flat)](https://github.com/ellerbrock/open-source-badges/)
2+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?logo=github&color=%23F7DF1E)](https://opensource.org/licenses/MIT)
3+
![GitHub last commit](https://img.shields.io/github/last-commit/cakraawijaya/MQ2_LPG?logo=Codeforces&logoColor=white&color=%23F7DF1E)
4+
![Project](https://img.shields.io/badge/Project-Library-light.svg?style=flat&logo=arduino&logoColor=white&color=%23F7DF1E)
5+
![Type](https://img.shields.io/badge/Type-Personal%20Experiment-light.svg?style=flat&logo=gitbook&logoColor=white&color=%23F7DF1E)
6+
7+
# MQ2_LPG
8+
Pustaka ini digunakan untuk membaca data gas LPG: propana (C3H8) dan butana (C4H10) yang ditangkap oleh sensor.
9+
10+
<br>
11+
12+
## INFORMASI UMUM
13+
<img src="extras/documentation/pinout/MQ2.jpg" alt="mq2-sensor-pinout"><br><br>
14+
• Kreator: Devan Cakra M.W.
15+
16+
• Lembar data: <a href="https://components101.com/sensors/mq2-gas-sensor">Klik Disini</a>
17+
18+
• Cara mengkalibrasi bagian LPG pada sensor MQ-2: <a href="extras/articles/Cara Kalibrasi.md">Klik Disini</a>
19+
20+
• Versi Pustaka: V1.0.0 (08-April-2023).
21+
22+
• Fitur: Terdapat fungsi kalibrasi MQ-2 yang dinamis, sehingga memudahkan pengguna untuk membaca data gas, terutama LPG.
23+
24+
<br><br>
25+
26+
## Apresiasi
27+
Jika karya ini bermanfaat bagi anda, maka dukunglah karya ini sebagai bentuk apresiasi kepada penulis dengan mengklik tombol ``` ⭐Bintang ``` di bagian atas repositori.
28+
29+
<br><br>
30+
31+
## LISENSI
32+
LISENSI MIT - Hak Cipta © 2023 - Devan C. M. Wijaya, S.Kom
33+
34+
Dengan ini diberikan izin tanpa biaya kepada siapa pun yang mendapatkan salinan perangkat lunak ini dan file dokumentasi terkait perangkat lunak untuk menggunakannya tanpa batasan, termasuk namun tidak terbatas pada hak untuk menggunakan, menyalin, memodifikasi, menggabungkan, mempublikasikan, mendistribusikan, mensublisensikan, dan/atau menjual salinan Perangkat Lunak ini, dan mengizinkan orang yang menerima Perangkat Lunak ini untuk dilengkapi dengan persyaratan berikut:
35+
36+
Pemberitahuan hak cipta di atas dan pemberitahuan izin ini harus menyertai semua salinan atau bagian penting dari Perangkat Lunak.
37+
38+
DALAM HAL APAPUN, PENULIS ATAU PEMEGANG HAK CIPTA DI SINI TETAP MEMILIKI HAK KEPEMILIKAN PENUH. PERANGKAT LUNAK INI DISEDIAKAN SEBAGAIMANA ADANYA, TANPA JAMINAN APAPUN, BAIK TERSURAT MAUPUN TERSIRAT, OLEH KARENA ITU JIKA TERJADI KERUSAKAN, KEHILANGAN, ATAU LAINNYA YANG TIMBUL DARI PENGGUNAAN ATAU URUSAN LAIN DALAM PERANGKAT LUNAK INI, PENULIS ATAU PEMEGANG HAK CIPTA TIDAK BERTANGGUNG JAWAB, KARENA PENGGUNAAN PERANGKAT LUNAK INI TIDAK DIPAKSAKAN SAMA SEKALI, SEHINGGA RISIKO ADALAH MILIK ANDA SENDIRI.

LICENSE

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MIT License
2+
3+
Copyright © 2023 - Devan C. M. Wijaya, S.Kom.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[![Open Source Love](https://badges.frapsoft.com/os/v1/open-source.svg?style=flat)](https://github.com/ellerbrock/open-source-badges/)
2+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?logo=github&color=%23F7DF1E)](https://opensource.org/licenses/MIT)
3+
![GitHub last commit](https://img.shields.io/github/last-commit/cakraawijaya/MQ2_LPG?logo=Codeforces&logoColor=white&color=%23F7DF1E)
4+
![Project](https://img.shields.io/badge/Project-Library-light.svg?style=flat&logo=arduino&logoColor=white&color=%23F7DF1E)
5+
![Type](https://img.shields.io/badge/Type-Personal%20Experiment-light.svg?style=flat&logo=gitbook&logoColor=white&color=%23F7DF1E)
6+
7+
# MQ2_LPG
8+
This library is used to read the LPG gas data: propane (C3H8) and butane (C4H10) captured by the sensor.
9+
10+
<br>
11+
12+
## GENERAL INFORMATION
13+
<img src="extras/documentation/pinout/MQ2.jpg" alt="mq2-sensor-pinout"><br><br>
14+
• Creator: Devan Cakra M.W.
15+
16+
• Datasheet: <a href="https://components101.com/sensors/mq2-gas-sensor">Click Here</a>
17+
18+
• How to calibrate the LPG part of the MQ-2 sensor: <a href="extras/articles/How To Calibration.md">Click Here</a>
19+
20+
• Library Version: V1.0.0 (08-April-2023).
21+
22+
• Features: There is a dynamic MQ-2 calibration function, making it easier for users to read gas data, especially LPG.
23+
24+
<br><br>
25+
26+
## Appreciation
27+
If this work is useful to you, then support this work as a form of appreciation to the author by clicking the ``` ⭐Star ``` button at the top of the repository.
28+
29+
<br><br>
30+
31+
## LICENSE
32+
MIT License - Copyright © 2023 - Devan C. M. Wijaya, S.Kom
33+
34+
Permission is hereby granted without charge to any person obtaining a copy of this software and the software-related documentation files to deal in them without restriction, including without limitation the right to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons receiving the Software to be furnished therewith on the following terms:
35+
36+
The above copyright notice and this permission notice must accompany all copies or substantial portions of the Software.
37+
38+
IN ANY EVENT, THE AUTHOR OR COPYRIGHT HOLDER HEREIN RETAINS FULL OWNERSHIP RIGHTS. THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, THEREFORE IF ANY DAMAGE, LOSS, OR OTHERWISE ARISES FROM THE USE OR OTHER DEALINGS IN THE SOFTWARE, THE AUTHOR OR COPYRIGHT HOLDER SHALL NOT BE LIABLE, AS THE USE OF THE SOFTWARE IS NOT COMPELLED AT ALL, SO THE RISK IS YOUR OWN.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Library: Gas MQ2-LPG
2+
// By: Devan Cakra M.W
3+
4+
#include "MQ2_LPG.h" // library declaration
5+
#define MQ2PIN A0 // mq2 pin declaration
6+
7+
MQ2Sensor mq2(MQ2PIN); // create a new object with the name mq2 to hold the MQ2Sensor class
8+
9+
void setup() {
10+
Serial.begin(9600); // default baudrate for the Arduino board
11+
mq2.begin(); // initiate mq2 sensor
12+
}
13+
14+
// gas calibration data
15+
#define RL_Value 100 // 100K ohm
16+
#define x1_Value 199.150007852152
17+
#define x2_Value 797.3322752256328
18+
#define y1_Value 1.664988323698715
19+
#define y2_Value 0.8990240080541785
20+
#define x_Value 497.4177875376839
21+
#define y_Value 1.0876679972710004
22+
#define Ro_Value 6.02
23+
#define Voltage_Value 5.0
24+
#define bitADC_Value 1023.0 // development board adc resolution
25+
26+
void calibration(){
27+
mq2.RL(RL_Value); // resistance load setting
28+
mq2.Ro(Ro_Value); // reverse osmosis setting
29+
mq2.Volt(Voltage_Value); // voltage sensor setting
30+
mq2.BitADC(bitADC_Value); // development board adc resolution setting
31+
mq2.mCurve(x1_Value, x2_Value, y1_Value, y2_Value); // mCurve setting
32+
mq2.bCurve(x_Value, y_Value); // bCurve setting
33+
mq2.getCalibrationData(); // get data calibration
34+
mq2.viewCalibrationData(); // print to serial monitor: data calibration
35+
}
36+
37+
void loop() {
38+
calibration(); // calls calibration method
39+
mq2.readGas(); // reading mq2 sensor data
40+
mq2.viewGasData(); // print to serial monitor: gas value & status
41+
delay(3000); // delay for 3 seconds
42+
}

extras/articles/Cara Kalibrasi.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
## Mencari Nilai Ro (Reverse Osmosis)
2+
3+
```ino
4+
#include "MQ2_LPG.h" // library declaration
5+
#define MQ2PIN A0 // mq2 pin declaration
6+
7+
MQ2Sensor mq2(MQ2PIN); // create a new object with the name mq2 to hold the MQ2Sensor class
8+
9+
void setup() {
10+
Serial.begin(9600); // default baudrate for the Arduino board
11+
mq2.begin(); // initiate mq2 sensor
12+
}
13+
14+
// gas calibration data
15+
#define RL_Value 10 // 10K ohm
16+
#define x1_Value 0
17+
#define x2_Value 0
18+
#define y1_Value 0
19+
#define y2_Value 0
20+
#define x_Value 0
21+
#define y_Value 0
22+
#define Voltage_Value 5.0
23+
#define bitADC_Value 1023.0 // development board adc resolution
24+
25+
void calibration(){
26+
mq2.RL(RL_Value); // resistance load setting
27+
mq2.Volt(Voltage_Value); // voltage sensor setting
28+
mq2.BitADC(bitADC_Value); // development board adc resolution setting
29+
mq2.mCurve(x1_Value, x2_Value, y1_Value, y2_Value); // mCurve setting
30+
mq2.bCurve(x_Value, y_Value); // bCurve setting
31+
mq2.getCalibrationData(); // get data calibration
32+
mq2.viewCalibrationData(); // print to serial monitor: data calibration
33+
}
34+
35+
void loop() {
36+
calibration(); // calls calibration method
37+
delay(3000); // delay for 3 seconds
38+
}
39+
```
40+
41+
<br>
42+
43+
<div align="justify">
44+
45+
Setelah data Ro didapatkan, maka langkah selanjutnya yaitu memasukkan data Ro tersebut ke bagian #define.
46+
47+
```ino
48+
#define Ro_Value 6.31
49+
```
50+
51+
<br><br>
52+
53+
## Mencari Titik Koordinat Yang Sesuai
54+
55+
Bukalah link berikut: <a href="https://automeris.io/WebPlotDigitizer/">WebPlotDigitizer</a> , lalu klik ``` Launch Now! ```. Kemudian klik ``` Load Image ```. Hal tersebut dapat anda ketahui selengkapnya di bawah ini.
56+
57+
<img src="../documentation/experiment/Load Image.jpg" alt="load-image">
58+
59+
Upload gambar sesuai dengan link yang telah disediakan: <a href="../documentation/experiment/Calibration Graph.jpg" alt="calibration-graph">Klik disini</a>.
60+
61+
<br>
62+
63+
Kemudian memilih tipe plot: ``` 2D (X-Y) Plot ```. Selanjutnya klik ``` Align Axes `````` Proceed ```.
64+
65+
<img src="../documentation/experiment/Plot Type.jpg" alt="plot-type"><br>
66+
67+
Selanjutnya, anda harus memberikan batas nilai, mulai dari ``` X1 → X2 → Y1 → Y2 ```. Selanjutnya klik ``` Complete! ``` untuk mengatur ``` X-Axis ``` dan ``` Y-Axis ```. Jangan lupa untuk mencentang bagian ``` Log Scale `````` OK ```.
68+
69+
<img src="../documentation/experiment/Axes Calibration.jpg" alt="axes-calibration"><br>
70+
71+
Langkah berikutnya, klik ``` Add Point (A) ```, lalu pilih kurva yang diinginkan (dalam hal ini hanya menggunakan LPG dan Propane). Jangan lupa cari titik koordinat yang saling berhimpitan satu sama lain seperti yang ditampilkan pada gambar berikut.
72+
73+
<img src="../documentation/experiment/Add Point.jpg" alt="add-point"><br>
74+
75+
Kemudian, klik ``` View Data ``` untuk mengetahui nilai dari titik koordinat yang telah dipilih tadi. Misalnya seperti yang terlihat pada gambar di bawah ini.
76+
77+
<img src="../documentation/experiment/View Data.jpg" alt="view-data"><br>
78+
79+
Langkah terakhir, data koordinat diatas kemudian dimasukkan kedalam kode yang ada di Arduino IDE bagian #define.
80+
81+
```ino
82+
#define x1_Value 199.150007852152
83+
#define x2_Value 797.3322752256328
84+
#define y1_Value 1.664988323698715
85+
#define y2_Value 0.8990240080541785
86+
#define x_Value 497.4177875376839
87+
#define y_Value 1.0876679972710004
88+
```
89+
90+
<br>
91+
92+
Lalu unggah program.&nbsp;&nbsp;&nbsp;<strong>~ SELESAI... , SELAMAT MENCOBA</strong> ~
93+
94+
</div>
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
## Finding Ro (Reverse Osmosis) Value
2+
3+
```ino
4+
#include "MQ2_LPG.h" // library declaration
5+
#define MQ2PIN A0 // mq2 pin declaration
6+
7+
MQ2Sensor mq2(MQ2PIN); // create a new object with the name mq2 to hold the MQ2Sensor class
8+
9+
void setup() {
10+
Serial.begin(9600); // default baudrate for the Arduino board
11+
mq2.begin(); // initiate mq2 sensor
12+
}
13+
14+
// gas calibration data
15+
#define RL_Value 10 // 10K ohm
16+
#define x1_Value 0
17+
#define x2_Value 0
18+
#define y1_Value 0
19+
#define y2_Value 0
20+
#define x_Value 0
21+
#define y_Value 0
22+
#define Voltage_Value 5.0
23+
#define bitADC_Value 1023.0 // development board adc resolution
24+
25+
void calibration(){
26+
mq2.RL(RL_Value); // resistance load setting
27+
mq2.Volt(Voltage_Value); // voltage sensor setting
28+
mq2.BitADC(bitADC_Value); // development board adc resolution setting
29+
mq2.mCurve(x1_Value, x2_Value, y1_Value, y2_Value); // mCurve setting
30+
mq2.bCurve(x_Value, y_Value); // bCurve setting
31+
mq2.getCalibrationData(); // get data calibration
32+
mq2.viewCalibrationData(); // print to serial monitor: data calibration
33+
}
34+
35+
void loop() {
36+
calibration(); // calls calibration method
37+
delay(3000); // delay for 3 seconds
38+
}
39+
```
40+
41+
<br>
42+
43+
<div align="justify">
44+
45+
<i>After the Ro data is obtained, the next step is to enter the Ro data into the #define section.</i>
46+
47+
```ino
48+
#define Ro_Value 6.31
49+
```
50+
51+
<br><br>
52+
53+
## Finding the Right Coordinate Point
54+
55+
<i>Open the following link: <a href="https://automeris.io/WebPlotDigitizer/">WebPlotDigitizer</a> , then click ``` Launch Now! ```. Then click ``` Load Image ```. You can find out more about this below.</i>
56+
57+
<img src="../documentation/experiment/Load Image.jpg" alt="load-image">
58+
59+
<i>Upload the image according to the link provided: <a href="../documentation/experiment/Calibration Graph.jpg" alt="calibration-graph">Click here</a>.</i>
60+
61+
<br>
62+
63+
<i>Then choose a plot type: ``` 2D (X-Y) Plot ```. Then click ``` Align Axes `````` Proceed ```.</i>
64+
65+
<img src="../documentation/experiment/Plot Type.jpg" alt="plot-type"><br>
66+
67+
<i>Next, you must provide a value limit, starting from ``` X1 → X2 → Y1 → Y2 ```. Then click ``` Complete! ``` to set the ``` X-Axis ``` and ``` Y-Axis ```. Don't forget to tick the ``` Log Scale `````` OK ``` section.</i>
68+
69+
<img src="../documentation/experiment/Axes Calibration.jpg" alt="axes-calibration"><br>
70+
71+
<i>In the next step, click ``` Add Point (A) ```, then select the desired curve (in this case using only LPG and Propane). Don't forget to look for coordinate points that overlap each other as shown in the following image.</i>
72+
73+
<img src="../documentation/experiment/Add Point.jpg" alt="add-point"><br>
74+
75+
<i>Then, click ``` View Data ``` to find out the value of the coordinate point that was selected earlier. For example, as shown in the image below.</i>
76+
77+
<img src="../documentation/experiment/View Data.jpg" alt="view-data"><br>
78+
79+
<i>In the final step, the coordinate data above is then entered into the code in the #define section of the Arduino IDE.</i>
80+
81+
```ino
82+
#define x1_Value 199.150007852152
83+
#define x2_Value 797.3322752256328
84+
#define y1_Value 1.664988323698715
85+
#define y2_Value 0.8990240080541785
86+
#define x_Value 497.4177875376839
87+
#define y_Value 1.0876679972710004
88+
```
89+
90+
<br>
91+
92+
Then upload the program.&nbsp;&nbsp;&nbsp;<strong>~ DONE... , GOOD LUCK</strong> ~
93+
94+
</div>
301 KB
Loading
251 KB
Loading
30.1 KB
Loading
183 KB
Loading

0 commit comments

Comments
 (0)