// Koding Relay-------------------------------------------------------------->
#define shd 12
#define tmp 13
int state;
//Koding HJ-SRO4T------------------------------------------------------------------->
#define PIN_TRIG 18
#define PIN_ECHO 19
#define wr 21
// Koding DHT-------------------------------------------------------------->
const float BETA = 3950;
void setup() {
// Koding Relay-------------------------------------------------------------->
Serial.begin(115200);
pinMode(shd, OUTPUT);
digitalWrite(shd, HIGH);
pinMode(tmp, OUTPUT);
digitalWrite(tmp, LOW);
pinMode(PIN_TRIG, OUTPUT);
pinMode(PIN_ECHO, INPUT);
pinMode(wr, OUTPUT);
}
void loop() {
// Koding NTC-------------------------------------------------------------->
int analogValue = analogRead(22);
float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) + 65;
Serial.print("Temperature: ");
Serial.print(celsius);
Serial.println(" ℃");
delay(1000);
// Koding Kondisi Secure--------------------------------------------------------------
if (analogValue < 50){
state = 1;
digitalWrite(tmp, LOW);
digitalWrite(shd, HIGH);
Serial.println("BOILER CONDITION : SECURE (AMAN)");
}
// Koding Kondisi High Temperatur--------------------------------------------------------------
if (analogValue > 50){
state = 2;
digitalWrite(tmp, HIGH);
digitalWrite(shd, HIGH);
Serial.println("BOILER CONDITION : HIGH TEMPERATURE (SUHU TINGGI)");
}
// Koding Kondisi High Pressure--------------------------------------------------------------
if (analogValue > 60){
state = 3;
digitalWrite(tmp, LOW);
digitalWrite(shd, LOW);
Serial.println ("BOILER CONDITION : HIGH PRESSURE (TEKANAN TINGGI)");
}
// Koding Kondisi Danger--------------------------------------------------------------
if (analogValue > 70){
state = 4;
digitalWrite(shd, LOW);
digitalWrite(tmp, HIGH);
Serial.println ("BOILER CONDITION : DANGER (BAHAYA)");
}
Serial.println("---(CONVERTING TO REAL TIME MONITORING)------");
delay(2000);
// Koding Ultrasonik--------------------------------------------------------------
digitalWrite(PIN_TRIG, HIGH);
delayMicroseconds(10);
digitalWrite(PIN_TRIG, LOW);
// Read the result:
int duration = pulseIn(PIN_ECHO, HIGH);
Serial.print("Distance in CM: ");
Serial.println(duration/58);
// Volume = 40x28x24 (26000cm), skala 1:100
// Koding Kondisi UNFILLING----------------------
if ((duration/58) >= 260){
digitalWrite(wr, LOW);
Serial.println("FEED WATER CONDITION : UNFILLING");
}
// Koding Kondisi Filling-----------------------
if ((duration/58) <= 87){
digitalWrite(wr, HIGH);
Serial.println ("FEED WATER CONDITION : FILLING");
}
Serial.println("---(CONVERTING TO REAL TIME MONITORING)------");
delay(2000);
}