#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2 // Pin untuk sensor suhu DS18B20
#define RELAY_PIN 3 // Pin untuk relay yang mengendalikan oven
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
const float setPoint = 180.0; // Suhu yang diinginkan (misalnya, 180°C)
float currentTemp;
void setup() {
pinMode(RELAY_PIN, OUTPUT);
Serial.begin(9600);
sensors.begin();
}
void loop() {
sensors.requestTemperatures();
currentTemp = sensors.getTempCByIndex(0);
Serial.print("Current Temperature: ");
Serial.println(currentTemp);
if (currentTemp < setPoint) {
digitalWrite(RELAY_PIN, HIGH); // Nyalakan oven
} else {
digitalWrite(RELAY_PIN, LOW); // Matikan oven
}
delay(1000); // Tunda 1 detik sebelum membaca ulang sensor
}