Examples

nRF Connect

Note

The profile for nRF Connect application is in bleico repo under examples/nRF_Connect directory

Put bletag_profile.xml in the mobile device and load the profile in Configure GATT server option

Bletag

This example demonstrates a simple ble tag peripheral with the following structure:

  • Device Local Name: [MOBILE DEVICE]

  • Services:

      1. Device Information:
        1. Appearance
        1. Manufacturer Name String
        1. Model Number String
        1. Firmware Revision String
      1. Battery Service:
        1. Battery Level
        1. Battery Power State
      1. Environmental Sensing:
        1. Temperature
        1. Sensor location
      1. Tx Power:
        1. Tx Power Level

Enable the Advertiser and edit the advertising packet to set the Display Name, Advertising Data, Scan Response Data and check Connectable in options. Finally toggle advertising and run bleico.

When the connection is established, next to advertiser will appear the Connected device (Central) and under Server, Characteristics values can be modified 🖊️ or notifications/indications ⬆️ can be sent to the client.

Warning

Be aware to write the values in the right format, otherwise data will appear as invalid, bleico will raise a wrong format error and a question mark (‘?’) will be shown instead.

Esp32 (MicroPython)

Note

The script for this example is in bleico repo under examples/micropython_esp32 directory

This example demonstrates a simple temperature sensor (esp32 cpu temperature) peripheral with the following structure:

  • Device Local Name: esp32-batt-temp

  • Services:

      1. Device Information:
        1. Appearance
        1. Manufacturer Name String
        1. Model Number String
        1. Serial Number String
        1. Firmware Revision String
        1. Hardware Revision String
        1. Software Revision String
      1. Battery Service:
        1. Battery Level
        1. Battery Power State
      1. Environmental Sensing:
        1. Temperature
        1. Temperature Range
  • Connected Mode:

    The sensor’s local value updates every 30 seconds. When Battery Level is over 90 % or under 10 % it notifies the Client with the Battery Power State

  • Energy Save Mode:

    To save Battery power, it will advertise for 30 seconds, if there is no connection event, it will enter into deep sleep for 60 seconds. If there is a connection event, it will enter the Connected Mode and if there is a disconnection event, it will enter into Energy Save Mode.

Once BLE_Battery_Temp class is initiated it will enter the Energy Save Mode.

Note

Battery Level and Temperature values are averaged over the previous 30 samples

Put ble_batt_cputemp.py in the device and add this in main.py :

import bluetooth
from ble_batt_cputemp import BLE_Battery_Temp


ble = bluetooth.BLE()
ble_temp_batt = BLE_Battery_Temp(ble)

Warning

The board used for this example is the Adafruit feather huzzah32 . If using a different board, the ADC pin for battery readings should be adapted.