//Tech Trends Shameer
//Temperature Monitor Using DS18B20 Sensor with ESP32
#define BLYNK_TEMPLATE_ID "TMPL6QhPdO-v-"
#define BLYNK_TEMPLATE_NAME "Quickstart Template"
#define BLYNK_AUTH_TOKEN "u8GnJkG0vToDPkvjFw7tQl4GyPkNtBtc"
#define BLYNK_PRINT Serial
#include <WiFi.h> // Pustaka untuk ESP32
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h> // Pustaka Blynk untuk ESP32
#include <OneWire.h>
#include <DallasTemperature.h>
#define DS18B20_PIN 12 // Connect to GPIO4 pin on ESP32
OneWire ourWire(DS18B20_PIN);
DallasTemperature sensor(&ourWire);
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST"; // Masukkan nama wifi Anda
char pass[] = ""; // Masukkan kata sandi wifi Anda
BlynkTimer timer;
void sendSensor()
{
// Request temperature to all devices on the data line
sensor.requestTemperatures();
Serial.print("Celsius temperature: ");
// We can connect more than one IC on the same data wire. 0 refers to the first IC on the wire
Serial.print(sensor.getTempCByIndex(0));
Serial.print(" - Fahrenheit temperature: ");
Serial.println(sensor.getTempFByIndex(0));
float tempC = sensor.getTempCByIndex(0);
float tempF = sensor.getTempFByIndex(0);
delay(1000);
// You can send any value at any time.
// Please don't send more than 10 values per second.
Blynk.virtualWrite(V0, tempC);
Blynk.virtualWrite(V1, tempF);
delay(500);
}
void setup()
{
Serial.begin(9600);
sensor.begin();
Blynk.begin(auth, ssid, pass);
timer.setInterval(1000L, sendSensor); // Ubah interval menjadi 1000ms (1 detik) untuk menghindari batasan per detik.
}
void loop()
{
Blynk.run();
timer.run();
}
Loading
esp32-s2-devkitm-1
esp32-s2-devkitm-1