README.md
# ESP8266 Fitness Watch — tscircuit recreation
This is a 50 mm × 40 mm, two-layer tscircuit PCB based on the architecture and firmware pinout in [Neutrino-1/Fitness_Watch](https://github.com/Neutrino-1/Fitness_Watch). The reference repository is released under CC0 1.0.
## What is on the board
- JLCPCB C89297 ESP-12E / ESP8266 controller with exact footprint, model, and antenna copper keepout
- Power-only USB-C input using separate 5.1 kΩ CC1/CC2 pull-downs
- TP4056 single-cell LiPo charger set to approximately 120 mA
- USB/battery load sharing with an AO3401A P-channel MOSFET and Schottky diode
- AP2112K 600 mA, 3.3 V regulator
- 0.91-inch SSD1306 128×32 I2C OLED daughterboard footprint
- Bottom-mounted GY-521 / MPU6050 daughterboard footprint
- Pulse-sensor header with a 270 kΩ / 100 kΩ ADC divider and 100 nF filter
- AO3400A vibration-motor driver with gate pull-down and flyback diode
- Navigation/reset buttons and a six-pin serial programming header
## Reference-compatible pin map
| Function | ESP-12E pin |
| --- | --- |
| Navigation / boot button | GPIO0 |
| Vibration motor | GPIO14 |
| OLED and MPU6050 SCL | GPIO5 |
| OLED and MPU6050 SDA | GPIO4 |
| Pulse input | ADC0 |
| UART programming | TXD / RXD |
The original schematic leaves ADC0 unconnected even though its firmware calls `analogRead(0)`. This board exposes a pulse-sensor header and divides a 3.3 V input to about 0.89 V for the ESP8266 ADC.
## Mechanical and fabrication arrangement
- PCB: 50 mm × 40 mm × 1.6 mm, black solder mask, white silkscreen.
- Four 2.4 mm non-plated mounting holes remain at `(-23, 18)`, `(23, 18)`, `(-23, -18)`, and `(23, -18)` mm.
- Each mounting hole has a 1.7 mm top-and-bottom copper keepout radius, giving 0.5 mm copper clearance around the drill.
- The USB-C receptacle was shifted 1 mm down from the upper-right hole and its shell/CC routing was manually cleared.
- The ESP-12E antenna faces the left edge and has a top-and-bottom copper keepout.
- U2 uses the exact C89297 pad numbering: bottom flash pads are 9–14, GND is pin 15, and GPIO/UART pads are 16–22.
- The OLED and GY-521 are daughterboards and are marked `doNotPlace`; hand-install them after PCB assembly.
- Mount the OLED on headers/spacers high enough to clear the top-side parts beneath its outline.
- The USB-C receptacle and both pushbuttons face the right edge for enclosure access.
- Every fitted component footprint has a courtyard. JLCPCB-assembled parts carry their exact supplier part number in the source and BOM.
## Build and verify
```sh
bun install
bun run typecheck
bun run build
bun run export:gerbers
bun run export:kicad
bun run fab:package
tsci check placement index.circuit.tsx
tsci check netlist index.circuit.tsx
tsci check source index.circuit.tsx
tsci check shorts index.circuit.tsx
```
`index.circuit.tsx` replays the verified manual copper from `pcb-routes.json`; vias are owned by their traces rather than emitted as standalone `<via />` elements. `scripts/extract-manual-routes.mjs` documents how the verified autorouter result was normalized.
After exporting `dist/index/fitness-watch-gerbers.zip`, run `bun run fab:package`. This creates `dist/index/fitness-watch-fab-ready.zip`, removes the DNP OLED and GY-521 daughterboards from the assembly BOM and pick-and-place file, and embeds the critical fabrication, polarity, and hand-assembly notes.
## Assembly and safety notes
- Use only a protected 3.7 V single-cell LiPo. This PCB does not include a cell-protection IC.
- The 10 kΩ TP4056 programming resistor requests roughly 120 mA. Confirm the selected cell is rated for this charge current.
- Confirm battery polarity before connection: J1 pin 1 is `BAT+`, pin 2 is `BAT-`/GND.
- The OLED and GY-521 are not standardized JLCPCB parts; verify the exact module pin order, board outline, and spacer height before ordering an enclosure.
- The design has passed tscircuit placement, source/netlist, DRC build, and Gerber-style short checks, but it has not yet been physically prototyped or certified.
## Key files
- `index.circuit.tsx` — complete tscircuit source
- `pcb-routes.json` — verified manual trace geometry
- `BOM.csv` — fabrication/assembly bill of materials
- `scripts/prepare-fab-package.mjs` — filters DNP modules and adds fab notes to the final archive
- `dist/index/circuit.json` — generated circuit JSON
- `dist/index/fitness-watch-fab-ready.zip` — assembler-facing Gerber, drill, BOM, PnP, and notes archive