#define ADC_VREF_mV 5000.0 // in millivolt
#define ADC_RESOLUTION 4096.0
#define PIN_LM35 13 // ESP32 pin GIOP36 (ADC0) connected to LM35
int dio = 10;
int CLK = 11;
int rele = 8;
void setup() {
// Start the Serial Monitor
Serial.begin(9600);
// Start the DS18B20 sensor
pinMode(rele, OUTPUT);
//sensors.begin();
}
void loop() {
//Código LM35
int adcVal = analogRead(PIN_LM35);
// convert the ADC value to voltage in millivolt
float milliVolt = adcVal * (ADC_VREF_mV / ADC_RESOLUTION);
// convert the voltage to the temperature in °C
float tempC = milliVolt / 10;
// convert the °C to °F
float tempF = tempC * 9 / 5 + 32;
Serial.print("Temperatura em °C: ");
Serial.print(tempC);
Serial.println("°C");
//*********************
if (tempF >= 30){
digitalWrite(rele, 1);
}
else {
digitalWrite(rele, 0);
delay(5000);
}