# NoiseForge — ESP32 DevKit Pinout

**Target:** Dual-action noise suppression + energy harvesting (v0.1 hardware)

## Pin map

```
ESP32 DevKit
├── 3.3V ── Mic VDD (all INMP441)
├── GND ── Common ground for all components
├── GPIO 25 (I2S WS) ── Mic WS
├── GPIO 26 (I2S SCK) ── Mic SCK
├── GPIO 27 (I2S SD) ── Mic SD (or multiple mics on bus)
├── GPIO 32 ── Speaker/Actuator output (via transistor or amp module)
├── GPIO 33 (ADC1) ── Piezo vibration harvesting signal (rectifier diode)
├── GPIO 34 (ADC1) ── Thermoelectric voltage input
├── GPIO 2 ── Status LED (optional)
└── VIN ── USB or battery power input
```

## Signal summary

| ESP32 pin | Function | Component |
|-----------|----------|-----------|
| 3.3V | Digital mic power | INMP441 VDD (all) |
| GND | Common ground | Mics, amp, harvesters, LED |
| GPIO 25 | I2S WS (word select / LRCLK) | INMP441 WS |
| GPIO 26 | I2S SCK (bit clock / BCLK) | INMP441 SCK |
| GPIO 27 | I2S SD (serial data) | INMP441 SD (shared bus for multi-mic) |
| GPIO 32 | PWM / DAC path out | Speaker / actuator via transistor or amp |
| GPIO 33 | ADC1 | Piezo vibration (after diode rectifier) |
| GPIO 34 | ADC1 | Thermoelectric (TEG) voltage sense |
| GPIO 2 | GPIO out | Status LED (optional) |
| VIN | Power in | USB or battery |

## Notes

1. **I2S mics (INMP441)** — Keep SCK/WS short; share SD for multi-mic with L/R select or TDM later.
2. **GPIO 32 actuator** — Never drive a speaker coil directly from the pin; use a MOSFET + amp or MAX98357-class module.
3. **GPIO 33 piezo** — Full-wave bridge or Schottky rectifier + small filter cap before ADC; stay within 0–3.3 V (attenuate if needed).
4. **GPIO 34 TEG** — Input-only ADC; same voltage clamping rules; series resistor + TVS recommended.
5. **ADC1 only** — GPIO 33/34 avoid Wi‑Fi conflict issues common on ADC2 during STA mode.
6. **Common ground** — Star ground back to ESP32 GND for analog sense lines.

## Firmware map (suggested)

| Subsystem | Pins | Role |
|-----------|------|------|
| Capture | 25, 26, 27 | Reference mic for ANC / ambient |
| Actuate | 32 | Anti-noise / haptic drive |
| Harvest sense | 33, 34 | Energy telemetry for agent optimizer |
| Status | 2 | Calibrating / locked / fault |

## Firmware

Basic test loop sketch:

- Arduino: [`firmware/NoiseForge_Basic/NoiseForge_Basic.ino`](./firmware/NoiseForge_Basic/NoiseForge_Basic.ino)
- Notes: [`firmware/README.md`](./firmware/README.md)

```cpp
void loop() {
  // Read mics, calculate cancellation signal, output to speaker
  // Read ADC for harvesting voltage, log power generated
  // Send data to AthenaForge app via WiFi for agent optimization
  delay(10);
}
```


## Safety

- Low-voltage design only (3.3 V logic / USB or LiPo via proper regulator).
- Isolate mains equipment — do not connect harvesters to line voltage.
- Prototype on breadboard before permanent panel install.
