Skip to content
A sample ClearBlade Platform System and an associated Python adapter that can be utilized for BLE communication.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Bluetooth Low Energy Gateway for ClearBlade

This is a BLE Gateway for the ClearBlade Platform that can be executed on any Linux operating system (including Raspberry Pi) supporting bluetooth. The adapter requires the bluez library to be installed. The adapter connects to the ClearBlade platform over MQTT and sends status and error messages back to the platform for processing. In addition, the adapter will automatically scan for BLE devices and add those devices to the ClearBlade Platform.

Commands can be sent to this gateway from the platform for reading and writing data to and from connected BLE devices.


Import the BLE System

  • Create a new account on the ClearBlade platform if you haven't already
  • Clone this repository
  • You will need to import the BLE system into your account
  • After you have installed the cb-cli tool cd into the BLE directory
  • Then run cb-cli import -importrows -importusers
  • It will ask you for the platform URL and your account username and password and then the system will be successfully imported
  • This system contains all the code needed to process messages coming from the bluetooth gateway and also send messages to the gateway
  • The BLEGateway collection contains the gateway status.
  • The BLEDevice collection contains the low energy devices connected to the gateway.
  • The BLEReadValues collection contains the data read from these low energy devices.
  • The BLEErrors collection contains various error messages sent from the gateway.

Add device entry to devices table

Before we start the gateway, we need to add a device, representing the gateway, to the ClearBlade Platform.

  • From the BLE system within the ClearBlade Platform Developers console, select Auth --> Devices
  • Click + Device
  • Enter the following information in the New Device dialog:
    • Name: The name of the device
    • Type: A description of the type of device being added (for example: Raspberry Pi 3 model B)
    • Enabled: YES
    • Allow Key Authorization: YES
  • Click Create
  • In the newly inserted row, double click within the active_key cell and enter an authentication key (ex. 1234567890)

Starting the Gateway

  • Open a terminal session on the device where the gateway will run and enter the following command:

    • sudo python --systemKey <SYSTEM_KEY> --systemSecret <SYSTEM_SECRET> --deviceName <DEVICE_NAME> --activeKey <ACTIVE_KEY> [--platformUrl <PLATFORM_URL>] [--scanInterval <SCAN_INTERVAL>]
  • Once the gateway has started, it will automatically:

    1. Start scanning for BLE devices
    2. Add any found devices to the platform
    3. Read any available information from the device
    4. Store data read from the device in the BLEReadValues collection
You can’t perform that action at this time.