Capstone Simulation — Xiao Esp32S3 Sense simulation

Capstone 1

An interactive Xiao Esp32S3 Sense circuit simulation you can run free in your browser on Velxio, by lusyyy-am.

Components

Sketch code

#include <WiFi.h>
#include <WebServer.h>

// ========================================
// HERMES I - ESP32-S3 SENSE
// ========================================

const char* SSID = "Hermes";
const char* PASSWORD = "";

#define SPEAKER_PIN 2

WebServer server(80);

unsigned long lastReconnect = 0;
unsigned long requests = 0;

bool cameraReady = false;
bool microphoneReady = false;
bool speakerTested = false;

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

void connectWiFi() {
    WiFi.mode(WIFI_STA);
    WiFi.begin(SSID, PASSWORD);

    Serial.print("Connecting to WiFi");

    unsigned long start = millis();

    while (WiFi.status() != WL_CONNECTED &&
           millis() - start < 15000) {

        delay(500);
        Serial.print(".");
    }

    Serial.println();

    if (WiFi.status() == WL_CONNECTED) {
        Serial.println("WiFi connected");
        Serial.print("IP address: ");
        Serial.println(WiFi.localIP());
    } else {
        Serial.println("WiFi unavailable");
    }
}

// ========================================
// SPEAKER STARTUP TEST
// ========================================

void testSpeaker() {
    tone(SPEAKER_PIN, 800, 150);
    delay(200);
    noTone(SPEAKER_PIN);

    speakerTested = true;
}

// ========================================
// HTTP STATUS ENDPOINT
// ========================================

void handleStatus() {

    requests++;

    String json = "{";

    json += "\"device\":\"Hermes ESP32-S3\",";
    json += "\"mode\":\"simulation\",";
    json += "\"connected\":true,";

    json += "\"uptime_seconds\":";
    json += String(millis() / 1000);
    json += ",";

    json += "\"rssi\":";
    json += String(WiFi.RSSI());
    json += ",";

    json += "\"camera_ready\":";
    json += cameraReady ? "true" : "false";
    json += ",";

    json += "\"microphone_ready\":";
    json += microphoneReady ? "true" : "false";
    json += ",";

    json += "\"speaker_tested\":";
    json += speakerTested ? "true" : "false";
    json += ",";

    json += "\"requests\":";
    json += String(requests);

    json += "}";

    server.send(200, "application/json", json);
}

// ========================================
// HOME PAGE
// ========================================

void handleRoot() {

    String page = "<html><body>";
    page += "<h1>HERMES I</h1>";
    page += "<h2>Multimedia Subsystem</h2>";
    page += "<p>ESP32-S3 Sense</p>";
    page += "<p>Camera integration pending</p>";
    page += "<p>Microphone integration pending</p>";
    page += "<a href='/status'>System Status</a>";
    page += "</body></html>";

    server.send(200, "text/html", page);
}

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

void setup() {

    Serial.begin(115200);

    pinMode(SPEAKER_PIN, OUTPUT);

    Serial.println("HERMES I - ESP32-S3");

    testSpeaker();
    connectWiFi();

    server.on("/", HTTP_GET, handleRoot);
    server.on("/s

More projects by lusyyy-am