README.md
# Wi-Fi Weather Station (tscircuit)
A small 60 × 44 mm, 2-layer board that measures **temperature, relative
humidity and UV index** and reports over **Wi-Fi**. Designed entirely in
[tscircuit](https://tscircuit.com); every part is a stocked JLCPCB basic /
extended part so the board can be ordered assembled.
| Function | Part | Interface | Notes |
|---|---|---|---|
| MCU + Wi-Fi/BLE | ESP32-S3-WROOM-1-N8R2 (`U1`) | native USB | 8 MB flash, 2 MB PSRAM, on-module PCB antenna |
| Temperature + humidity | Sensirion SHT40-AD1B (`U3`) | I2C `0x44` | ±0.2 °C, ±1.8 %RH |
| UV index + ambient light | Lite-On LTR-390UV-01 (`U4`) | I2C `0x53` | INT on IO10 |
| Power in / programming | USB-C 16-pin (`J1`) | USB 2.0 | 5.1 k CC pull-downs (UFP), USBLC6-2SC6 ESD (`U5`) |
| 3.3 V rail | AMS1117-3.3 (`U2`) | | 10 µF in, 22 µF + 100 nF out |
| Expansion | Qwiic / STEMMA-QT JST-SH 4-pin (`J2`) | I2C | GND, 3V3, SDA, SCL |
| Debug / spare I/O | 8-pin 2.54 mm header (`J3`) | UART0 + GPIO | 3V3, GND, TXD0, RXD0, IO4–IO7 |
| Buttons | RESET (`SW1`, EN), BOOT (`SW2`, IO0) | | hold BOOT + tap RESET → USB download mode |
| LEDs | `D1` power (green), `D2` status on IO21 (blue) | | |
## ESP32-S3 pin map
| Signal | GPIO | Signal | GPIO |
|---|---|---|---|
| I2C SDA | IO8 | USB D− | IO19 |
| I2C SCL | IO9 | USB D+ | IO20 |
| LTR-390 INT | IO10 | Status LED | IO21 |
| UART0 TX / RX | IO43 / IO44 (TXD0/RXD0) | Spare ADC-capable | IO4, IO5, IO6, IO7 |
I2C pull-ups (4.7 k) live on the board, so nothing on the Qwiic bus needs
its own. Strapping pins IO0/EN are handled by the buttons + 10 k pull-ups;
IO3, IO45, IO46 are left floating as Espressif recommends.
## Revision history
### 1.2.0 — power delivery
* 3V3 and VBUS nets route at 0.5 mm, GND at 0.4 mm (signals stay 0.25 mm), so
Wi-Fi transmit bursts no longer run through 0.25 mm copper.
* `C9`, a 22 µF ceramic, added at the module's 3V3 pin next to the existing
10 µF + 100 nF; the regulator keeps its own 22 µF.
### 1.1.x
* **Thermal isolation for the SHT40.** `U3` and its decoupling cap now sit on
a 5.5 × 7.5 mm island at the top-right corner, separated from the rest of
the board by three 1.2 mm milled slots (the left and right slots run out
through the top edge). A single 3.2 mm bridge at the bottom carries the
four traces (SDA, SCL, 3V3, GND), so heat from the LDO and the module can
only reach the sensor through that narrow neck. Cutouts are routing
obstacles in tscircuit, and the build verifies no trace or via crosses a
slot.
* **Enclosure model.** The board is wrapped in an `<assembly.device>` with an
`<enclosure.fdm.box>` (2 mm walls, 1 mm board clearance). Parts declare
their own openings, so the printed lid and base get:
* a 6 mm round **window above the UV sensor** `U4` — cover it with a
UV-transparent material (0.1–0.2 mm PTFE film or a quartz disc; ordinary
acrylic and polycarbonate block UV-B and would zero the UV index);
* a 5 × 7 mm **vent above the SHT40 island** so outside air reaches the
humidity sensor;
* 4 mm holes above both buttons, a pill opening for USB-C and a rectangular
opening for the Qwiic connector in the bottom wall.
The debug header `J3` has no opening; use it with the lid off. Export the
base and lid from the 3D view of `tsci dev` (or `tsci export -f glb`).
* The Qwiic connector `J2` now uses the exact JLCPCB footprint for
SM04B-SRSS-TB, which also fixes pin-1 orientation for assembly.
* The USB-C receptacle `J1` uses the exact JLCPCB land pattern and 3D model
for TYPE-C-31-M-12 (C165948), with each shell anchor as its own pin, so it
shows up in the 3D/enclosure view and its placement rotation is verified.
## Layout notes
* The module sits at the top-left with its antenna flush to the board edge.
A copper/routing **keep-out** covers the antenna area on both layers and the
bottom-side ground pour respects it. Keep metal (and the M3 screw heads)
away from that corner in the enclosure.
* USB-C at the bottom edge, LDO next to it, buttons and expansion on the
right, sensors along the top edge away from the LDO and the module (see
Revision 1.1 for the SHT40 island and the enclosure openings).
## Files
* `index.circuit.tsx` – the whole board (schematic + PCB + BOM)
* `imports/` – JLCPCB parts pulled in with `tsci import` (exact EasyEDA
footprints and 3D models). The ESP32 module's nine thermal-pad pads were
merged into one pad; the SHT40 centre pad is labelled `EP` and left
unconnected (Sensirion allows floating or VSS).
* `__snapshots__/` – rendered schematic and PCB SVGs
## Build / view / order
```bash
bun install # or npm install
bun run dev # live preview at http://localhost:3020
bun run build # dist/index/circuit.json (+ routing)
bunx tsci snapshot # refresh __snapshots__/*.svg
bunx tsci export index.circuit.tsx -f gerbers # fabrication zip
bunx tsci export index.circuit.tsx -f kicad_zip # open in KiCad
```
Fab rules used: 0.25 mm traces (0.15 mm minimum), vias 0.3 mm drill / 0.6 mm
pad, 1.2 mm slots, all inside JLCPCB's standard 2-layer capability.
Checks that pass on this revision: `tsci check netlist`, `tsci check
placement`, `tsci check shorts`, full autoroute with no unconnected ports.
## Firmware sketch
Any ESP32-S3 Arduino / ESP-IDF / MicroPython image works over the USB-C
port (USB-Serial/JTAG, no driver chip). With Arduino:
`Wire.begin(8, 9)`, `Adafruit_SHT4x` for `U3`, `Adafruit_LTR390` for `U4`,
then publish over Wi-Fi (MQTT / HTTP) as you like.