smartclassroom — ESP32 simulation

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

Components

Sketch code

#include <WiFi.h>
#include <HTTPClient.h>
#include <NetworkClient.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

// =====================================================
// WIFI
// =====================================================

const char* WIFI_SSID = "Velxio-GUEST";

// =====================================================
// LOCAL PYTHON PROXY URL (Points to her laptop's Wi-Fi IP)
// =====================================================

const char* GOOGLE_SCRIPT_URL = "http://10.188.126.80:5000";

// =====================================================
// ESP32 PINS
// =====================================================

#define LED_PIN 15
#define FAN_PIN 26

#define OLED_SDA 21
#define OLED_SCL 22

// =====================================================
// OLED
// =====================================================

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

Adafruit_SSD1306 display(
  SCREEN_WIDTH,
  SCREEN_HEIGHT,
  &Wire,
  -1
);

// =====================================================
// CLASSROOM DATA
// =====================================================

int readingNumber = 0;

float temperature = 26.0;
float humidity = 55.0;

int lightValue = 300;

String motion = "NO";
String student = "YES";

String ledState = "OFF";
String fanState = "OFF";

// =====================================================
// READING TIMER
// =====================================================

unsigned long lastReadingTime = 0;

const unsigned long readingInterval = 5000;


// =====================================================
// SETUP
// =====================================================

void setup() {

  Serial.begin(115200);

  delay(1000);

  Serial.println();
  Serial.println("======================================");
  Serial.println("       SMART CLASSROOM SYSTEM");
  Serial.println("       LOCAL PROXY BRIDGE");
  Serial.println("======================================");

  // ---------------------------------------------------
  // OUTPUT PINS
  // ---------------------------------------------------

  pinMode(LED_PIN, OUTPUT);
  pinMode(FAN_PIN, OUTPUT);

  digitalWrite(LED_PIN, LOW);
  digitalWrite(FAN_PIN, LOW);

  // ---------------------------------------------------
  // OLED
  // ---------------------------------------------------

  Wire.begin(OLED_SDA, OLED_SCL);

  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {

    Serial.println("OLED FAILED!");

  } else {

    Serial.println("OLED OK");

    display.clearDisplay();

    display.setTextColor(SSD1306_WHITE);
    display.setTextSize(1);

    display.setCursor(0, 0);

    display.println("SMART CLASSROOM");
    display.println();
    display.println("Starting...");

    display.display();
  }

  // ---------------------------------------------------
  // WIFI
  // ---------------------------------------------------

  WiFi.mode(WIFI_STA);

  WiFi.begin(WIFI_SSID);

  Serial.println();
  Serial.print("Connecting WiFi");