MCUcraft · Example project, made with MCUcraft
Workshop air quality
The idea
Air quality monitor for my workshop, on an STM32. It measures CO2, temperature and humidity, shows them on a small OLED display, and sounds a buzzer when CO2 goes above 1500 ppm. Powered from USB-C. I want a custom PCB.
Firmware
Firmware builds, some tests fail
it compiles, but the check `comportamento_sull_host` failed: scenario `V-01.release` (rule V-01, R-de09, R-5c68): expected output `buzzer` off the whole time from 6 s to 9 s, seen on. The user said «Your other assumptions are fine.». Script: at 0 s co2=1500; at; the firmware is delivered as it is
Bill of materials (29 lines)
| Part | Manufacturer part number | Manufacturer | Qty | Function |
|---|---|---|---|---|
| STM32F103C8T6 | STM32F103C8T6 | STMicroelectronics | 1 | Main controller: runs sensor reading, CO2 alarm logic, 15-minute silence timer, OLED rendering and buzzer drive. |
| Sensirion SCD41 | SCD41-D-R2 | Sensirion | 1 | NDIR CO2 measurement (ppm), plus its own temperature and humidity readings. |
| Sensirion SHT40 temperature and humidity sensor, I2C | SHT40-AD1B-R2 | Sensirion | 1 | Dedicated ambient temperature (°C) and relative humidity (%) sensor, placed away from self-heating parts so readings reflect the room air. |
| Omron B3F-1000 tactile pushbutton | B3F-1000 | Omron | 1 | Silence button: starts the 15-minute buzzer silence phase when pressed. |
| Cicalino magnetico attivo 12 mm 3 V (CMI-1295-85T), allarme CO2 e allarme guasto sensore | CMI-1295-85T | Same Sky (formerly CUI Devices) | 1 | Sounds the CO2 alarm and the sensor-fault alarm. |
| 2N7002 N-channel MOSFET | 2N7002K | onsemi | 1 | Low-side switch that drives the buzzer from the MCU GPIO. |
| 0.96in 128x64 I2C SSD1306 OLED panel module, 3.3 V supply and logic | DFR0650 | DFRobot | 1 | Shows CO2 (ppm), temperature (°C) and humidity (%) values, plus warm-up and fault messages. |
| 3.3 V LDO regulator 1 A SOT-223 MCP1826S-3302E/DB | MCP1826S-3302E/DB | Microchip Technology | 1 | Regulates the 5 V USB input down to the 3.3 V rail for the MCU, sensors and OLED. |
| USB-C 16-pin receptacle (USB2.0) | USB4105-GF-A | GCT | 1 | 5 V power input from USB-C. |
| Low-capacitance TVS/ESD diode, VBUS to GND, 5 V line | TPD1E05U06DPYR | Texas Instruments | 1 | Low-capacitance TVS/ESD clamp from VBUS to GND, placed next to the USB-C receptacle, protecting the user-accessible port. |
| 1x6 2.54 mm pin header, OLED module connector | 78511-206HLF | Amphenol Communications Solutions | 1 | Connector for the 0.96in OLED module header: VCC, GND, SCL, SDA, D/C, CS. Carries the module's wires. In I2C mode only VCC, GND, SCL and SDA are used; D/C and CS are not connected or tied as the module's I2C mode requires. |
| SWD 2x5 1.27mm programming header | FTSH-105-01-L-DV-K | Samtec | 1 | SWD programming and debug connector for the STM32 (flashing with an ST-LINK probe). |
| 1 µF input capacitor on the VIN of the MCP1826S 3.3 V LDO | 1 | Input decoupling of the 3.3 V LDO regulator (MCP1826S-3302E/DB), on its VIN pin. | ||
| I2C pull-up resistor 4.7 kΩ 0603 | 2 | Pull-up pair on the shared I2C bus (SDA and SCL to 3V3). | ||
| Decoupling capacitor 100 nF 0603 | 6 | Local decoupling on each supply pin of the MCU, sensors and regulator. | ||
| Bulk capacitor 10 µF 0805 | 2 | Bulk decoupling on the 3.3 V rail and on the USB 5 V input. | ||
| Pull-down resistor 100 kΩ 0603 | 1 | Pull-down on the buzzer MOSFET gate so the buzzer stays OFF during boot. | ||
| Button pull-up resistor 10 kΩ 0603 | 1 | Pull-up on the silence button GPIO input; the button pulls it low when pressed. | ||
| Crystal 8 MHz HSE 12 pF CL, 3.2x2.5 mm SMD | 1 | External high-speed clock for the STM32 core and USB. | ||
| 5.1 kOhm USB-C CC pull-down resistor 0603 | 2 | Rd pull-downs on CC1 and CC2 of the USB-C receptacle, so a USB-C source gives 5 V to this sink. | ||
| 20 pF HSE load capacitor on OSC_IN | 1 | HSE load capacitor from OSC_IN of the STM32 to ground, with C12 on OSC_OUT, for crystal Y1. | ||
| 20 pF HSE load capacitor on OSC_OUT | 1 | HSE load capacitor from OSC_OUT of the STM32 to ground, with C11 on OSC_IN, for crystal Y1. | ||
| 4.7 µF VDD bulk capacitor on the STM32 | 1 | Bulk decoupling of the MCU supply: 4.7 µF from VDD to VSS. | ||
| 10 nF VDDA decoupling capacitor on the STM32 | 1 | High-frequency decoupling of the analog supply: 10 nF from VDDA to VSSA. | ||
| 1 µF VDDA decoupling capacitor on the STM32 | 1 | Low-frequency decoupling of the analog supply: 1 µF from VDDA to VSSA. | ||
| 10 kΩ BOOT0 pull-down resistor 0603 | 1 | Pull-down on the STM32 BOOT0 pin so the MCU boots from flash. | ||
| 100 nF NRST filter capacitor on the STM32 | 1 | Reset filter: 100 nF from NRST to ground. | ||
| 100 nF 0603 supply decoupling capacitor, SHT40 VDD to GND | 1 | Supply decoupling of the Sensirion SHT40 temperature and humidity sensor: 100 nF from VDD to GND, next to the sensor. | ||
| Schottky diode 1N5819 | 1 | Flyback diode across the active buzzer BZ1: cathode on +3V3, anode on BUZZER_LOW (the buzzer's negative, driven by Q1). |
The schematic, the PCB, the firmware and the chat that produced them open in the MCUcraft workspace, read-only and without an account: Workshop air quality.