This project aims to implement an environmental sensing system using Sparkfun Thing Plus for Matter - MGM240 development kits and external sensors integrated with the BLE wireless stack and CircuitPython.
The block diagram of this application is shown in the image below:
The wireless environment sensing system is composed of a sensor and minimum one client device. The sensor device continuously monitors the ambient temperature, humidity and the air quality. The sensor continuously sends the measured data to the client device.
At first, the sensor device broadcasts its advertisement package that includes its name (CP_ENV_SENSOR) and the UUID of the Environmental Sensing Service (0x181A). A client device can scan and connect to the sensor device; the sensor device can periodically notify the client.
The client device scans periodically the BLE network. Once it found the sender device, it tries to connect to it and reads all the characteristics in the Environmental Sensing Service (0x181A), then it is visible on the OLED display.
Note: Any other BLE-capable device can be a client device, for instance a simple cell phone.
The environmental combo, OLED display and SparkFun Thing Plus Matter board can easily connect to each other via Qwiic I2C connector.
Getting started with CircuitPython on EFR32 boards.
To run the example you need to install Thonny editor and then follow the steps below:
- Flash the corresponding CircuitPython binary for your board. You can visit circuitpython.org/downloads to download the binary.
NOTE: The examples in this repository require CircuitPython v8.2.0 or higher.
-
The lib folder on github contains the necessary library files. You can get updates from the bundle here. The libraries used in this project are listed below.
-
Sensor device
Library Version adafruit_register 1.9.15 adafruit_bme280 2.6.20 adafruit_ccs811 1.3.13 -
Client device
Library Version adafruit_framebuf 1.6.1 adafruit_ssd1306 2.12.12
-
-
Upload all the files and folders from the device_root folder to the CircuitPython device. The files and folders should be copied into the root of the file system on the target device.
-
Run the scripts on the board.
-
Initialization process
-
GATT Database:
- [Service] Environmental Sensing
- [Char] Temperature
- [R, N] Get temperature value (e.g.: 25.5 C => 255)
- [Char] Humidity
- [R, N] Get humidity value (e.g.: 25.5 % => 255)
- [Char] TVOC
- [R, N] Get TVOC value in ppm
- [Char] CO2
- [R, N] Get CO2 value in ppm
- [Char] Temperature
- [Service] Environmental Sensing
-
Runtime operation
Run the code.py file on both sensor and client device and monitor the OLED you will see the result like below.