AC SMART — ESP32 simulation

An interactive ESP32 circuit simulation you can run free in your browser on Velxio, by piyushtamdeokawale2004.

Components

Sketch code

#define BLYNK_PRINT Serial

// =====================================================
// BLYNK CONFIGURATION
// =====================================================
#define BLYNK_TEMPLATE_ID "TMPL3JSUvDwWAA"
#define BLYNK_TEMPLATE_NAME "IOT Smart AC"
#define BLYNK_AUTH_TOKEN "GW83gk6cfx0KJuUW9Ld4cngy9UNAi7C6"

#include <WiFi.h>
#include <BlynkSimpleEsp32.h>
#include <DHT.h>
#include <LiquidCrystal.h>

// =====================================================
// WIFI
// =====================================================
char ssid[] = "Piyush_Wifi";
char pass[] = "12345678";

// =====================================================
// DHT11
// =====================================================
#define DHTPIN 4
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

// =====================================================
// PIR + MQ135
// =====================================================
#define PIR_PIN 34
#define GAS_PIN 35

// =====================================================
// LEDs
// =====================================================
#define GREEN_LED 18
#define RED_LED   19

// =====================================================
// L293D MOTOR DRIVER
// =====================================================
#define FAN_EN  32
#define FAN_IN1 16
#define FAN_IN2 17

// =====================================================
// LCD 16x2
// =====================================================
#define LCD_RS 13
#define LCD_EN 14
#define LCD_D4 27
#define LCD_D5 26
#define LCD_D6 25
#define LCD_D7 33

LiquidCrystal lcd(
  LCD_RS,
  LCD_EN,
  LCD_D4,
  LCD_D5,
  LCD_D6,
  LCD_D7
);

// =====================================================
// TEMPERATURE / HUMIDITY LIMITS
// =====================================================
#define TEMP_LIMIT 26.0
#define HUMIDITY_LIMIT 88.0

// =====================================================
// MQ135 GAS SETTINGS
// =====================================================

// Higher value = less sensitive
// Lower value = more sensitive
#define GAS_DANGER_DELTA 40

int gasBaseline = 0;
int gasDangerLevel = 0;

// =====================================================
// SENSOR VARIABLES
// =====================================================
float temperature = 0;
float humidity = 0;

int gasRaw = 0;
int gasValue = 100;

int person = LOW;

bool highTemperature = false;
bool highHumidity = false;
bool badAir = false;

bool acRequired = false;

// =====================================================
// LCD + DHT TIMING
// =====================================================
bool lcdPage = false;
unsigned long lastLCDChange = 0;
unsigned long lastDHTRead = 0;

// =====================================================
// BLYNK TIMER
// =====================================================
BlynkTimer timer;


// =====================================================
// FAN ON
// =====================================================
void fanON()
{
  digitalWrite(FAN_EN, HIGH);
  digitalWrite(FAN_IN1, HIGH