Project Startup


Worked for 3 mins
Thought for 16 sec
Managing assets.
Thought for 17 sec — Gathering documentation and schematics
Reading project docs.
Thought for 13 sec
Getting a schematic overview for ESP32.
Thought for 12 sec
Reading schematic details while tracing connections from U1.
Thought for 16 sec — Considering pin mappings
Reading schematic details for U1.
Thought for 47 sec — Creating project documentation
Updating 2 project docs.
Created 2 project docs

Firmware Starter — ESP32-S3-WROOM-1-N16R8

View Document

Firmware Starter — ESP32-S3-WROOM-1-N16R8 Platform & Toolchain
  • MCU: U1, ESP32-S3-WROOM-1-N16R8
  • Framework: Arduino-ESP32 through PlatformIO
  • Purpose: Safe board bring-up firmware. Peripheral rails default off; transmit-capable modules require explicit user action.
Pin Mapping
Low-speed power enables, isolation controls, buttons, presence inputs, and night-mode control are provided through TCA9535 expanders U23 and U32 on the system I2C bus. Their exact port roles are defined by the net names in the schematic and must remain default-off until configured.
platformio.ini Complete Starter Source — src/main.cpp Build & Flash
Set SW3 to DOWNLOAD or hold BOOT (SW2) while resetting (SW1) to enter the ROM bootloader. Return SW3 to NORMAL after ...

Board Bring-Up Plan

View Document

Board Bring-Up Plan Prerequisites
  • Bench supply with current limit, DMM, oscilloscope, USB current meter, thermal camera, USB data isolator, logic analyzer, known-good 1S protected packs, and ESD-safe workstation.
  • Use the Firmware Starter safe bring-up image.
  • Start without NFC, sub-GHz, display, removable storage, debug target, microphone, speaker, or expansion modules attached.
1. Visual and Unpowered Inspection
  • Verify orientation and soldering of U1–U38, D1–D5, Q1, F2/F3, polarized battery connectors, USB-C J1, microSD J3, and switches SW1–SW3.
  • Confirm no conductive debris beneath shielded modules or connectors.
  • Measure resistance from USB_VBUS, PACK_A_FUSED, PACK_B_FUSED, VBAT, VSYS, 3V3, 5V_BOOST, and 5V_TARGET to GND. Investigate readings below 10 ohms befo...
Can it have a keyboard
Yes. I’ll include a compact, glove-tolerant thumb QWERTY keyboard in the handheld concept, plus the existing directional controls and dedicated power/back keys. It will connect through the I/O expander as a scanned key matrix so it uses few ESP32 pins and can wake the device from sleep.
The concept image is saved, and I created the Firmware Starter and Board Bring-Up Plan.
Before placement, confirm this layout plan:
  • Main PCB: retain 160 × 100 mm, four layers, standard through-vias.
  • Keyboard: separate front-panel thumb-QWERTY matrix PCB connected through the I/O expander; directional, power, and back controls remain dedicated.
  • Top side: MCU, power stages, radios/modules, SD, connectors, switches, and tall components.
  • Bottom side: small passives only.
  • Edges: USB-C and SD accessible at the front; debug/expansion ports along one side; batteries and emergency-isolation interfaces opposite; antennas separated along the rear edge.
  • RF: dedicated NFC, sub-GHz, and ESP32 antenna keepouts.
  • Manufacturing: standard 1 oz copper, no HDI or microvias; compatible with mainstream prototype fabs.
Reply confirmed to start placement and routing, or specify a different board size or keyboard arrangement.

Waiting for input


Firmware Starter — ESP32-S3-WROOM-1-N16R8
Platform & Toolchain
  • MCU: U1, ESP32-S3-WROOM-1-N16R8
  • Framework: Arduino-ESP32 through PlatformIO
  • Purpose: Safe board bring-up firmware. Peripheral rails default off; transmit-capable modules require explicit user action.
Pin Mapping

Table


FunctionGPIOSchematic netDirection
I2S amplifier data7I2S_AMP_DINOut
I2C SDA8I2C_SDABidirectional
SPI clock12SPI_CLKOut
SPI MISO13SPI_MISOIn
NFC chip select15SPI_CS_NFCOut
Storage chip select21SPI_CS_STORAGEOut
Display D/C47DISPLAY_DCOut
Charger interrupt39CHG_INT_NIn, pull-up
Fuel-gauge alert40FUEL_ALERT_NIn, pull-up
Target-power fault41TARGET_PWR_FAULT_NIn, pull-up
USB-C controller interrupt42USB_CC_INT_NIn, pull-up
Temperature alert38TEMP_ALERTIn, pull-up
Boot select0MCU_BOOTBoot strap
Native USB D- / D+19 / 20USB_D_N / USB_D_PUSB
UART0 RX / TXRXD0 / TXD0UART_RX / UART_TXBidirectional
Low-speed power enables, isolation controls, buttons, presence inputs, and night-mode control are provided through TCA9535 expanders U23 and U32 on the system I2C bus. Their exact port roles are defined by the net names in the schematic and must remain default-off until configured.
platformio.ini

Ini


[env:esp32-s3-toolkit]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
monitor_speed = 115200
board_build.flash_size = 16MB
board_build.arduino.memory_type = qio_opi
build_flags =
  -DARDUINO_USB_MODE=1
  -DARDUINO_USB_CDC_ON_BOOT=1
lib_deps =
  adafruit/Adafruit TCA9534@^1.0.7
  adafruit/Adafruit MAX1704X@^1.0.3
Complete Starter Source — src/main.cpp

Cpp


#include <Arduino.h>
#include <Wire.h>
#include <SPI.h>
#include <WiFi.h>
#include <Adafruit_MAX1704X.h>

constexpr int PIN_I2C_SDA = 8;
constexpr int PIN_I2C_SCL = 9;       // U1 IO9, system I2C clock
constexpr int PIN_SPI_SCK = 12;
constexpr int PIN_SPI_MISO = 13;
constexpr int PIN_SPI_MOSI = 11;     // U1 IO11, SPI_MOSI
constexpr int PIN_CS_NFC = 15;
constexpr int PIN_CS_STORAGE = 21;
constexpr int PIN_DISPLAY_DC = 47;
constexpr int PIN_CHG_INT_N = 39;
constexpr int PIN_FUEL_ALERT_N = 40;
constexpr int PIN_TARGET_FAULT_N = 41;
constexpr int PIN_USB_CC_INT_N = 42;
constexpr int PIN_TEMP_ALERT = 38;
constexpr int PIN_I2S_AMP_DIN = 7;

constexpr uint8_t IOX_MAIN_ADDR = 0x20; // U23: A0/A1/A2 tied low
constexpr uint8_t IOX_SUB_ADDR  = 0x21; // Confirm U32 A0 state during bring-up
constexpr uint8_t REG_INPUT0 = 0x00;
constexpr uint8_t REG_OUTPUT0 = 0x02;
constexpr uint8_t REG_CONFIG0 = 0x06;

Adafruit_MAX17048 fuel;
uint32_t lastReport = 0;

bool i2cWrite8(uint8_t addr, uint8_t reg, uint8_t value) {
  Wire.beginTransmission(addr);
  Wire.write(reg);
  Wire.write(value);
  return Wire.endTransmission() == 0;
}

bool i2cRead16(uint8_t addr, uint8_t reg, uint16_t &value) {
  Wire.beginTransmission(addr);
  Wire.write(reg);
  if (Wire.endTransmission(false) != 0) return false;
  if (Wire.requestFrom((int)addr, 2) != 2) return false;
  value = Wire.read() | (uint16_t(Wire.read()) << 8);
  return true;
}

void configureExpandersSafe() {
  // Configure both TCA9535 devices as inputs first. This preserves hardware
  // pull-down/default-off states on rail enables and isolation controls.
  for (uint8_t addr : {IOX_MAIN_ADDR, IOX_SUB_ADDR}) {
    i2cWrite8(addr, REG_CONFIG0, 0xFF);
    i2cWrite8(addr, REG_CONFIG0 + 1, 0xFF);
  }
}

void scanI2C() {
  Serial.println("I2C scan:");
  for (uint8_t a = 1; a < 0x7F; ++a) {
    Wire.beginTransmission(a);
    if (Wire.endTransmission() == 0) Serial.printf("  0x%02X\n", a);
  }
}

void initWiFiSafe() {
  WiFi.mode(WIFI_STA);
  WiFi.disconnect(true, true);
  // No automatic association or continuous transmission in bring-up firmware.
}

void setup() {
  Serial.begin(115200);
  delay(500);
  Serial.println("Rugged toolkit safe bring-up starting");

  pinMode(PIN_CS_NFC, OUTPUT);
  pinMode(PIN_CS_STORAGE, OUTPUT);
  pinMode(PIN_DISPLAY_DC, OUTPUT);
  digitalWrite(PIN_CS_NFC, HIGH);
  digitalWrite(PIN_CS_STORAGE, HIGH);
  digitalWrite(PIN_DISPLAY_DC, LOW);

  for (int pin : {PIN_CHG_INT_N, PIN_FUEL_ALERT_N, PIN_TARGET_FAULT_N,
                  PIN_USB_CC_INT_N, PIN_TEMP_ALERT}) pinMode(pin, INPUT_PULLUP);

  Wire.begin(PIN_I2C_SDA, PIN_I2C_SCL, 400000);
  SPI.begin(PIN_SPI_SCK, PIN_SPI_MISO, PIN_SPI_MOSI);
  configureExpandersSafe();
  scanI2C();

  if (!fuel.begin(&Wire)) Serial.println("MAX17048 not detected");
  else Serial.println("MAX17048 ready");

  initWiFiSafe();
  Serial.println("Initialization complete; switched peripheral rails remain off");
}

void loop() {
  const uint32_t now = millis();
  if (now - lastReport >= 1000) {
    lastReport = now;
    Serial.printf("IRQ chg=%d fuel=%d target_fault=%d usbcc=%d temp=%d",
      digitalRead(PIN_CHG_INT_N), digitalRead(PIN_FUEL_ALERT_N),
      digitalRead(PIN_TARGET_FAULT_N), digitalRead(PIN_USB_CC_INT_N),
      digitalRead(PIN_TEMP_ALERT));
    if (fuel.cellVoltage() > 0.0f)
      Serial.printf(" battery=%.3fV soc=%.1f%%", fuel.cellVoltage(), fuel.cellPercent());
    Serial.println();
  }
  delay(10);
}
Build & Flash

Bash


pio run
pio run -t upload
pio device monitor
Set SW3 to DOWNLOAD or hold BOOT (SW2) while resetting (SW1) to enter the ROM bootloader. Return SW3 to NORMAL after flashing.
Safety and Completion Notes
  • Confirm U32's final I2C address from its A0 strap before enabling outputs.
  • Do not enable sub-GHz, NFC, target power, storage, display, microphone, audio, or IR rails until each expander output polarity has been verified with a meter.
  • Radio transmit functions must require explicit user action, regional configuration, and time-limited operation.
  • Platform & Toolchain

  • Pin Mapping

  • `platformio.ini`

  • Complete Starter Source — `src/main.cpp`

  • Build & Flash

  • Safety and Completion Notes