The Air Quality Sensor project contains two parts:
- External unit - the main unit placed inside the building
- Internal unit - the unit placed outside the building
The internal unit is equipped with e-Ink display and shows the temperature, humidity and pressure alongside with PM1/2.5/10 measurements from external unit and its own internal sensors. It's powered by 18500 accumulator and receive data from the external unit via Esp-Now transport protocol. This unit is based on Firebeetle-ESP32 board, with the firmware based on ESP-IDF framework. The board was chosen due to 32K oscillator for RTC and low power consumption.
- Firebeetle-ESP32 main microcontroller board
- SPS30 particulate matter sensor
- BME280 temperature, humidity and pressure sensor
- Pololu Mini MOSFET Switch low voltage module switch
- Pololu U1V10F5 5V step-up module
- 18650 battery case 18650 battery case
- 18650 accumulator 18650 accumulator
- 3,7" WaveShare e-ink display 3,7" WaveShare e-ink display
- 2x20 2,54mm DIP header 2x20 2,54mm DIP header
- Prototyping board 40x60mm 2,54mm pitch Prototype board 40x60mm 2,54mm pitch
- esp-idf main framework
- general-support-library common embedded library
- SimpleDrivers simple embedded drivers for SPS30 and BME280 sensors
All parts of the unit are fixed on frame and covered by external cover. The frame is designed to fit the Firebeetle board, switch, step-up converter, BME280 and SPS30 sensors. It's attached to battery case and the whole module is placed into the external cover. The fame and cover parts are 3D printed. Connection schema:
- SPS30 sensor is connected to the UART2 port of the Firebeetle board.
VCC
pin of the sensor is connected to the +5V output of the step-up converterRX
pin of the sensor is connected to theIO26
pin of the boardTX
pin of the sensor is connected to theIO27
pin of the boardSEL
pin of the sensor is not connectedGND
pin of the sensor is connected to theGND
pin of the board
- BME280 module is connected to the I2C port of the Firebeetle board
SDA
pin of the sensor is connected to theIO21
pin of the boardSCL
pin of the sensor is connected to theIO22
pin of the boardGND
pin of the sensor is connected to theGND
pin of the boardVCC
pin of the sensor is connected to the3V3
pin of the board
- Pololu 2810 switch is mounted under the main board:
GND
connected to the GND pin of the boardEnable
pin connected to the IO13 pin of the Firebeetle boardVIN
pin connected to the battery+ of the Firebeetle boardVOUT
pin connected to the + input of the step-up converter
- step-up converter's is fixed into separated place on the frame under the board
VIN
is connected to the VBAT pin of the Firebeetle boardGND
is connected to the GND pin of the Firebeetle boardVOUT
is connected to the VCC pin of the SPS30 sensor
- e-ink display is connected to the SPI port of the Firebeetle board. It's attached to the 2x20 DIP header soldered on the protoboard to emulate the Raspberry PI 40-pin header. To make it, the protoboard have to be cut to the 3x20 size and the header should be soldered to the board. The cords to the display are soldered to the socket (the 1st pin is top left):
CS
: pin 24 of the header is connected to theIO25
pin of the boardDC
: pin 22 of the header is connected to theIO4
pin of the boardRST
: pin 11 of the header is connected to theIO15
pin of the boardBUSY
: pin 18 of the header is connected to theIO16
pin of the boardCLK
: pin 23 of the header is connected to theIO18
pin of the boardDIN
: pin 19 of the header is connected to theIO23
pin of the boardGND
pin 6 (possibly 9, 14, 20, 25, 30, 34, 39) of the socket is connected to theGND
pin of the board3.3V
pin 1 of the socket is connected to the3V3
pin of the board
The firmware is based on ESP-IDF framework (tested version is 4.4.5) and is written in C++ language. The main task is to show the data from internal sensors alongside with the ones received from the external unit via Esp-Now protocol. The firmware is divided into several modules:
- components - contains the code of the external unit
- general-support library - contains the code for general support functions, obtained from this repository.
- SimpleDrivers - contains the code for the SPS30, BME280 and e-Ink display drivers, obtained from this repository.
- main - contains the main code of the external unit's firmware
- AppConfig - contains the code for the application's configuration
- AppMain - contains the app_main() function and hosts the controller object
- DustMonitorController - contains the code for the controller class handling the main logic of the firmware
- DustMonitorView - contains the code for the class providing the data for the e-Ink display
- EspNowTransport - contains the code for the communication with the main unit based on Esp-Now protocol
- PTHProvider - contains the code for the class providing the data from BME280 sensor
- SPS30DataProvider - contains the code for the class providing the data from SPS30 sensor
- WiFiManager - contains the code for the class providing the Wi-Fi connection management
- CMakeLists.txt - main CMake file for the firmware
- sdkconfig - default configuration file for the ESP-IDF framework.