Unofficial library for sphero v2.
Project description
PySphero
This is an unofficial Sphero library for BLE toys.
The Sphero protocol is reverse-engineered using the official Sphero Edu application for Android and this library.
This code is tested only on Sphero Bolt. Probably it will work on the other BLE toys too.
Install the dependencies
For using this library need bluepy and libgtk2.0-dev.
# apt-get install libgtk2.0-dev
# pip install bluepy
# To use gatt BT stack, install it manually
# pip install gatt
Install
To install pysphero
use pip
:
# pip install pysphero
Example
from time import sleep
from pysphero.utils import toy_scanner
def main():
with toy_scanner() as sphero:
sphero.power.wake()
sleep(2)
sphero.power.enter_soft_sleep()
if __name__ == '__main__':
main()
Tips
While using gatt, if you are facing connection issues
# Connection failed: Device does not exist, check adapter name and MAC address.
You must check if your BLE device is known on your system list (thanks to bluez-tools).
# bt-device -l
If not, used bluetoothctl to do so.
sudo bluetoothctl
Agent registered
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# scan on
[CHG] Controller AB:CD:EF:12:34:56 Discovering: yes
[NEW] Device 12:34:56:78:90:AB (your Sphero toy)
[bluetooth]# exit
BLE device list must have been populated
Unknown
Packet contains sourceID and targetID. Their meaning is unknown.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pysphero-0.0.12.tar.gz
.
File metadata
- Download URL: pysphero-0.0.12.tar.gz
- Upload date:
- Size: 18.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26c407426c023815d14cdb205994ee4f343b2b6575877503b7e1719bf96c2db2 |
|
MD5 | 91d01fd661e944f9de08ec4acb56466f |
|
BLAKE2b-256 | 4726c14cf3e93582bafb079a888cfa7c8ad427356e2f8743e309f8019525c058 |