change dht pin to 2

This commit is contained in:
Muhammad Izza Alfiansyah 2024-06-07 12:51:05 +07:00
parent 7d04e9e8c1
commit 3239790d2a
2 changed files with 10 additions and 6 deletions

View File

@ -15,7 +15,7 @@
#define BOARD "ESP-32" #define BOARD "ESP-32"
#define MQPIN 34 #define MQPIN 34
#define DHTPIN 4 #define DHTPIN 2
#define LAMPPIN 26 #define LAMPPIN 26
#define FANPIN 25 #define FANPIN 25
#define BUZZERPIN 23 #define BUZZERPIN 23
@ -356,10 +356,14 @@ float getKadarGas() {
// konversi tegangan ke persen berdasarkan rumus yang telah ditentukan // konversi tegangan ke persen berdasarkan rumus yang telah ditentukan
float getPersentaseKadarGas(float voltase) { float getPersentaseKadarGas(float voltase) {
float m = 6.0 / (1.49 / 0.33); // float m = 6.0 / (1.49 / 0.33);
float b = -m * 0.33; // float b = -m * 0.33;
float persentase = m * voltase + b; // 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 hasil = constrain(persentase * 100, 0, 100);
// float persentase = 0.2043 * pow(voltase, 2.0) + 0.0611 * voltase - 0.0249; // float persentase = 0.2043 * pow(voltase, 2.0) + 0.0611 * voltase - 0.0249;
// float hasil = constrain(persentase * 100, 0, 100); // float hasil = constrain(persentase * 100, 0, 100);
@ -518,7 +522,7 @@ void cekKegagalan() {
regresiKadarGas = regresiKadarGas * 100; regresiKadarGas = regresiKadarGas * 100;
float nilaiPertiga = regresiKadarGas / 3.0; float nilaiPertiga = regresiKadarGas / 3.0;
if (lamaJam > 12) { if (lamaJam > 6) {
// jika kadar gas tidak naik secara signifikan // jika kadar gas tidak naik secara signifikan
// if (persentaseKadarGas > (regresiKadarGas + nilaiPertiga) || persentaseKadarGas < (regresiKadarGas - nilaiPertiga)) { // if (persentaseKadarGas > (regresiKadarGas + nilaiPertiga) || persentaseKadarGas < (regresiKadarGas - nilaiPertiga)) {
if (persentaseKadarGas < (regresiKadarGas - nilaiPertiga)) { if (persentaseKadarGas < (regresiKadarGas - nilaiPertiga)) {

View File

@ -15,7 +15,7 @@
#define BOARD "ESP-32" #define BOARD "ESP-32"
#define MQPIN 34 #define MQPIN 34
#define DHTPIN 4 #define DHTPIN 2
#define LAMPPIN 26 #define LAMPPIN 26
#define FANPIN 25 #define FANPIN 25
#define BUZZERPIN 23 #define BUZZERPIN 23