#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
#define ONE_WIRE_BUS 6 // Define the digital pin where the DS18B20 is connected
#define RELAY_PIN 7 // Define the digital pin where the relay module is connected
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
float simulatedTemperature = 48.0; // Starting temperature
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
Serial.begin(9600);
pinMode(RELAY_PIN, OUTPUT);
lcd.begin(16, 2);
}
void loop() {
// Simulate temperature increase by 1 degree every second
simulatedTemperature += 1.0;
Serial.print("Simulated Temperature: ");
Serial.print(simulatedTemperature);
Serial.println(" °C");
if (simulatedTemperature > 50.0) {
digitalWrite(RELAY_PIN, HIGH); // Activate relay if temperature exceeds 50°C
lcd.setCursor(0,0);
lcd.print("Temp. HIGH: ");
lcd.setCursor(11,0);
lcd.print(simulatedTemperature);
lcd.setCursor(0,1);
lcd.print("ALERT!!!");
} else {
digitalWrite(RELAY_PIN, LOW); // Deactivate relay if temperature is below 50°C
lcd.setCursor(0,0);
lcd.print("Temp. Low: ");
lcd.setCursor(10,0);
lcd.print(simulatedTemperature);
}
delay(1000); // Adjust the delay as needed to control how often the temperature is checked
}