Devesh36/usb-c-aqi-meter

A PETG-enclosed air-quality monitor assembly combining an AQI circuit board, Sensirion SPS30 particulate sensor, OLED display with bezel and glass, power slider, branding, and internal wiring harness.

Version
1.2.0
License
unset
Stars
0

Use with the tscircuit CLI

tsci is the tscircuit CLI. Install it with npm install -g tscircuit.

tsci clone Devesh36/usb-c-aqi-meter  # download the package files into ./usb-c-aqi-meter
tsci add Devesh36/usb-c-aqi-meter    # add it to your project as @tsci/Devesh36.usb-c-aqi-meter

In a cloned or new (tsci init) project: tsci dev starts a local preview, tsci build outputs Circuit JSON, and tsci push publishes to tscircuit.com.

Files

README.md

# tscircuit — USB-C AQI meter

A desktop particulate monitor with one hardware ON/OFF slide switch and a large **2.42-inch OLED**. A Sensirion SPS30 measures airborne particles; a Raspberry Pi Pico reads it over UART and displays a PM2.5-based air-quality estimate. A low-power Sensirion SHT40 supplies ambient temperature and humidity.

The enclosure has a white lid, a dark screen bezel and small blue **tscircuit** lettering. The display's active area is **55.01 Ɨ 27.49 mm**, approximately six times the area of the earlier 0.96-inch screen. Mode/reset buttons, external status LEDs and light pipes have been removed. The screen communicates status; the single front-edge slide switch controls power.

The 3D display reads **AQI -- / STARTING**. This is a startup illustration, not a measurement from your room. Reference MicroPython firmware is included, with physical hardware testing still required.

## Run and inspect

```sh
bun install
bun run typecheck
bun run build
bun run check
bun run dev assembly.circuit.tsx
python -m unittest discover -s firmware -p 'test_*.py'
```

- `index.circuit.tsx`: labeled schematic and routed 80 Ɨ 70 mm two-layer PCB.
- `assembly.circuit.tsx`: assembled 86 Ɨ 76 mm vented desktop enclosure.
- `exploded.circuit.tsx`: separated lid, OLED and sensor for inspection.
- `firmware/main.py`, `firmware/protocol.py`: Pico reference firmware.
- `BOM.csv`: electronic components, purchased modules and mechanical items.

All electronic design, footprints, routing and assembly geometry use tscircuit. Generated Circuit JSON, schematic/PCB previews and GLB models are in `dist/`.

## Power and the single switch

USB-C supplies 5 V only, with two 5.1 kΩ CC sink resistors and no USB-PD negotiation. F1 is a 500 mA resettable fuse; D_TVS protects the fused input. **SW_PWR is the real SHOU HAN SK12D07VG4, a 500 mA SPDT slide switch imported as C393937 with its exact footprint and CAD.**

The path is USB-C → F1 → FUSED5V → SW_PWR → V5. Physical pin 2 is common, pin 1 is the ON output, and pin 3 is intentionally unconnected for OFF. Metal mounting tabs 4 and 5 connect to ground. The schematic uses a custom tscircuit symbol to retain the manufacturer's pin-2 common numbering. The supplier pad geometry is unchanged.

In normal USB-C operation, OFF disconnects power from both the SPS30 and the Pico/display supply. A B5819W isolation diode between V5 and Pico VSYS prevents the separate Pico service USB from backfeeding the carrier rail. **During programming, service USB can power the Pico and OLED even with SW_PWR off; it does not power the SPS30.** Disconnect service USB for normal ON/OFF operation. The USB-C data pins are intentionally unconnected.

The SPS30 uses switched 5 V directly. The Pico regulator supplies the SHT40 and OLED at 3.3 V. Waveshare quotes about 196 mA for a fully illuminated 2.42-inch OLED; the display and SHT40 fit within the Pico's documented 300 mA external 3.3 V load recommendation. Verify peak current, input inrush and temperature on hardware. Flash, clock, boot control and MCU decoupling remain on the purchased Pico module. Its programming connector is accessible through a rear service opening.

## Display and pin map

The purchased display is the **Waveshare 2.42inch OLED Module, SSD1309, white 128 Ɨ 64**, with a 61.5 Ɨ 39.5 mm module envelope. It sits beneath a 56 Ɨ 28.5 mm lid window, supported by edge rails above the Pico and SPS30. The large AQI line uses doubled text in the firmware.

The schematic has Power, Controller, Sensors and User interface sheets.

| Pico pin | Signal | Connection |
|---|---|---|
| 39 / VSYS | PICO_VSYS | Switched V5 through isolation diode |
| 36 / 3V3 OUT | V3V3 | SHT40, OLED and I²C pull-ups |
| 1 / GP0 | PM_TX | SPS30 RX, J_PM pin 2 |
| 2 / GP1 | PM_RX | SPS30 TX, J_PM pin 3 |
| 4 / GP2 | SDA | SHT40 SDA and OLED DIN |
| 5 / GP3 | SCL | SHT40 SCL and OLED CLK |
| 11 / GP8 | PM_SEL | Input without pull; UART requires floating SEL |
| 12 / GP9 | OLED_RESET | OLED RES, active low |
| 30 / RUN | RUN | 10 kΩ pull-up; no reset button fitted |
| 3, 8, 13, 18, 23, 28, 33, 38 | GND | Common ground |

**J_PM:** vertical JST ZH five-way: 1 = switched 5 V, 2 = sensor RX, 3 = sensor TX, 4 = SEL, 5 = GND. Use an oriented 1:1 cable with ZHR-5 housings.

**J_OLED:** vertical JST PH five-way: 1 = 3.3 V, 2 = GND, 3 = SDA/DIN, 4 = SCL/CLK, 5 = RES. This is a custom adapter to the module's supplied MX1.25 cable, not the factory wire order. Configure **both interface-selection links for I²C** according to Waveshare's instructions. **Tie the display DC lead to GND** through a branch of the adapter ground lead to select address 0x3C; leave CS unconnected. Factory configuration is SPI. RESET is driven by GP9.

## Placement and assembly

The SPS30 is a real purchased laser particulate module connected by cable, rather than a fabricated PCB part. It sits on four supports 6 mm above the right-hand PCB area. Its cable header is clear of its body. The lid's upper vent bank and side vents provide air access; intake/outlet separation needs physical qualification.

The Pico occupies the left side. Power parts occupy the USB-C edge. The SHT40 and its 100 nF capacitor sit at the opposite edge beside a dedicated ambient vent. Keep its sensing opening exposed. The local supplier import omits the centre copper pad according to Sensirion's recommendation, with a routing keepout between the signal lands.

The case has rounded corners, four lid fixing positions and stepped mounting necks through the PCB holes. The only external control is the native power slide switch, with a printed actuator extension through the front wall. The display window, bezel, lettering and vents are separate mechanical features, not additional buttons.

Pico, OLED and SPS30 models are simplified dimensional envelopes. USB-C, SHT40, switch and TVS use downloaded supplier CAD. Cable looms are illustrative. Qualify the display thickness/support, glass protection, switch travel/extension fit, M2 pilot bores, sensor retention, airflow and cable bending against physical samples. This is a mechanical prototype, not a production-qualified enclosure.

## Firmware and validation

Install MicroPython for Raspberry Pi Pico and copy `firmware/main.py` and `firmware/protocol.py` to the device root. Power through USB-C and set SW_PWR ON. The firmware starts the SPS30 over 115200-baud SHDLC UART, verifies checksums, warms it for 30 seconds and gathers about 60 seconds of fresh samples. It validates SHT40 CRCs at 0x44 and drives the SSD1309 OLED at 0x3C using page addressing. There is no mode-button handling or external LED driver code.

The screen says **EST**: the index uses approximately 60-second PM2.5 concentrations and US EPA 2024 breakpoints. It is an indicative local particle index, not a regulatory 24-hour AQI, AirNow NowCast or multi-pollutant AQI. Sensor errors clear the displayed estimate. Values above 500 show `>500`.

Host tests cover manufacturer protocol/CRC examples, reserved-byte escaping, invalid frames, measurement field order and AQI boundaries. Electronic checks cover netlist, schematic placement, component placement, copper shorts and route style. Firmware needs hardware testing; previews do not establish live readings, calibrated performance or mechanical fit.

## References

- [Sensirion SPS30 datasheet and mechanical guidance](https://sensirion.com/sps30)
- [Sensirion SHT40](https://sensirion.com/products/catalog/SHT40)
- [Pico datasheet and pinout](https://datasheets.raspberrypi.com/pico/pico-datasheet.pdf)
- [Waveshare 2.42inch OLED module and interface configuration](https://www.waveshare.com/wiki/2.42inch_OLED_Module)
- [SHOU HAN SK12D07VG4 / C393937](https://jlcpcb.com/partdetail/SK12D07VG4/C393937)
- [US EPA AQI breakpoints](https://aqs.epa.gov/aqsweb/documents/codetables/aqi_breakpoints.html)

Standard footprints come from tscircuit footprinter. Supplier imports include local STEP/OBJ assets. All EDA and assembly source uses the tscircuit ecosystem.