#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <LiquidCrystal_I2C.h>
#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <DallasTemperature.h>
#define LCD_I2C_ADDR 0x3C
Adafruit_SSD1306 display(LCD_I2C_ADDR);
DallasTemperature tempSensor(0x90);
LiquidCrystal_I2C lcd(LCD_I2C_ADDR, 20, 4);
#define BLYNK_TEMPLATE_ID "TMPL64WGH6p5Q"
#define BLYNK_TEMPLATE_NAME "FYP"
#define BLYNK_AUTH_TOKEN "XrqafTZ6ckaEcPBEABmonsXZz3MWgc8V"
const int buttonPin = 14;
int buttonState = 0;
const int redLED = 12;
const int blueLED = 13;
const int greenLED = 15;
char auth[] = "XrqafTZ6ckaEcPBEABmonsXZz3MWgc8V";
void setup() {
Serial.begin(115200);
Blynk.begin(auth, "it's MEHH!!", "00365511");
display.begin(SSD1306_SWITCHCAPVCC, 128, 64);
lcd.init();
lcd.backlight();
tempSensor.begin();
pinMode(buttonPin, INPUT_PULLUP);
pinMode(redLED, OUTPUT);
pinMode(blueLED, OUTPUT);
pinMode(greenLED, OUTPUT);
}
void loop() {
Blynk.run();
float temperature = tempSensor.readCelsius();
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(temperature);
lcd.print(" *C");
// Your temperature control logic here...
buttonState = digitalRead(buttonPin);
if (buttonState == LOW) {
Blynk.virtualWrite(V1, "ON");
} else {
Blynk.virtualWrite(V1, "OFF");
}
// Consider using BlynkTimer for scheduling tasks without delay
delay(1000);
}
// BLYNK_WRITE(V2) { // Blynk button widget on V2
// // Handle Blynk button press event
// int relayState = param.asInt();
// if (relayState == HIGH) {
// // Perform action when the button is pressed
// } else {
// // Perform action when the button is released
// }
// }