# ESP32-C3 Example
_ContextGraph::ai · saved 2026-06-27T19:38:22Z_

> **What this file is.** A ContextGraph::ai export of an enterprise-architecture map titled “ESP32-C3 Example”. It describes a component map — a hierarchy of component groups → components → functions (stored as domains → components → functions), plus the dependencies drawn between any of those nodes. This map uses **Component-driven** vocabulary: in the embedded state each `domain` is a **component group** and each `component` is a **component** — the JSON keys are kept unchanged for tooling compatibility, so treat them as groups and components. A human-readable summary follows below; the complete machine-readable state is embedded at the end inside a `<!-- DEPMAP:STATE … -->` HTML comment (ContextGraph::ai reads it to re-open the file — you can ignore it for analysis). Any **“AI Context”** notes are authoritative descriptions of intent written by the author — treat them as binding when reasoning about this system.

## AI Context

> ESP32-C3 + WS2812B rainbow — PlatformIO build context (BINDING).
> 
> GOAL: Scroll a smooth rainbow along a 16-LED WS2812B strip driven by an ESP32-C3.
> 
> VOCABULARY: This is a COMPONENT-DRIVEN map. Read each `domain` as a component group and each `component` as a component (the JSON keys are unchanged for tooling).
> 
> HARDWARE / WIRING:
> - Board: ESP32-C3-DevKitM-1 (RISC-V). Native USB-Serial/JTAG on GPIO18/19.
> - WS2812B DIN  <- ESP32-C3 GPIO8 through a ~330 ohm series resistor (GPIO8 is a strapping pin; let it float at boot).
> - WS2812B 5V   <- 5V (VBUS) for a few LEDs; use an EXTERNAL 5V supply for the full strip.
> - WS2812B GND  <- common GND with the ESP32-C3 (required).
> - Add a 1000uF electrolytic cap across the strip's 5V/GND.
> - Do NOT use GPIO11-GPIO17 (internal SPI flash).
> 
> PROJECT LAYOUT (PlatformIO):
>   platformio.ini
>   src/main.cpp
> 
> platformio.ini:
>   [env:esp32-c3-devkitm-1]
>   platform = espressif32
>   board = esp32-c3-devkitm-1
>   framework = arduino
>   monitor_speed = 115200
>   build_flags = -D ARDUINO_USB_MODE=1 -D ARDUINO_USB_CDC_ON_BOOT=1
>   lib_deps = fastled/FastLED@^3.7.0
> 
> FIRMWARE (src/main.cpp) — outline:
>   #include <FastLED.h>
>   #define DATA_PIN 8
>   #define NUM_LEDS 16
>   CRGB leds[NUM_LEDS];
>   uint8_t hueOffset = 0;
>   void setup(){ FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS); FastLED.setBrightness(64); }
>   void loop(){
>     fill_rainbow(leds, NUM_LEDS, hueOffset, 256 / NUM_LEDS); // spread hue wheel across the strip
>     FastLED.show();
>     hueOffset++;            // scroll the rainbow
>     delay(20);              // ~50 fps
>   }
> 
> BUILD & RUN:
>   pio run                 # compile
>   pio run -t upload       # flash over USB
>   pio device monitor      # serial console @115200
> 
> NOTES FOR THE AI BUILDING THIS:
> - Keep DATA_PIN=8 unless the user rewires; update both the wiring and the define together.
> - Every ESP32-C3 pin is listed as a function on the MCU component with its role/caveat — honor the DO-NOT-USE flash pins and strapping-pin notes.
> - fill_rainbow + an incrementing hueOffset is the whole effect; tune delay() for speed and setBrightness() for current.

## Microcontroller 📝
- **ESP32-C3** 📝
  - GPIO0 📝
  - GPIO1 📝
  - GPIO2 📝
  - GPIO3 📝
  - GPIO4 📝
  - GPIO5 📝
  - GPIO6 📝
  - GPIO7 📝
  - GPIO8 📝
  - GPIO9 📝
  - GPIO10 📝
  - GPIO11 📝
  - GPIO12 📝
  - GPIO13 📝
  - GPIO14 📝
  - GPIO15 📝
  - GPIO16 📝
  - GPIO17 📝
  - GPIO18 📝
  - GPIO19 📝
  - GPIO20 📝
  - GPIO21 📝
  - 5V (VBUS) 📝
  - 3V3 📝
  - GND 📝
  - EN / RST 📝

## LEDs 📝
- **WS2812B Strip** 📝
  - DIN (data in) 📝
  - DOUT (data out) 📝
  - VCC (+5V) 📝
  - GND 📝
  - Pixel chain (16x RGB) 📝

## Firmware 📝
- **Firmware (FastLED)** 📝
  - setup() 📝
  - loop() 📝
  - renderRainbow(hueOffset) 📝

## Dependencies
- Microcontroller › ESP32-C3 › GPIO8 → LEDs › WS2812B Strip › DIN (data in) (solid) — *800kHz data* 📝
- Microcontroller › ESP32-C3 › 5V (VBUS) → LEDs › WS2812B Strip › VCC (+5V) (dashed) — *5V power* 📝
- Microcontroller › ESP32-C3 › GND → LEDs › WS2812B Strip › GND (dashed) — *GND* 📝
- Firmware › Firmware (FastLED) → Microcontroller › ESP32-C3 (solid) — *runs on / RMT GPIO8* 📝
- Firmware › Firmware (FastLED) → LEDs › WS2812B Strip (solid) — *drives pixels* 📝

<!-- DEPMAP:STATE
{
  "mode": "component",
  "domains": [
    {
      "id": "d-dp3ao0o",
      "name": "Microcontroller",
      "inv": null,
      "x": 80,
      "y": 80,
      "color": "#d97757",
      "note": "ESP32-C3 RISC-V SoC (single core, 2.4GHz Wi-Fi/BLE). The MCU object below lists every pin as a function.",
      "components": [
        {
          "id": "c-gtirzv9",
          "name": "ESP32-C3",
          "subdomain": "all",
          "type": "service",
          "icon": "service",
          "note": "Target board: esp32-c3-devkitm-1. Drives the WS2812B data line from GPIO8. All chip/board pins are enumerated as functions; honor the DO-NOT-USE flash pins.",
          "functions": [
            {
              "id": "f-71hfe86",
              "name": "GPIO0",
              "note": "ADC1_CH0, RTC, XTAL_32K_P. Usable GPIO / analog in."
            },
            {
              "id": "f-y5r215d",
              "name": "GPIO1",
              "note": "ADC1_CH1, RTC, XTAL_32K_N. Usable GPIO / analog in."
            },
            {
              "id": "f-ew1zcyq",
              "name": "GPIO2",
              "note": "ADC1_CH2, FSPIQ. STRAPPING pin (boot mode) — keep float/high at reset; usable I/O."
            },
            {
              "id": "f-esh0arl",
              "name": "GPIO3",
              "note": "ADC1_CH3. Usable GPIO / analog in."
            },
            {
              "id": "f-h9dl65o",
              "name": "GPIO4",
              "note": "ADC1_CH4, FSPIHD, MTMS(JTAG). Usable I/O."
            },
            {
              "id": "f-6mmg2ty",
              "name": "GPIO5",
              "note": "ADC2_CH0, FSPIWP, MTDI(JTAG). Usable I/O."
            },
            {
              "id": "f-7o5zinc",
              "name": "GPIO6",
              "note": "FSPICLK, MTCK(JTAG). Usable I/O."
            },
            {
              "id": "f-42ei5e6",
              "name": "GPIO7",
              "note": "FSPID, MTDO(JTAG). Usable I/O."
            },
            {
              "id": "f-ohtnanm",
              "name": "GPIO8",
              "note": "STRAPPING pin; onboard addressable RGB LED on most C3 dev boards. >> WS2812B DATA (DIN) in this project. Drive via ~330R series resistor."
            },
            {
              "id": "f-dh4ayfa",
              "name": "GPIO9",
              "note": "STRAPPING pin; BOOT button (hold low for download mode). Avoid driving externally."
            },
            {
              "id": "f-tohzek3",
              "name": "GPIO10",
              "note": "FSPICS0. Usable I/O."
            },
            {
              "id": "f-e2kph4d",
              "name": "GPIO11",
              "note": "VDD_SPI / flash power domain — usually reserved; do not use for general I/O."
            },
            {
              "id": "f-kdvpt9g",
              "name": "GPIO12",
              "note": "SPIHD — wired to internal SPI flash. DO NOT USE."
            },
            {
              "id": "f-8fzygrp",
              "name": "GPIO13",
              "note": "SPIWP — wired to internal SPI flash. DO NOT USE."
            },
            {
              "id": "f-ne8wv53",
              "name": "GPIO14",
              "note": "SPICS0 — wired to internal SPI flash. DO NOT USE."
            },
            {
              "id": "f-79ar4oo",
              "name": "GPIO15",
              "note": "SPICLK — wired to internal SPI flash. DO NOT USE."
            },
            {
              "id": "f-txgz07y",
              "name": "GPIO16",
              "note": "SPID — wired to internal SPI flash. DO NOT USE."
            },
            {
              "id": "f-hl7irat",
              "name": "GPIO17",
              "note": "SPIQ — wired to internal SPI flash. DO NOT USE."
            },
            {
              "id": "f-0gwbw6j",
              "name": "GPIO18",
              "note": "USB D- (native USB-Serial/JTAG). Avoid if using the USB port."
            },
            {
              "id": "f-wc9nayx",
              "name": "GPIO19",
              "note": "USB D+ (native USB-Serial/JTAG). Avoid if using the USB port."
            },
            {
              "id": "f-0kv17nj",
              "name": "GPIO20",
              "note": "U0RXD — UART0 RX (serial console)."
            },
            {
              "id": "f-f3f55v4",
              "name": "GPIO21",
              "note": "U0TXD — UART0 TX (serial console)."
            },
            {
              "id": "f-y88uzag",
              "name": "5V (VBUS)",
              "note": "USB 5V input rail. Powers the WS2812B strip (use an external 5V supply for many LEDs)."
            },
            {
              "id": "f-xrdycjp",
              "name": "3V3",
              "note": "Regulated 3.3V logic rail (chip + GPIO logic level)."
            },
            {
              "id": "f-nsxs7fe",
              "name": "GND",
              "note": "Ground. MUST be common with the LED strip ground."
            },
            {
              "id": "f-4l1zee0",
              "name": "EN / RST",
              "note": "Chip enable / reset (active high). Pull low to reset."
            }
          ]
        }
      ]
    },
    {
      "id": "d-cid3y3k",
      "name": "LEDs",
      "inv": null,
      "x": 760,
      "y": 80,
      "color": "#788c5d",
      "note": "Addressable RGB LED hardware driven over a single data wire.",
      "components": [
        {
          "id": "c-33uwxa3",
          "name": "WS2812B Strip",
          "subdomain": "all",
          "type": "external",
          "icon": "integration",
          "note": "16x WS2812B (NeoPixel-compatible), 5V, 800kHz, GRB. DIN from GPIO8 via 330R; common GND; 1000uF cap across 5V/GND at the strip.",
          "functions": [
            {
              "id": "f-43e42l4",
              "name": "DIN (data in)",
              "note": "Single-wire 800kHz data input. Connect to ESP32-C3 GPIO8 through a ~330R series resistor; keep the lead short."
            },
            {
              "id": "f-wfhvdy8",
              "name": "DOUT (data out)",
              "note": "Chained to the next pixel's DIN. Daisy-chain to extend the strip."
            },
            {
              "id": "f-ufuqc66",
              "name": "VCC (+5V)",
              "note": "5V power for the LEDs. ~60mA per LED at full white — size the supply (16 LEDs ≈ 1A worst case)."
            },
            {
              "id": "f-rmrqt36",
              "name": "GND",
              "note": "Common ground — tie to the ESP32-C3 GND."
            },
            {
              "id": "f-3pl6fcc",
              "name": "Pixel chain (16x RGB)",
              "note": "16 addressable WS2812B pixels; each integrates an RGB LED + driver. GRB byte order."
            }
          ]
        }
      ]
    },
    {
      "id": "d-w5b44fp",
      "name": "Firmware",
      "inv": null,
      "x": 760,
      "y": 560,
      "color": "#6a9bcc",
      "note": "PlatformIO + Arduino framework firmware. Uses FastLED to render a scrolling rainbow.",
      "components": [
        {
          "id": "c-7f25qxk",
          "name": "Firmware (FastLED)",
          "subdomain": "all",
          "type": "service",
          "icon": "service",
          "note": "Single Arduino sketch (src/main.cpp). Owns CRGB leds[NUM_LEDS]; drives the strip on GPIO8.",
          "functions": [
            {
              "id": "f-ys8rbht",
              "name": "setup()",
              "note": "Init Serial; FastLED.addLeds<WS2812B, 8, GRB>(leds, 16); FastLED.setBrightness(64)."
            },
            {
              "id": "f-f4sz63y",
              "name": "loop()",
              "note": "Each frame: renderRainbow(hueOffset) -> FastLED.show() -> hueOffset++ -> delay(~20ms)."
            },
            {
              "id": "f-05faqvu",
              "name": "renderRainbow(hueOffset)",
              "note": "Rainbow generator: fill_rainbow(leds, NUM_LEDS, hueOffset, 256/NUM_LEDS) so the hue wheel spreads across the strip and scrolls."
            }
          ]
        }
      ]
    }
  ],
  "entities": [],
  "links": [
    {
      "id": "lk-gdkfgp8",
      "source": "f-ohtnanm",
      "target": "f-43e42l4",
      "label": "800kHz data",
      "style": "solid",
      "direction": "forward",
      "flow": "post",
      "note": "The data signal: GPIO8 -> 330R -> WS2812B DIN. Strapping pin, so let it float at boot."
    },
    {
      "id": "lk-jtk40t6",
      "source": "f-y88uzag",
      "target": "f-ufuqc66",
      "label": "5V power",
      "style": "dashed",
      "direction": "forward",
      "flow": "get",
      "note": "Power rail. For >8 LEDs feed the strip from an external 5V supply and share GND with the board."
    },
    {
      "id": "lk-4ydwg8m",
      "source": "f-nsxs7fe",
      "target": "f-rmrqt36",
      "label": "GND",
      "style": "dashed",
      "direction": "both",
      "flow": "get",
      "note": "Common ground — the ESP32-C3 GND MUST tie to the WS2812B GND or the data signal has no reference."
    },
    {
      "id": "lk-4fniasy",
      "source": "c-7f25qxk",
      "target": "c-gtirzv9",
      "label": "runs on / RMT GPIO8",
      "style": "solid",
      "direction": "forward",
      "flow": "post",
      "note": "The sketch runs on the ESP32-C3 and drives the strip via the RMT peripheral on DATA_PIN=8."
    },
    {
      "id": "lk-jx0zj68",
      "source": "c-7f25qxk",
      "target": "c-33uwxa3",
      "label": "drives pixels",
      "style": "solid",
      "direction": "forward",
      "flow": "post",
      "note": "Firmware fills CRGB leds[] and latches it out with FastLED.show()."
    }
  ],
  "sequences": [],
  "annotations": [],
  "aiContext": "ESP32-C3 + WS2812B rainbow — PlatformIO build context (BINDING).\n\nGOAL: Scroll a smooth rainbow along a 16-LED WS2812B strip driven by an ESP32-C3.\n\nVOCABULARY: This is a COMPONENT-DRIVEN map. Read each `domain` as a component group and each `component` as a component (the JSON keys are unchanged for tooling).\n\nHARDWARE / WIRING:\n- Board: ESP32-C3-DevKitM-1 (RISC-V). Native USB-Serial/JTAG on GPIO18/19.\n- WS2812B DIN  <- ESP32-C3 GPIO8 through a ~330 ohm series resistor (GPIO8 is a strapping pin; let it float at boot).\n- WS2812B 5V   <- 5V (VBUS) for a few LEDs; use an EXTERNAL 5V supply for the full strip.\n- WS2812B GND  <- common GND with the ESP32-C3 (required).\n- Add a 1000uF electrolytic cap across the strip's 5V/GND.\n- Do NOT use GPIO11-GPIO17 (internal SPI flash).\n\nPROJECT LAYOUT (PlatformIO):\n  platformio.ini\n  src/main.cpp\n\nplatformio.ini:\n  [env:esp32-c3-devkitm-1]\n  platform = espressif32\n  board = esp32-c3-devkitm-1\n  framework = arduino\n  monitor_speed = 115200\n  build_flags = -D ARDUINO_USB_MODE=1 -D ARDUINO_USB_CDC_ON_BOOT=1\n  lib_deps = fastled/FastLED@^3.7.0\n\nFIRMWARE (src/main.cpp) — outline:\n  #include <FastLED.h>\n  #define DATA_PIN 8\n  #define NUM_LEDS 16\n  CRGB leds[NUM_LEDS];\n  uint8_t hueOffset = 0;\n  void setup(){ FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS); FastLED.setBrightness(64); }\n  void loop(){\n    fill_rainbow(leds, NUM_LEDS, hueOffset, 256 / NUM_LEDS); // spread hue wheel across the strip\n    FastLED.show();\n    hueOffset++;            // scroll the rainbow\n    delay(20);              // ~50 fps\n  }\n\nBUILD & RUN:\n  pio run                 # compile\n  pio run -t upload       # flash over USB\n  pio device monitor      # serial console @115200\n\nNOTES FOR THE AI BUILDING THIS:\n- Keep DATA_PIN=8 unless the user rewires; update both the wiring and the define together.\n- Every ESP32-C3 pin is listed as a function on the MCU component with its role/caveat — honor the DO-NOT-USE flash pins and strapping-pin notes.\n- fill_rainbow + an incrementing hueOffset is the whole effect; tune delay() for speed and setBrightness() for current.\n",
  "camera": {
    "x": 0,
    "y": 0,
    "zoom": 1
  }
}
-->
