Home

Awesome

<img align="right" width="200" height="100" src="https://raw.githubusercontent.com/Carglglz/upyble/master/uPyblelogo.png">

uPyble

PyPI versionPyPI license

Command line tool for Bluetooth Low Energy devices

uPyble is intended to be a command line tool upydev-like to make easier the development, prototyping and testing process of devices based on boards running *MicroPython with Bluetooth Low Energy capabilities.

*( Any other BLE device should work as well)

⚠️ Keep in mind that this project is in ALPHA state, sometimes, some commands may not work/return anything ⚠️

Features:

🔸 (REPL works, but some SHELL commands are still under development)

🔺 There is a limit in the amount of output it can produce, so long lists or cat a big file will freeze the BLE SHELL-REPL and possibly the device, which makes a reset almost inevitable.


Getting Started

To use Terminal BLE SHELL-REPL :

First be sure that the BLE REPL daemon is enabled and running:

These scripts are in upybleutils directory. (Originals from MicroPython repo bluetooth examples)

Installing :

$ pip install upyble or $ pip install --upgrade upyble to update to the last version available

Finding BLE devices:

Use $ upyble scan or $ upyble tscan for table output format.

$ upyble tscan
Scanning...
Scanning...
BLE device/s found: 1
==============================================================================
        NAME         |                   UUID                   | RSSI (dBm) |
 esp32-30aea4233564  |   9998175F-9A91-4CA2-B5EA-482AFC3453B9   |   -68.0    |

Create a configuration file:

*upyble will use local working directory configuration unless it does not find any or manually indicated with -g option.


uPyble Usage:

Usage:

$ upyble [Mode] [options]

This means that if the first argument is not a Mode keyword it assumes it is a 'raw' upy command to send to the upy device

Help: $ upyble -h

uPyble Mode/Tools:


Examples:

Follow the Battery Level and Temperature (cpu) of an Esp32.

​ This needs ble_batt_temp.py in the device. (See upybleutils)

​ In the device REPL do:

>>> import ble_batt_temp
>>> ble_batt_temp.ble_batt.start_batt_bg()

Now in local Shell/Terminal:

  1. Scan and configure device:

    $ upyble scan
    Scanning...
    Scanning...
    BLE device/s found: 1
    NAME: esp32-batt-temp, UUID: 9998175F-9A91-4CA2-B5EA-482AFC3453B9, RSSI: -59.0 dBm, Services: Environmental Sensing
    
    $ upyble config -t 9998175F-9A91-4CA2-B5EA-482AFC3453B9 -g
    upyble device settings saved globally!
    
  2. Follow services

$ upyble follow -s all
Following service: all
[Service] 180A: Device Information
	[Characteristic] 2A01: (read) | Name: Appearance
	[Characteristic] 2A29: (read) | Name: Manufacturer Name String
[Service] 180F: Battery Service
	[Characteristic] 2A19: (read,notify) | Name: Battery Level
		[Descriptor] 2902: (Handle: 19)
[Service] 181A: Environmental Sensing
	[Characteristic] 2A6E: (read,notify) | Name: Temperature
		[Descriptor] 2902: (Handle: 23)
15:35:28,813 [upyble@esp32-batt-temp] Battery Service [Battery Level] : 77.0 %
15:35:28,843 [upyble@esp32-batt-temp] Environmental Sensing [Temperature] : 56.67 °C
15:35:33,883 [upyble@esp32-batt-temp] Battery Service [Battery Level] : 76.0 %
15:35:33,913 [upyble@esp32-batt-temp] Environmental Sensing [Temperature] : 56.67 °C
15:35:38,954 [upyble@esp32-batt-temp] Battery Service [Battery Level] : 76.0 %
15:35:38,983 [upyble@esp32-batt-temp] Environmental Sensing [Temperature] : 56.67 °C
15:35:44,024 [upyble@esp32-batt-temp] Battery Service [Battery Level] : 71.0 %
15:35:44,053 [upyble@esp32-batt-temp] Environmental Sensing [Temperature] : 56.67 °C
^CDisconnected successfully

See more usage examples at EXAMPLES doc.


ABOUT

To see more information about upyble dependencies, requirements, tested devices, etc see ABOUT doc.