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)

PartManufacturer part numberManufacturerQtyFunction
STM32F103C8T6STM32F103C8T6STMicroelectronics1Main controller: runs sensor reading, CO2 alarm logic, 15-minute silence timer, OLED rendering and buzzer drive.
Sensirion SCD41SCD41-D-R2Sensirion1NDIR CO2 measurement (ppm), plus its own temperature and humidity readings.
Sensirion SHT40 temperature and humidity sensor, I2CSHT40-AD1B-R2Sensirion1Dedicated ambient temperature (°C) and relative humidity (%) sensor, placed away from self-heating parts so readings reflect the room air.
Omron B3F-1000 tactile pushbuttonB3F-1000Omron1Silence 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 sensoreCMI-1295-85TSame Sky (formerly CUI Devices)1Sounds the CO2 alarm and the sensor-fault alarm.
2N7002 N-channel MOSFET2N7002Konsemi1Low-side switch that drives the buzzer from the MCU GPIO.
0.96in 128x64 I2C SSD1306 OLED panel module, 3.3 V supply and logicDFR0650DFRobot1Shows CO2 (ppm), temperature (°C) and humidity (%) values, plus warm-up and fault messages.
3.3 V LDO regulator 1 A SOT-223 MCP1826S-3302E/DBMCP1826S-3302E/DBMicrochip Technology1Regulates 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-AGCT15 V power input from USB-C.
Low-capacitance TVS/ESD diode, VBUS to GND, 5 V lineTPD1E05U06DPYRTexas Instruments1Low-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 connector78511-206HLFAmphenol Communications Solutions1Connector 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 headerFTSH-105-01-L-DV-KSamtec1SWD 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 LDO1Input decoupling of the 3.3 V LDO regulator (MCP1826S-3302E/DB), on its VIN pin.
I2C pull-up resistor 4.7 kΩ 06032Pull-up pair on the shared I2C bus (SDA and SCL to 3V3).
Decoupling capacitor 100 nF 06036Local decoupling on each supply pin of the MCU, sensors and regulator.
Bulk capacitor 10 µF 08052Bulk decoupling on the 3.3 V rail and on the USB 5 V input.
Pull-down resistor 100 kΩ 06031Pull-down on the buzzer MOSFET gate so the buzzer stays OFF during boot.
Button pull-up resistor 10 kΩ 06031Pull-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 SMD1External high-speed clock for the STM32 core and USB.
5.1 kOhm USB-C CC pull-down resistor 06032Rd 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_IN1HSE 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_OUT1HSE 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 STM321Bulk decoupling of the MCU supply: 4.7 µF from VDD to VSS.
10 nF VDDA decoupling capacitor on the STM321High-frequency decoupling of the analog supply: 10 nF from VDDA to VSSA.
1 µF VDDA decoupling capacitor on the STM321Low-frequency decoupling of the analog supply: 1 µF from VDDA to VSSA.
10 kΩ BOOT0 pull-down resistor 06031Pull-down on the STM32 BOOT0 pin so the MCU boots from flash.
100 nF NRST filter capacitor on the STM321Reset filter: 100 nF from NRST to ground.
100 nF 0603 supply decoupling capacitor, SHT40 VDD to GND1Supply decoupling of the Sensirion SHT40 temperature and humidity sensor: 100 nF from VDD to GND, next to the sensor.
Schottky diode 1N58191Flyback 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.