Target Hardware: Seeed Studio XIAO ESP32-S3 Role: Audio Playback, Light Sync, and Network Telemetry Node Total Units: 16
This layout segregates the SPI Storage bus (Right Side) from the I2S/Action bus (Left Side) to minimize interference and simplify wiring.
| Component | Function | XIAO Pin | ESP32 GPIO | Direction | Connection / Notes |
|---|---|---|---|---|---|
| Audio Amp | I2S Bit Clock (BCLK) | D0 | 1 | Output | To MAX98357A BCLK |
| Audio Amp | I2S Word Select (LRC) | D1 | 2 | Output | To MAX98357A LRC |
| Audio Amp | I2S Data (DIN) | D2 | 3 | Output | To MAX98357A DIN |
| NeoPixel | LED Data | D3 | 4 | Output | To WS2812B DIN (via 470Ω Resistor) |
| Battery | Voltage Sense | D4 | 5 | Input (ADC) | Center of Voltage Divider (100kΩ / 100kΩ) |
| Button | Rescue / Config | D5 | 6 | Input | Tactile Button to GND (Internal Pullup) |
| Status LED | Diagnostic Light | D6 | 43 | Output | Red LED via 220Ω Resistor to GND |
| SD Card | Chip Select (CS) | D7 | 44 | Output | To SD Module CS |
| SD Card | SPI Clock (SCK) | D8 | 7 | Output | To SD Module SCK |
| SD Card | SPI MISO | D9 | 8 | Input | To SD Module MISO |
| SD Card | SPI MOSI | D10 | 9 | Output | To SD Module MOSI |
- Battery: 3.7V LiPo connected to BAT+ / BAT- pads on the underside of the XIAO.
- Charging: Handled natively via the XIAO USB-C port.
- 5V Rail: The
5Vpin on the XIAO header acts as the main power rail for peripherals (Outputs Battery Voltage when on battery, 5V when on USB).
- VCC: Connect to XIAO
5Vpin. - GND: Connect to Common GND.
- GAIN: Leave Floating (9dB) or connect to GND via 100kΩ resistor (12dB).
- SD_MODE: Connect to VCC via 100kΩ resistor (Force ON).
- VCC: Connect to BAT+ pad (or XIAO
5Vpin). Do not power from 3V3. - GND: Common GND.
- Data: D3 (GPIO 4).
- Note: If flickering occurs on battery power, add a 1N4001 diode in series with the NeoPixel VCC to drop the voltage slightly for logic level compatibility.
- Rescue Button (D5): Must use
INPUT_PULLUPin code. Logic: LOW = Pressed. - Battery Monitor (D4):
- Circuit: Voltage Divider.
- R1: 100kΩ (Between BAT+ and D4).
- R2: 100kΩ (Between D4 and GND).
- Math:
Voltage = (AnalogRead * 3.3 / 4095) * 2.
Copy and paste this block into the config.h or main.cpp file for the Agent.
// ==========================================
// HARDWARE PIN DEFINITIONS (XIAO ESP32-S3)
// Architecture: Split-Brain (SPI Right, I2S Left)
// ==========================================
// --- STORAGE (SD Card via SPI) ---
#define SD_CS_PIN 44 // D7
#define SD_SCK_PIN 7 // D8
#define SD_MISO_PIN 8 // D9
#define SD_MOSI_PIN 9 // D10
// --- AUDIO (MAX98357A via I2S) ---
#define I2S_BCLK_PIN 1 // D0
#define I2S_LRC_PIN 2 // D1
#define I2S_DIN_PIN 3 // D2
// --- VISUALS (WS2812B) ---
#define LED_PIN 4 // D3
#define NUM_LEDS 16 // Update with actual count
// --- UTILITIES ---
#define BAT_SENSE_PIN 5 // D4 (100k/100k Divider)
#define RESCUE_BTN_PIN 6 // D5 (Active LOW)
#define STATUS_LED_PIN 43 // D6 (Active HIGH)
// --- CONFIGURATION CONSTANTS ---
#define RESCUE_HOLD_TIME_MS 3000 // Hold button 3s to enter AP Mode
#define BATTERY_CALIBRATION 2.0 // Multiplier for voltage divider