1 — Esp32 Devkit C V4 simulation

An interactive Esp32 Devkit C V4 circuit simulation you can run free in your browser on Velxio, by zhao.

Components

Sketch code

/*
 * ============================================================================
 *   Adaptive Health Lighting System v1.0 - ESP32 Edition
 * ============================================================================
 *
 * Hardware (Plan B: DevKitC + 2x19 pin-header socket):
 *   - ESP32 DevKitC development board (WROOM-32, WiFi + BT)
 *     inserted into J1 2x19 female header on PCB
 *   - VEML7700 ambient light sensor (I2C 0x10, +/-5%)
 *   - SHT30 temperature/humidity sensor (I2C 0x44)
 *   - PIR motion sensor (GPIO27)
 *   - 2x AO3400 MOSFET (dual-channel LED driver, SOT-23)
 *   - Warm white LED strip 2700K (GPIO25 HW / GPIO27 SIM, LEDC ch0)
 *   - Cool white LED strip 6500K (GPIO26, LEDC ch1)
 *   - PCB Type-C: power-only (no data)
 *   - Program download: via DevKitC onboard USB (CP2102)
 *
 * Simulation Mode (Velxio):
 *   Uncomment #define SIMULATION_MODE below to use:
 *   - Potentiometer on GPIO34 (ADC1_CH6) -> simulated light 0-500 lux
 *   - Potentiometer on GPIO35 (ADC1_CH7) -> simulated temperature 0-50 C
 *   - Push button on GPIO14 (INPUT_PULLUP) -> simulated PIR
 *   - Yellow LED + 68-100R on GPIO27 -> warm white (GPIO25=DAC1 stuck HIGH in Velxio)
 *   - White LED + 68-100R on GPIO26 -> cool white
 *   - Black button on GPIO0 (BOOT) -> mode switch
 *   LED output: SOFTWARE PWM via digitalWrite, 50Hz / 32-step + 100uF cap (Velxio's
 *   QEMU hangs on ledcWrite in the main-firmware context; digitalWrite verified OK.
 *   Frequency evolution: 25Hz flickered, 1kHz lost duty info, 100-120Hz had beat-
 *   frequency aliasing. 50Hz + 100uF smoothing capacitor (Drain->GND) = no flicker
 *   + SPICE resolves duty. Gamma correction SKIPPED in sim (2.2 crushes low duty).)
 *   WiFi/MQTT/NTP/OTA/WebServer/NVS are skipped in simulation (compile-isolated)
 *
 * Libraries required:
 *   Adafruit_VEML7700, Adafruit_SHT31, ArduinoJson, PubSubClient
 *
 * Author: HealthLight Project
 * Date: 2026-08-13
 * ============================================================================
 */

// ============================================================================
// SECTION 0: SIMULATION TOGGLE
// ============================================================================
// ★ DEFAULT ON: simulation mode for Velxio / Wokwi (uses potentiometers +
//   push buttons instead of real VEML7700 / SHT30 / PIR sensors).
//   Velxio does NOT have the Adafruit_VEML7700 / Adafruit_SHT31 libraries,
//   so leaving this ON is REQUIRED for the online simulator to compile.
//   >>> For REAL HARDWARE (breadboard / PCB with actual sensors), COMMENT
//       THIS LINE BACK OUT so the I2C sensor drivers get compiled. <<<
#define SIMULATION_MODE

// ============================================================================
// SECTION 1: PIN DEFINITIONS (ESP32 DevKit V1 silkscreen labels)
// ============================================================================
// Layout strategy: LEFT side = inputs/sensors/PWM outputs; RIGHT side = I2C/status.
// See ES

More projects by zhao