Bluetooth
At present, basic BLE functionality is available. More features will be implemented in the near future, such as pairing. This page will be updated in line with these features.
Full info on bluetooth can be found within Bluetooth page of the Firmware API Reference.
Scan for BLE Devices
Scan for all of the advertising devices within range of the scanning device.
bluetooth.start_scan(10) # starts scanning and stop after 10 seconds
bluetooth.start_scan(-1) # starts scanning indefinitely until bluetooth.stop_scan() is calledRaw Data from a BLE Device
A quick usage example that scans and prints the raw data from advertisements.
from network import Bluetooth
bluetooth = Bluetooth()
bluetooth.start_scan(-1) # start scanning with no timeout
while True:
print(bluetooth.get_adv())Connect to a BLE Device
Connecting to a device that is sending advertisements.
Connect to a BLE Device and Retrieve Data
Connecting to a device named 'Heart Rate' and receiving data from it’s services.
Retrieve the Name & Manufacturer from a BLE Device
Using resolve_adv_data() to attempt to retrieve the name and manufacturer data from the advertiser.
Last updated