Skip to content

Latest commit

 

History

History

cp_bluetooth_neopixel_humidity_gauge

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

CircuitPython - Bluetooth - Neopixel humidity gauge (SHTC3)

Type badge Technology badge License badge

Overview

This project aims to implement a wireless humidity gauge 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:

overview

Sensor Device

The sensor device is a Sparkfun Thing Plus Matter - MGM240P kit connected to a SparkFun Humidity Sensor Breakout - SHTC3 (Qwiic) board. This device periodically provides the humidity level.

The sensor device implements a GATT Server and provides the measured values via BLE Characteristics. The client device can connect to the sensor and gather the provided environmental data by reading the BLE Characteristics.

Client Device

The client device is a Sparkfun Thing Plus Matter - MGM240P kit connected to a NeoPixel Ring - 12 x 5050 RGB LED with Integrated Drivers display. The client device connects to the sensor device via BLE and reads the provided environmental data via BLE characteristics.

The gathered humidity data is displayed on the connected NeoPixel Ring.

Hardware Required

Silabs Development Kits

External Hardware

Prerequisites

Setup

To run the example you need to install Thonny editor and then follow the steps below:

  1. 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.

  1. 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_shtc3 1.9.15
    • Client device

      Library Version
      neopixel_spi 1.6.1
  2. 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.

  3. Run the scripts on the board.

How it Works

Sensor

  • Initialization process
    sensor_init

  • Runtime The sensor device periodically measures the environmental data with a time period of 10 seconds. sensor_runtime

  • BLE

    Read Characteristics ble_char

  • GATT Database:

    • Device name: "CP_HUM_SENSOR"
      • [Service] Humidity Sensing
        • [Char] Humidity [R, N] Get humidity value (e.g.: 25.5 % => 255)

Client

  • Initialization process
    client_init

  • Runtime operation
    client_runtime

Output Display

Measured values should be displayed on the connected Neopixel Ring display. After startup, if client app is scanning sensor app via BLE, Neopixel will blink. After the connection is established, the client app will receive the humidity data and display it via Neopixel. The Neopixel ring has 12 RGB LEDs. The measured humidity value is in the 0-100% range and 8% => 1 LED.

The NeoPixel ring is made up of 12 individual RGB LEDs, which means that each LED can display any color in the RGB color space. In this example, the colors displayed are based on the humidity level measured by the SHTC3 sensor.

The SHTC3 sensor measures relative humidity as a percentage. In this example, the range of humidity values is divided into 12 equal parts, with each part corresponding to one LED on the NeoPixel ring. When the humidity is at 0%, only the first LED lights up with a blue color, which indicates a low humidity level. As the humidity level increases, more LEDs light up on the ring, and the colors become warmer.

For example, if the humidity level is at 10%, then the first two LEDs light up with a warmer color than blue. At 20% humidity, the first three LEDs light up with a warmer color, and so on. At 100% humidity, all 12 LEDs light up with the warmest color, indicating that the humidity level is very high.

Run the code.py file on both sensor and client device and monitor the NeoPixel you will see the result like below.

Sensor Shell
sensor_result

Client Shell
client_result

Hardware hw_result