Luftqualität kontrollieren und fit bleiben!

Maker: MicrocontrollerProjects

Surely you know the following problem: You are working together with several people in an office and after some time your concentration drops strongly. So you decide to get a coffee to counteract the tiredness. When you return with the fresh coffee in your hand, you immediately notice that the air in the office is stale and stuffy. So you open the window to ventilate. What would have happened if you had aired out an hour ago? Would the last hour have been more productive? Probably so, but how can you tell when it's the right time to ventilate while you're brooding intently over your tasks? Many chemicals in the air are also odorless. This is where the SGP30 Air Quality Sensor comes in! It allows you to permanently monitor the indoor air quality in terms of CO2 and volatile organic compounds (VOCs) and to ventilate at an early stage. Thus, productivity and well-being can be increased.

In the following YouTube video tutorial from MikrocontrollerProjekte you will find all steps described in detail:

Hardware needed

  • Adafruit SGP30 Air Quality Sensor Breakout Board
  • Nucleo-F401RE
  • USB cable type A to mini-B
  • 4x Jumper-Wire

Required Software (completely free of charge)

  • ST-LINK Utility
  • RS232 terminal e.g. HTerm
  • (optional: Python 3 + PySerial)
  • (optional: System Workbench for STM32)

Hardware setup

The hardware setup is very simple. You connect the SGP30 breakout board to the NucleoF401RE using the jumper wires (see video) according to the following scheme:

Quick Start

Step 1: Download the ST-LINK utility and install it completely including drivers.

Step 2: Connect the hardware to your PC via USB cable as described in the chapter Hardware Setup.

Step 3: Download the compiled software (SGP30_AirQualitySensor.bin) from GitHub and transfer it to the Nucleo board using the ST LINK Utility (File -> Open File -> "SGP30_AirQualitySensor.bin", then: Target -> Program and Verify -> Start):

Step 4: If everything is assembled correctly and the software communicates successfully with the sensor, the green User LED (LD2) should blink every second. Now you need to use the Windows Device Manager to find the COM port that the ST board used to register a virtual COM port on your PC.

Step 5: Now you can use any RS232 terminal program (e.g. HTerm) to read the serial data sent by the board via your COM port with the settings (baud rate 115200, 8 data bits, 1 stop bit, no parity). With this you have already done the most important thing, the sensor works and measures successfully!

For advanced users

Only if the quick start was successful, you can continue here. To be able to evaluate the sensor data over several hours, e.g. with Excel or Matlab, I wrote a small Python 3 script.

Thanks to the PySerial extension, it reads the RS232 data directly from the serial port and stores it in a logfile (*.csv), separated by a semicolon.

Step 1: Download and install Python 3. Then you have to install the Python extension PySerial. This can be done comfortably with the Python package management program PIP by typing the following command in the Windows command prompt: "pip install pyserial".

Step 2: Download the Python script from GitHub:

Step 3: You have to change the COM5 in the Python script in line 22: (port='COM5', ## xtagstartz--- change to your COM-Port here) with your COM-Port. You can find it again in the Windows Device Manager. Then save and run the script.

Passend dazu

Sparkfun SparkFun Air Quality Sensor - SGP30 (Qwiic)
Sale price13,37 €
In stock, 144 units
Sparkfun SparkFun Indoor Air Quality Sensor - ENS160 (Qwiic)
Sale price23,30 €
Not in stock, available for backorder

Passend zu diesem Artikel

View all