#include <OneWire.
h>
#include <DallasTemperature.h>
// Data wire is connected to the Arduino digital pin 4
#define ONE_WIRE_BUS PD4
float target_temp_high = 70.0; // Temperatura alvo inicial
float target_temp_stable = 40.0; // Temperatura alvo para estabilização
float sensor_temp = 0.0;
bool heating_phase = true; // Estado do sistema: true para aquecimento inicial,
false para estabilização
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);
void setup(void)
{
// Start serial communication for debugging purposes
[Link](9600);
// Start up the library
[Link]();
pinMode(13, OUTPUT);
}
void loop(void){
// Request temperatures from the sensor
[Link]();
// Read the temperature
sensor_temp = [Link](0);
[Link]("Current Celsius temperature: ");
[Link](sensor_temp);
// Fase de aquecimento até 70 graus
if (heating_phase) {
if (sensor_temp < target_temp_high) {
digitalWrite(13, LOW); // Liga o aquecimento (LOW para normalmente fechado)
} else {
heating_phase = false; // Transição para a fase de estabilização
digitalWrite(13, HIGH); // Desliga o aquecimento ao atingir 70 graus
}
}
// Fase de estabilização em 40 graus
else {
if (sensor_temp < target_temp_stable) {
digitalWrite(13, LOW); // Liga o aquecimento se estiver abaixo de 40 (LOW
para normalmente fechado)
} else {
digitalWrite(13, HIGH); // Desliga o aquecimento se estiver acima de 40
}
}
delay(1000); // Intervalo entre leituras
}