diff --git a/microcontroller/sketch_apr22a/sketch_apr22a.ino b/microcontroller/sketch_apr22a/sketch_apr22a.ino index 8236efa..e391792 100644 --- a/microcontroller/sketch_apr22a/sketch_apr22a.ino +++ b/microcontroller/sketch_apr22a/sketch_apr22a.ino @@ -15,7 +15,7 @@ #define BOARD "ESP-32" #define MQPIN 34 -#define DHTPIN 4 +#define DHTPIN 2 #define LAMPPIN 26 #define FANPIN 25 #define BUZZERPIN 23 @@ -356,10 +356,14 @@ float getKadarGas() { // konversi tegangan ke persen berdasarkan rumus yang telah ditentukan float getPersentaseKadarGas(float voltase) { - float m = 6.0 / (1.49 / 0.33); - float b = -m * 0.33; - float persentase = m * voltase + b; + // float m = 6.0 / (1.49 / 0.33); + // float b = -m * 0.33; + // float persentase = m * voltase + b; + // float hasil = constrain(persentase * 100, 0, 100); + + float persentase = 0.0526 * voltase - 0.0174; float hasil = constrain(persentase * 100, 0, 100); + // float persentase = 0.2043 * pow(voltase, 2.0) + 0.0611 * voltase - 0.0249; // float hasil = constrain(persentase * 100, 0, 100); @@ -518,7 +522,7 @@ void cekKegagalan() { regresiKadarGas = regresiKadarGas * 100; float nilaiPertiga = regresiKadarGas / 3.0; - if (lamaJam > 12) { + if (lamaJam > 6) { // jika kadar gas tidak naik secara signifikan // if (persentaseKadarGas > (regresiKadarGas + nilaiPertiga) || persentaseKadarGas < (regresiKadarGas - nilaiPertiga)) { if (persentaseKadarGas < (regresiKadarGas - nilaiPertiga)) { diff --git a/microdebugging/microdebugging.ino b/microdebugging/microdebugging.ino index 67bc193..6b8a957 100644 --- a/microdebugging/microdebugging.ino +++ b/microdebugging/microdebugging.ino @@ -15,7 +15,7 @@ #define BOARD "ESP-32" #define MQPIN 34 -#define DHTPIN 4 +#define DHTPIN 2 #define LAMPPIN 26 #define FANPIN 25 #define BUZZERPIN 23