BAHAN :
1. Arduino Uno R3 Rp 50.000
2. Sensor Gas MQ-135 - MQ135 Kualitas Udara - Air Quality RP 30.000
3. Kabel Jumper Female Female Breadboard Arduino Wire Sensor Cable AB71 Rp 10.000
● Arduino Uno
● Komputer + Software IDE Arduino
● Modul Sensor Gas MQ-2
● Kabel Jumpe
VCC 5V
GND GND
A0 A0
KODE PROGRAM
1
2
3 /* --- www.nyebarilmu.com --- */
4
5 #include <MQ2.h>
6
7 int pinAout = A0;
8 int lpg_gas, co_gas, smoke_gas;
9
10 MQ2 mq2(pinAout);
11
12 void setup(){
13 //Set serial monitor pada baut 9600
14 Serial.begin(9600);
15 mq2.begin();
16 }
17
18 void loop(){
19
20 /*Pembacaan ketiga gas sekaligus dalam satuan PPM
21 * No.1 = Gas LPG
22 * no.2 = Gas CO
23 * n0.3 = Gas SMOKE
24 */
25
26 float* values= mq2.read(true); //jika diset "false" tidak akan dimunculkan di serial monitor
27
28 lpg_gas = mq2.readLPG();
29 co_gas = mq2.readCO();
30 smoke_gas = mq2.readSmoke();
31
32 delay(1000);
33 }
34
Bahan yang perlu dipersiapkan :
Wiring rangakaian
Sensor Gas MQ-2 LCD 16×2 + PCF8574 Arduino Uno
VCC VCC 5V
SDA A4
SCL A5
1
2
3 /* project uno */
4
5 #include <LiquidCrystal_PCF8574.h>
6 #include <MQ2.h>
7 #include <Wire.h>
8
9 LiquidCrystal_PCF8574 lcd(0x38);
10 // dapat dicek menggunakan i2c finder
11
12 int pinAout = A0;
13 int lpg_gas, co_gas, smoke_gas;
14
15 MQ2 mq2(pinAout);
16
17 void setup(){
18 //Set serial monitor pada baut 9600
19 Serial.begin(9600);
20 lcd.begin(16, 2); //prosedur pemanggilan LCD
21 lcd.setBacklight(255);
22
23 lcd.setCursor(00, 00); //set pada baris 1 dan kolom 1
24 lcd.print("*Hello World*"); //menuliskan "Hello World"
25 Serial.println("*Hello World*");
26 lcd.setCursor(00, 1); //set pada baris 2 dan kolom 1
27 Serial.print("*tegar abdullah*");
28 lcd.print("*tegar abdullah*"); //menuliskan "nyebarilmu.com"
29 delay(3000);
30
31 lcd.clear(); //menghapus data sebelumnya
32
33 mq2.begin();
34 }
35
36 void loop(){
37
38 /*Pembacaan ketiga gas sekaligus dalam satuan PPM
39 * No.1 = Gas LPG
40 * no.2 = Gas CO
41 * n0.3 = Gas SMOKE
42 */
43
44 float* values= mq2.read(true); //jika diset "false" tidak akan dimunculkan di serial monitor
45
46 lpg_gas = mq2.readLPG();
47 co_gas = mq2.readCO();
48 smoke_gas = mq2.readSmoke();
49
50 lcd.setCursor(00,00);
51 lcd.print("LPG:");
52 lcd.print(lpg_gas);
53 lcd.print(" CO:");
54 lcd.print(co_gas);
55 lcd.setCursor(00,1);
56 lcd.print("SMOKE:");
57 lcd.print(smoke_gas);
58 lcd.print(" PPM");
59 delay(1000);
60 }
61