Skip to content

Latest commit

 

History

History

bluetooth_dosimeter

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Bluetooth - Dosimeter (Sparkfun Type 5)

Type badge Technology badge License badge SDK badge Build badge Flash badge RAM badge

Overview

This project aims to implement a dosimeter application using Silicon Labs development kits and external sensors integrated with the BLE wireless stack.

The block diagram of this application is shown in the image below:

overview

The wireless dosimeter system is composed of a sensor and a (at least one) client device. The sensor device continuously monitors the ambient radiation and calculates it in uSv/h unit and then reports this value to a client device via BLE (Bluetooth Low Energy).

Sensor:

This device broadcasts the calculated ambient radiation level in the advertisement package. A timestamp (a simple counter) value is included in the advertisement pack to indicate that a new radiation event occurred and the calculated radiation value is updated.

The counter (timestamp) value provides a trigger for the client to notify the user about the radiation. (e.g.: activate a buzzer). The sensor device also provides characteristics to read the calculated ambient radiation and get explicitly notified about the radiation events.

Client:

The client device scans periodically the BLE network. Once the sensor device is found, the client device tries to connect to it and read the radiation characteristic and show the radiation level on the connected OLED display. Optionally it can produce a "click" noise by activating the buzzer, to notify the user about the radiation event. The client device subscribes to the radiation characteristic to get notifications about changes in the measured radiation level.

Note: Any other BLE capable device can be a client device, (e.g.: a simple mobile phone).

Gecko SDK Suite version

Hardware Required

Sensor:

Client:

NOTE: The sensor device can run on all Silicon Labs boards while the client device should be used with the listed boards below:

Board ID Description
BRD2703A EFR32xG24 Explorer Kit - XG24-EK2703A
BRD4108A BG22 Bluetooth SoC Explorer Kit - BG22-EK4108A
BRD4314A BGM220 Explorer Kit Board

Connections Required

The hardware connection is shown in the image below:

Sensor Client
sensor client

The Sparkfun OLED Display board can be easily connected to these boards above by using a Qwiic cable while the Buzzer 2 Click connects to them using SPI protocol via a Mikroe connection.

NOTE: Please configure the sensor pin assignment as follows.

Sparkfun Thing Plus Matter xG24 Explorer Kit BGM220P/BG22 Explorer Kit Pocket Geiger Radiation Sensor markings
5V 5V 5V +V
GND GND GND GND
PB01 PB01 - INT PB03 - INT SIG
PB00 PD05 - RX PB02 - RX SN

Setup

To test this application, you can either create a project based on an example project or start with a "Bluetooth - SoC Empty" project based on your hardware.

NOTE:

Create a project based on an example project

  1. From the Launcher Home, add your hardware to MyProducts, click on it, and click on the EXAMPLE PROJECTS & DEMOS tab. Find the example project with the filter "dosimeter".

  2. Click Create button on both Bluetooth - Dosimeter (Sparkfun Type 5) - Sensor and Bluetooth - Dosimeter (Sparkfun Type 5) - Client examples. Example project creation dialog pops up -> click Create and Finish and the projects will be generated.

    create example

  3. Build and flash the examples to the board.

Start with a "Bluetooth - SoC Empty" project

  1. Create Bluetooth - SoC Empty projects for your hardware using Simplicity Studio 5 (for both sensor and client devices).

  2. Copy all attached files in inc and src folders into the project root folder (overwriting existing).

  3. Import the GATT configuration:

    • Open the .slcp file in the project.

    • Select the CONFIGURATION TOOLS tab and open the Bluetooth GATT Configurator.

    • Find the Import button and import the attached gatt_configuration.btconf file.

    • Save the GATT configuration (ctrl-s).

  4. Open the .slcp file. Select the SOFTWARE COMPONENTS tab and install the software components:

    • For sensor device:

      • [Services] → [Sleep Timer]
      • [Services] → [IO Stream] → [IO Stream: USART] → default instance name: vcom
      • [Application] → [Utility] → [Log]
      • [Application] → [Utility] → [Assert]
      • [Third Party] → [Tiny printf]
      • [Third Party Hardware Drivers] → [Sensors] → [Type 5 - Poket Geiger Radiation (Sparkfun)]
    • For client device:

      • [Services] → [Sleep Timer]
      • [Services] → [NVM3] → NVM3 Core
      • [Services] → [NVM3] → NVM3 Default Instance
      • [Services] → [IO Stream] → [IO Stream: USART] → default instance name: vcom
      • [Application] → [Utility] → [Log]
      • [Application] → [Utility] → [Assert]
      • [Third Party] → [Tiny printf]
      • [Platform] → [Driver] → [Button] → [Simple Button] → default instance name: btn0
      • [Platform] → [Driver] → [I2C] → [I2CSPM] → default instance name: qwiic
      • [Platform] → [Driver] → [PWM] → [PWM] → default instance name: mikroe
      • [Third Party Hardware Drivers] → [Display & LED] → [SSD1306 - Micro OLED Breakout (Sparkfun) - I2C]
      • [Third Party Hardware Drivers] → [Audio & Voice] → [CMT_8540S_SMT - Buzz 2 Click (Mikroe)]
      • [Third Party Hardware Drivers] → [Services] → [GLIB - OLED Graphics Library]
  5. Build and flash the project to your device.

Note:

  • Do not forget to flash a bootloader to your board, see Bootloader for more information.

How it Works

Sensor

Sensor overview

Application overview

Sensor GATT Database

  • [Service] Dosimeter Sensor

    • [Char] Radiation
      • [R] Get current radiation value (e.g.: 25 => 25 nSv/h)
      • [N] Notify subscriber

Sensor Implementation

Application initialization:

Application init

On Radiation Callback:

This handler is called when the driver calculates the current radiation level in every configured process period time.

Application callback

Advertisement Packet:

The AdvData field in the advertisement packet is as table below:

DeviceName DataCounter RadiationLevel
DM_SENSOR 4 byte 4 byte
  • DataCounter: This counter starts from 0, and incremented by 1 each time the advertisement packet content is updated (Each invocation of the onRadiation event callback).
  • RadiationLevel: Radiation level in nSv/h unit.
  • Device is not connectable. It sends manufacturer specific advertisement packets.

Client

Client overview

Application overview

Client GATT Database

Advertisement Packet Device name: DM_CLIENT

GATT Database

  • Device name: DM_CLIENT

  • [Service] Dosimeter client

    • [Char] Alarm Threshold
      • [R] Get alarm threshold value
      • [W] Set alarm threshold value - alarm_threshold (e.g.: 25 => 25 nSv/h)
    • [Char] Notification Status
      • [R] Get Notification Sound Status
      • [W] Set Notification Sound Status value - notification_status (0 - disabled, 1 - enabled)
    • [Char] Click Noise Status
      • [R] Get Click Noise Status
      • [W] Set Click Noise Status value - click_noise_status(0 - disabled, 1 - enabled)

Client Implementation

Application initialization:

Application init

Runtime - Configuration Mode:

Config mode

Runtime - Normal Mode:

Client events:

Client event

Client button

Logic blocks:

Client logic

Radiation Characteristic Notification Event:

Client logic

Display:

The OLED will display config mode and disconnected respectively if the client device is in the configuration mode and disconnected to sensor device.

Configuration Mode Disconnected to sensor
Configuration Disconnected

The application shows the received current radiation value on the display in nSv/h or uSv/h unit depending on the measured radiation level.

  • < 1 uSv/h => nSv/h (no decimals)
  • >= 1 uSv/h => uSv/h (2 decimals)

Display

Testing

Sensor:

You can use a smartphone application such as the EFR Connect application, to see the advertising packet from the Sensor.

  • Open the EFR Connect application.

  • Open the Bluetooth Browser.

  • Find the device advertising as DM_SENSOR.

  • Click on the instance of DM_SENSOR. Now, you should see the counter and the radiation value on the Manufacturer Specific Data row. Please have a look at the red highlighted area below in the result pictures.

    sensor efr connect

  • After a connection is established, a similar output from a serial terminal as shown below

    sensor Log

Client:

  • Upon reset, the application will display the Silicon Labs logo on the OLED screen for a few seconds.

  • Push the button 0 after reset the client device will make the device run into the configuration mode. In this mode, users can use the EFR Connect application to connect to the client device to change its operating configuration.

    client configuration efr

  • After the firmware is configured, the device starts in normal mode. In this state, it starts Scanning/Discovering advertising devices. It initiates a connection with those devices that contain the DM_SENSOR name in their advertising packets.

  • After a connection is established, the client discovers the service by UUID from the remote GATT database. After the service discovery is completed, the client discovers the radiation characteristics and enables notification sent from a remote GATT sensor. The application shows the received current radiation value on the display.

  • Open your terminal emulator and connect to your client device over its serial port. Set the baud rate to 115200. A similar output as below.

    client log

  • Note: Button PB0 should be pressed during startup (power-on or reset) to run the client in Configuration Mode. The terminal will display information as below and the Oled will also display "CONFIG MODE".

    client configuration