Design a USB environment logger: error, self-heating, power loss and release
A small instrument needs more than a connected sensor. Follow a USB logger from requirements through circuit choices, quantified budgets and the evidence still needed for release.
1. Define the product and its claims
Design an indoor temperature/humidity logger with one record per minute and CSV export over USB. The Japan-market reference uses USB bus power, with no battery, radio or mains input. Standalone logging requires a separate suitable 5V USB source. It does not log during an outage.
This unbuilt reference sets proposed requirements of 10–40°C, 20–80%RH noncondensing, total-product errors within ±0.5°C and ±3%RH, and at least 150 days of records. These are acceptance targets, not component guarantees or achieved results. Medical and food-safety decisions are outside this specification.
The clock stops when power is removed. A PC sets UTC on connection; until then, records use a boot ID and elapsed seconds with clock_valid=false. A clock that survives outages requires an RTC and backup supply, reopening battery and regulatory decisions.
2. Circuit architecture and candidate parts
The measurement path is SHT41 → I²C → RP2040 → external QSPI NOR. Export uses USB CDC and a PC CSV retrieval tool. Derive the power, clock, flash, USB and debug schematic from Hardware design with RP2040. This article provides a design specification, not manufacturing netlists or a routed PCB.
Candidates are RP2040, SHT41, a 16MiB W25Q128JV-family NOR, a fixed 3.3V TLV755P, and a USB-C receptacle. Freeze the actual flash voltage, package and ordering code, then verify boot commands and SDK configuration. Follow the official RP2040 USB reference for series resistors and routing; select low-capacitance ESD protection after checking signal integrity.
Initially use 4.7kΩ pull-ups to 3.3V on SDA and SCL. At an assumed 100pF bus capacitance, the 30–70% rise estimate is 0.8473×4.7k×100p ≈398ns. Confirm tolerances, thresholds and sink capability. Keep I²C inside the enclosure rather than extending it over an unqualified cable.
A candidate pin map uses GPIO4=SDA, GPIO5=SCL and GPIO25=status LED with a proposed0.5mA limit. Use dedicated USB and QSPI pins and expose SWDIO, SWCLK and RUN test pads. Calculate12MHz crystal loading from the selected crystal and parasitics; implement decoupling and VREG connections from the official reference. Reconcile logical pins, package numbers and ERC before layout release.
3. USB power and measurement bias from heat
Terminate CC1 and CC2 independently with 5.1kΩ Rd; do not short them together. This is a USB 2.0 device without a PD high-voltage request. Check preconfiguration current, descriptors, suspend behavior, VBUS capacitance and inrush against the applicable USB requirements.
Allocate 60mA normal and 90mA peak on 3.3V as design budgets, not measured MCU currents. At 5.25V, the LDO loss is 117mW normal or 175.5mW peak, excluding quiescent current. Verify the total input current and keep the proposed preconfiguration limit below 100mA; reduce functions or redesign power if the budget fails.
An assumed effective thermal resistance of 200°C/W gives a 23.4°C rise at normal load and 63.4°C junction at 40°C ambient. This is sensitivity analysis, not a board temperature prediction. Total normal input power is 315mW. Even when the regulator remains within limits, that heat can bias the air-temperature measurement.
Place the sensor at a vented board edge away from the MCU, regulator and USB connector. Evaluate thermal isolation slots against mechanical strength. Check measurement-rate self-heating and heater conditions; do not run the heater continuously during normal measurement. Compare against a reference with the finished enclosure, several orientations, still/moving air and USB active/idle states.
Suspend from a connected PC stops logging and enters a state meeting the applicable USB suspend-current limit; the normal60mA budget is not allowed to continue. Measure GPIO back-power, LEDs, sensor and regulator current, adding power switching if necessary. Continuous standalone logging requires a source that remains active.
4. Choose a recoverable log format before capacity
Reserve 8MiB of a 16MiB flash for logs. At an assumed 32 bytes per record, raw capacity is 262,144 records or 182.0 days at one-minute intervals. The 150-day requirement uses 216,000 records and 6,912,000 bytes, leaving about 1.48MB for headers, CRCs, unavailable space and management. Validate usable capacity after implementation and enforce firmware/log partition boundaries.
A candidate record contains sequence, valid UTC or elapsed time, measurements, status, CRC and a commit marker. Program the body into erased space, verify it, then program commit separately. Do not assume page writes are atomic. Check the actual NOR programming rules and interrupted-write behavior. On boot accept only records with consistent sequence, CRC and commit.
Rotate generation-tagged management headers instead of rewriting one pointer sector each minute. Calculate erase counts per sector and qualify retention over temperature and life. Account for RP2040 XIP availability and USB interrupts during flash operations, moving required code to RAM where needed.
Export an immutable snapshot ending at a captured sequence number over CDC while logging continues. Do not expose a simultaneously writable filesystem to the PC. USB unplugging or a stalled host must not block measurement indefinitely.
Version the32-byte format with byte order, measurement scales, invalid values and CRC polynomial/initial value. A commit marker alone does not establish validity: check CRC and ranges, then test interrupted programming, retries, erase interruption and loss of the newest record.
| 項目/Field | byte |
|---|---|
| sequence | 4 |
| UTC timestamp | 8 |
| elapsed seconds | 4 |
| boot ID | 4 |
| temperature signed fixed-point | 2 |
| RH unsigned fixed-point | 2 |
| status / clock_valid | 2 |
| CRC of first26 bytes | 4 |
| commit marker (last write) | 2 |
5. Error allocation and release tests
Allocate the ±0.5°C target among the sensor guaranteed envelope, board/enclosure heating, calibration residual and reference uncertainty. A typical accuracy number is not an all-condition bound. For humidity, control condensation, contamination, moisture-absorbing materials and assembly outgassing. If applying calibration, document reference traceability, points, coefficient format and recalibration conditions.
The following are proposed tests, not completed results. Freeze sample counts, measurement uncertainty and stabilization conditions in the test plan.
| Test | Proposed acceptance |
|---|---|
| Accuracy | Appropriate combinations of10/25/40°C and20/50/80%RH; include reference uncertainty in decisions |
| Power interruption | Interrupt writes, erase and USB export; previous committed records remain readable and gaps identifiable |
| Thermal/power | Meet device ratings, current budgets and accuracy at supply extremes in the finished enclosure |
| Long operation | Verify150-day capacity, time-not-set, clock changes and full-log behavior |
| EMC/ESD | Select applicable methods/levels beforehand; reject false records, hazardous heat or unrecoverable failures |
6. Japan-market checks and production handoff
This design contains no radio. Determine PSE applicability from the final circuit and supply arrangement against METI interpretations, distinguishing the USB DC device from any bundled/imported AC adapter. Adding an adapter or battery reopens the assessment, including applicable importer, notification, marking and record duties.
Separate legal EMC requirements, voluntary schemes such as VCCI, and customer requirements. Verify USB-IF logo and certification rules before making claims. Overseas sales need a separate destination-specific compliance plan.
Link schematic, exact ordering-code BOM/alternatives, fabrication and assembly data, firmware/licenses, test procedures, labels and manual by revision. Control sensor contamination during assembly. Track serial number and calibration coefficients; define production tests for USB enumeration, sensor CRC, flash readback, current and comparison in a controlled environment.
Explain power requirements, noncondensing conditions, outage gaps, time setting, data responsibilities, cleaning, warranty and contact details. Trace field issues to production lots. Release only after accuracy, immunity, data integrity and applicable regulatory evidence are complete.
Continue with I²C pull-ups, the power budget and PCB release review.
Standards and references
DEVICE DESIGN EXAMPLES
Design a complete device
Follow unbuilt reference designs through requirements, circuit choices, power, heat, tests and release checks.
Design a USB environment logger: error, self-heating, power loss and release
A small instrument needs more than a connected sensor. Follow a USB logger from requirements through circuit choices, quantified budgets and the evidence still needed for release.
Explore the design →Design a 12V temperature-controlled enclosure fan: from airflow to a release test plan
Build the review around a specific small product: a controller that ventilates an electronics enclosure with a replaceable 80mm fan. This reference design follows the requirements through candidate parts, numbers, firmware, mechanical details and commercial release evidence. It has not been built or tested; every acceptance criterion below is a proposed requirement.
Explore the design →