void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32-S2!");
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "DHT.h"
#define LED_PIN 2
#define DHTPIN 4
#define DHTTYPE DHT22
Adafruit_SSD1306 display(128,64,&Wire,-1);
DHT dht(DHTPIN,DHTTYPE);
String command="";
float temp;
void showMessage(String msg){
display.clearDisplay();
display.setCursor(0,0);
display.println(msg);
display.display();
}
void setup(){
Serial.begin(115200);
pinMode(LED_PIN,OUTPUT);
dht.begin();
display.begin(SSD1306_SWITCHCAPVCC,0x3C);
display.setTextColor(WHITE);
}
void loop(){
temp = dht.readTemperature();
if(Serial.available()){
command = Serial.readStringUntil('\n');
command.trim();
if(command=="ON" && temp>25){
digitalWrite(LED_PIN,HIGH);
showMessage("Cooling Mode");
}
else if(command=="ON"){
showMessage("Too Cold");
}
if(command=="OFF"){
digitalWrite(LED_PIN,LOW);
showMessage("System OFF");
}
}
delay(1000);
}