#define BLYNK_PRINT Serial
#define BLYNK_TEMPLATE_ID "TMPL2niWFLYMR"
#define BLYNK_TEMPLATE_NAME "Cloud temp monitoring"
#include <OneWire.h>
#include <WiFi.h>
#include <DallasTemperature.h>
#include <BlynkSimpleEsp32.h>
#include <WiFiClient.h>
// GPIO where the DS18B20 is connected to
const int oneWireBus = 13;
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(oneWireBus);
// Pass our oneWire reference to Dallas Temperature sensor
DallasTemperature sensors(&oneWire);
#define BLYNK_PRINT Serial
//setup Auth token
char auth[] = "N8jMBCLowAgMnsaMLT98V1T896gy4ODY";
//Wifi credentials
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
BlynkTimer timer;
float Temperature;
void sendSensor()
{
Serial.print("Temperature: ");
//Request Temperature
sensors.requestTemperatures();
Serial.print(sensors.getTempCByIndex(0));
Serial.println("ºC");
//Serial.print(" - Fahrenheit temperature: ");
//Serial.println(sensors.getTempFByIndex(0));
int tempC=sensors.getTempCByIndex(0);
//int tempF=sensors.getTempFByIndex(0);
delay(1000);
Blynk.virtualWrite(0, tempC);
delay(500);
}
void setup() {
// put your setup code here, to run once:
// delay(100);
Serial.begin(9600);
sensors.begin();
//Serial.println("Hello, ESP32!");
Blynk.begin(auth,ssid,pass);
//sensors.setResolution(10);
timer.setInterval(100L,sendSensor);
}
void loop() {
// put your main code here, to run repeatedly:
Blynk.run();
timer.run();
//delay(10); // this speeds up the simulation
}