gokul/wireless-calculator
A USB‑C rechargeable battery-powered controller board with MCP73871 Li‑ion charging, TPS63070 buck‑boost and LDO power regulation, ATmega328P and ESP32‑S3 control, LCD/keypad user interface, status LEDs, and UART/programming connectors.
- Version
- 0.0.1
- License
- ISC
- Stars
- 0
README.md
# Wireless calculator
**Prototype fabrication package generated and checked.** The build, netlist,
placement, PCB style and Gerber short checks pass. No physical unit has been
built or tested. Firmware is not included; production readiness is not claimed.
58 × 124 mm, two copper layers, 1.6 mm PCB. A 20-key matrix and reflective
EA DOGS102N-6 LCD provide a normal basic-calculator interface. An ATmega328P
handles calculation and display; it powers the ESP32-S3-WROOM-1-N8 only when
wireless features are requested. The radio supports 2.4 GHz Wi-Fi and Bluetooth
LE; Bluetooth Classic is not supported. Internet services require firmware.
Schematic sheets and automatically positioned sections organize the design.
There are no `schX` or `schY` assignments. PCB routing uses tscircuit's local
`@tscircuit/capacity-autorouter`, from the tscircuit-autorouter repository.
Versions are pinned in package.json and bun.lock. Six critical connections use authored trace paths: two regulator-to-inductor
connections, the regulator-to-radio-switch feed, the switch-to-ESP32 feed,
a ground return and the charger-to-regulator input feed. Their long power/return sections are 2 mm (top) and
1.2 mm (bottom radio feed), with narrower local pad escapes. The official
autorouter generated the remaining 223 connections. Their geometry is saved in
`lib/autorouted-paths.json`, with reviewed local clearance and 45-degree edits.
The default build reuses these paths for a reproducible board. Render
`<CalculatorBoard reuseRoutes={false} />` from `lib/calculator-board.tsx` to
run the official local router again; revalidate any new result.
## Battery and charging
Use one protected, rechargeable **3.7 V nominal / 4.2 V maximum Li-Po pack**,
not a coin cell. The specified example is [Adafruit 258, 1200 mAh](https://www.adafruit.com/product/258).
Its [manufacturer specification](https://cdn-shop.adafruit.com/product-files/258/C101-_Li-Polymer_503562_1200mAh_3.7V_with_PCM_APPROVED_8.18.pdf)
states 1 C maximum continuous discharge (1.2 A), a protection circuit, a 3.0 V
end-of-discharge voltage, and charging from 0 to 45 °C. Allow approximately
35 × 62 × 5 mm plus cable, insulation and swelling clearance in the enclosure.
The battery is an external assembly item, not an SMT BOM line.
JBAT pin 1 is positive and pin 2 is negative. Check the actual cable polarity
before connecting: a mechanically compatible JST plug does not establish its
polarity. JBAT uses B2B-PH-K-S(LF)(SN), 2 mm pitch, with 0.85 mm finished plated
holes. The custom footprint corrects the undersized holes in the generic PH
footprint used during development.
The battery also requires an insulated, battery-mounted **10 kΩ NTC assembly**
connected to JNTC (pin 1 THERM, pin 2 GND). The example battery has no temperature
lead. [TDK B57371V2103H060](https://product.tdk.com/en/search/sensor/ntc/chip-ntc-thermistor/info?part_no=B57371V2103H060)
(10 kΩ ±3%, B25/50 4386 K ±3%) is the specified sensor. This is a 0603
component that needs a separately insulated sensor assembly, thermally bonded
to the cell. The assembled sensor still requires temperature qualification;
the component selection alone does not establish thermal response time. Do not substitute an
arbitrary 10 kΩ thermistor or a fixed resistor. An absent sensor inhibits
charging. Never solder directly to the battery pouch or cell tabs.
MCP73871-2CCI/ML supplies load sharing, approximately 249 mA charge current
(4.02 kΩ), 25 mA termination current (40.2 kΩ), and a 500 mA input limit.
Use a regulated 5 V USB charging supply rated for at least 500 mA. This board
has no USB data, PD negotiation, BC1.2 detector or CC-current detector; universal
computer-port compatibility is not claimed. USB-C CC1 and CC2 have separate
5.1 kΩ sink resistors. A qualified USB input arrangement remains part of release
review.
## Power architecture
[TPS63070](https://www.ti.com/lit/ds/symlink/tps63070.pdf) generates **3.269 V nominal** for the radio supply using 154 kΩ /
49.9 kΩ, 0.1% feedback resistors. Power-save mode remains enabled. Including
its +3%/-1% PFM accuracy, resistor tolerance and a conservative ±100 nA
feedback leakage allowance gives approximately **3.216–3.388 V** before
transients and wiring drop. [TPS7A0230PDBVR](https://www.ti.com/lit/ds/symlink/tps7a02.pdf) then supplies the calculator MCU
and LCD at **3.0 V**. This separates the LCD's 3.3 V operating ceiling from
the ESP32's supply-drop requirements.
The explicit feed and return paths have an estimated combined resistance
of 105 mΩ with 35 µm copper at 70 °C. Including an 80 mΩ switch allowance
gives about 93 mV drop at 500 mA, or approximately **3.124 V** at the ESP32
under the modeled low-supply corner. This excludes parallel copper pours
and other supply paths, contact resistance and transient effects; it is a
calculation, not a measurement. Confirm the ESP32 remains above 3.0 V with
an oscilloscope during startup and maximum-power transmission on a prototype.
The 3.0 V LDO uses 1 µF input and 4.7 µF output capacitors. The calculator/LCD
load is much smaller than its 200 mA rating. Verify dropout and transient
response at the minimum input voltage. UART isolation remains powered by
RADIO; its output high voltage stays below the AVR's VCC + 0.5 V absolute
limit at the calculated steady-state supply corners.
[TPS22918](https://www.ti.com/lit/ds/symlink/tps22918.pdf) switches RADIO, with a 1 nF CT capacitor to limit turn-on inrush.
Its lower on-resistance preserves more ESP32 voltage margin than the earlier
TPS22919 selection. An external 100 kΩ pull-down keeps the radio off during
AVR reset. SN74LVC2G125 isolates both UART directions when the radio is off;
its Ioff behavior prevents those signals from powering the disconnected radio.
The main MCU remains powered and sleeps between keypresses. PWR and WIFI LEDs
are firmware-controlled green indicators; CHG and FULL reflect charger status.
Keep PWR off or pulse it when low standby consumption is desired.
## Assembly and mechanics
- Top: LCD, keypad, status LEDs, USB receptacle. Bottom: active electronics,
programming pads, boot/reset switches and battery/sensor connectors.
- LEDs use the exact Lite-On C190 footprints: green C125094 and red C94869.
All four have their cathodes on the right when viewed from the top. The
placement rotation is 180 degrees relative to the imported footprint.
Passive BOM lines retain their specified manufacturer part numbers; automatic
supplier substitution is disabled for these lines.
- 20 keys on a 12 mm grid. Four 2.2 mm mounting holes. Board dimensions exclude
the ESP32 antenna overhang of approximately 5.2 mm at the bottom edge.
- Keep the antenna away from metal, battery, wiring and enclosure features;
follow Espressif's 15 mm antenna clearance guidance. The board keep-out alone
does not validate an enclosure or radio performance.
- The ESP32 optional EPAD landing is omitted. Espressif's module datasheet,
section 9, explicitly permits leaving this pad unsoldered. Perimeter ground
pins 1 and 40 remain connected. This differs from a raw ESP32 chip's thermal
pad requirements.
- Use an insulating battery carrier. Do not press the pouch against solder
joints, headers or bottom-side parts. An enclosure is not included.
- Hand-solder the LCD and through-hole connectors after reflow. LCD CAD is a
simplified mechanical envelope, not manufacturer CAD.
- JISP and JESP are intentionally unpopulated programming access. JISP is a
single row of six pins, **not** the conventional 2×3 AVR ISP footprint.
- Assembly rotations must be checked against the supplier's orientation
preview before submitting an automated assembly order.
## Firmware and programming contract
ATmega328P must use the internal oscillator at 8 MHz or below; do not use a
16 MHz Arduino fuse setup. Program through JISP. Implement arithmetic, LCD
initialization, key debounce, sleep/wakeup and radio control. The matrix has no
diodes: reject ambiguous simultaneous keypresses. Hold LCD CS high during ISP.
| Interface | Mapping |
| --- | --- |
| JISP pins 1–6 | MISO, V3_0, SCK, MOSI, RESET, GND |
| JESP pins 1–5 | GND, ESP RXD0, ESP TXD0, BOOT, EN |
| MCU ↔ ESP runtime link | AVR UART ↔ isolated ESP GPIO4 RX / GPIO5 TX |
| LCD | SPI MOSI/SCK, CS, CD, RESET; UC1701 initialization required |
| Battery ADC | 1 MΩ / 330 kΩ divider, 100 nF filter; internal 1.1 V reference |
JESP does not supply programmer power. Enable RADIO before programming and use
3.3 V logic with shared ground. Never drive ESP programming pins while RADIO is
off. Hold BOOT low during reset for the serial bootloader. Release reset and
then BOOT before flashing. The firmware must also shut down wireless before
battery depletion and sleep the main MCU at the pack's operating cutoff.
Use calibrated battery measurements; initially disable the radio below
3.5 V under load, re-enable above 3.6 V, and enter low-battery sleep at 3.3 V.
Validate these thresholds in the prototype, including the charger power-path
drop and the regulator's accuracy conditions.
No battery-life number is claimed before measuring sleep current and actual
wireless duty cycle. Wi-Fi and charging temperature tests, display operation,
keypad wakeup, supply transients and antenna performance require a prototype.
## Rebuild and validate
```sh
bun install
bun run typecheck
bunx tsci check netlist index.circuit.tsx
bunx tsci check schematic-placement index.circuit.tsx
bunx tsci check placement index.circuit.tsx
bun run build
bunx tsci check shorts dist/index/circuit.json
bunx tsci check pcb-style dist/index/circuit.json
bun run render:views
```
Only a passing, inspected revision should be exported for manufacture.
## Fabrication files and verification
`dist/fabrication/wireless-calculator-gerbers.zip` contains the two-layer Gerbers,
plated and nonplated drills, 90-component BOM and original placement table.
`dist/fabrication/wireless-calculator-schematic.pdf` contains all 14 sheets.
Read `dist/fabrication/ASSEMBLY.txt` before ordering; the separate SMT placement
file excludes LCD1, JBAT and JNTC, which are hand soldered after reflow.
JISP and JESP are intentionally omitted from both BOM and placement exports.
The final Circuit JSON has zero error elements. Source, pin specification,
netlist and placement checks report zero errors and warnings; the complete
build retains stock warnings for L1/U5/U6 and a reference-prefix warning for
LCD1. Verify supplier availability. Some supplier placement rotations are
unverified by the exporter; check the assembly preview against the supplied
pin-1 coordinate reference. This cannot be replaced by a software pass.
Reviewed views include all schematic sheets, PCB top/bottom, 3D top/bottom,
and independent Gerber top/bottom renders. `dist/fabrication/validation.json`
records versions, hashes, passed checks and the hardware tests still needed.
The LCD 3D envelope is simplified and JBAT has no housing model.