Monitor 4 Gas dan Suhu Kelembaban MQ7 MQ135 MQ136 MQ8 + DHT11
Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yang dapat memonitor 4 buah sensor gas yaitu MQ7 MQ135 MQ136 MQ8 dan suhu kelembaban DHT11. alat ini menggunakan Arduino dan LCD 20x4 I2c. jadi hasil pengukuran ditampilkan ke lcd terkait nilai yag didapat oleh sensor. untuk lebih jelasnya berikut adalah komponen dan kodingnya.
1. Komponen
2. Program Arduino IDE
#include <Wire.h> //library
#include <LiquidCrystal_I2C.h> //library lcd
#include "DHT.h" //library dht11
#define DHTPIN 7 // pin digital untuk dht11
#define DHTTYPE DHT11 // set dht11
DHT dht(DHTPIN, DHTTYPE); //set dht11
LiquidCrystal_I2C lcd(0x27, 20, 4); //untuk library lcd i2c
float ppm; //variabel untuk mq7
float RS_air; // Get the value of RS via in a clear air
float R0 = 0.25; // Get the value of R0 via in H2
float sensorValue; // variabel bisa pecahan
float sensor_volt; // variabel bisa pecahan
float RS_gas; //variabel bisa pecahan
float ratio; //variabel bisa pecahan
float kal;
float ppm2; //variabel untuk mq7
float RS_air2; // Get the value of RS via in a clear air
float R02 = 0.25; // Get the value of R0 via in H2
float sensorValue2; // variabel bisa pecahan
float sensor_volt2; // variabel bisa pecahan
float RS_gas2; //variabel bisa pecahan
float ratio2; //variabel bisa pecahan
float kal2;
float ppm3; //variabel untuk mq7
float RS_air3; // Get the value of RS via in a clear air
float R03 = 0.25; // Get the value of R0 via in H2
float sensorValue3; // variabel bisa pecahan
float sensor_volt3; // variabel bisa pecahan
float RS_gas3; //variabel bisa pecahan
float ratio3; //variabel bisa pecahan
float kal3;
float ppm4; //variabel untuk mq7
float RS_air4; // Get the value of RS via in a clear air
float R04 = 0.25; // Get the value of R0 via in H2
float sensorValue4; // variabel bisa pecahan
float sensor_volt4; // variabel bisa pecahan
float RS_gas4; //variabel bisa pecahan
float ratio4; //variabel bisa pecahan
float kal4;
float h,t;
int suhu, hum;
void setup() //prosedure
{
dht.begin(); //mulai dht11
lcd.begin(); //mulai lcd
lcd.clear(); //bersihakn lcd
lcd.noCursor(); //lcd tanpa kursor
}
void loop() //prosedure
{
h = dht.readHumidity(); //ambil data humidity
t = dht.readTemperature(); //ambil data suhu c
hum = h; //deklarasi variabel
suhu = t; //deklaras variabel
gasmq7(); //ambil data gas mq7
gasmq8();
gasmq135();
gasmq136();
lcd.setCursor(0,0); //untuk menampilkan d baris atas
lcd.print("S/H = "); //menulis huruf
lcd.print(suhu); //menulis suhu
lcd.print(" / ");
lcd.print(hum); //menulis suhu
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print("MQ7= ");
lcd.print(ppm);
lcd.print(" ");
lcd.setCursor(0,2); //untuk menulis d lcd bawah
lcd.print("MQ8= "); //menulis variabel
lcd.print(ppm2); //menulis nilai
lcd.print(" "); //menulis variabel
lcd.setCursor(0,3); //untuk menulis d lcd bawah
lcd.print("MQ135/6= "); //menulis variabel
lcd.print(ppm3); //menulis nilai
lcd.print("/"); //menulis variabel
lcd.print(ppm4); //menulis nilai
lcd.print(" "); //menulis variabel
}
void gasmq7(){ //prosedure
sensorValue = analogRead(A0); //untuk ambil adc sensor mq7
sensor_volt = sensorValue/1024*5.0; //untuk menjadi tegangan
RS_gas = (5.0-sensor_volt)/sensor_volt; //untuk rumus
ratio = RS_gas/R0; //Replace R0 with the value found using the calibration code
kal = 83.39 / ratio; //untuk rumus
ppm = pow(kal , 0.63); //untuk jadi ppm
delay(100); //delay
}
void gasmq8(){
sensorValue2 = analogRead(A1); //untuk ambil adc sensor mq7
sensor_volt2 = sensorValue2/1024*5.0; //untuk menjadi tegangan
RS_gas2 = (5.0-sensor_volt2)/sensor_volt2; //untuk rumus
ratio2 = RS_gas2/R02; //Replace R0 with the value found using the calibration code
kal2 = 83.39 / ratio2; //untuk rumus
ppm2 = pow(kal2 , 0.63); //untuk jadi ppm
delay(100); //delay
}
void gasmq135(){
sensorValue3 = analogRead(A2); //untuk ambil adc sensor mq7
sensor_volt3 = sensorValue3/1024*5.0; //untuk menjadi tegangan
RS_gas3 = (5.0-sensor_volt3)/sensor_volt3; //untuk rumus
ratio3 = RS_gas3/R03; //Replace R0 with the value found using the calibration code
kal3 = 83.39 / ratio3; //untuk rumus
ppm3 = pow(kal3 , 0.63); //untuk jadi ppm
delay(100); //delay
}
void gasmq136(){
sensorValue4 = analogRead(A3); //untuk ambil adc sensor mq7
sensor_volt4 = sensorValue4/1024*5.0; //untuk menjadi tegangan
RS_gas4 = (5.0-sensor_volt4)/sensor_volt4; //untuk rumus
ratio4 = RS_gas4/R04; //Replace R0 with the value found using the calibration code
kal4 = 83.39 / ratio4; //untuk rumus
ppm4 = pow(kal4 , 0.63); //untuk jadi ppm
delay(100); //delay
}
3. VIDEO HASILNYA
No comments:
Post a Comment