#include <WiFi.h>
#include <ESPAsyncWebServer.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 4
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensor(&oneWire);
String temperatureC = "";
unsigned long lastTime = 0;
unsigned long timerDelay = 30000;
const char* ssid = "Wokwi-GUEST";
AsyncWebServer server(80);
String readDSTemperatureC () {
sensor.requestTemperatures();
float tempC = sensor.getTempCByIndex(0);
if(tempC == -127.00) {
Serial.println("Falha em ler o sensor DS18B20");
return "--";
} else {
Serial.print("Temperatura (oC): ");
Serial.println(tempC);
}
return String(tempC);
}
const char index_html[] PROGMEM = R"rawliteral (
<!DOCTYPE HTML<>html>
<head>
<meta name = "viewpoint" content = "width = device-width, initial-scale = 1">
<link rel = "stylesheet" href = "https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity = "sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin = "anonymous">
<style>
html {
font-family: Arial;
display: inline-block;
margin: 0px auto;
text-align: center;
h2 { font-size: 3.0rem; }
p { font-size:3.0rem; }
.units { font-size:1.2rem; }
.ds-labels {
font-size: 1.5rem;
vertical-align: middle;
padding-bottom: 15px;
}
</style>
}
)
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32-S3!");
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}