All Projects → sraodev → bluetooth-iot-service-python

sraodev / bluetooth-iot-service-python

Licence: other
This application connects two devices over Bluetooth and allows one to send messages to the other using json. Raspberry Pi Bluetooth interfacing with Linux via RFCOMM BT network

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to bluetooth-iot-service-python

py-bluetooth-utils
Python module containing bluetooth utility functions, in particular for easy BLE scanning and advertising
Stars: ✭ 60 (+160.87%)
Mutual labels:  bluetooth, ble, bluez, pybluez
bluer
BlueR — Official BlueZ Bindings for Rust
Stars: ✭ 43 (+86.96%)
Mutual labels:  bluetooth, rfcomm, bluez
ble2mqtt
A BLE to MQTT bridge
Stars: ✭ 60 (+160.87%)
Mutual labels:  bluetooth, ble, bluez
GoFIT SDK Android
GoFIT SDK for Android — GOLiFE 手環 App 介接 SDK
Stars: ✭ 32 (+39.13%)
Mutual labels:  bluetooth, ble, iot-device
spherov2.py
Unofficial Python API for all Sphero toys
Stars: ✭ 36 (+56.52%)
Mutual labels:  bluetooth, ble
ioBroker.ble
Monitor Bluetooth Low Energy beacons
Stars: ✭ 39 (+69.57%)
Mutual labels:  bluetooth, ble
ble2mqtt
Bluetooth to MQTT bridge, add your bluetooth-capable (including controllable) devices to your smart home
Stars: ✭ 46 (+100%)
Mutual labels:  bluetooth, ble
daydream-node
Quick Node.js module to connect to the Daydream controller and receive all the data
Stars: ✭ 17 (-26.09%)
Mutual labels:  bluetooth, ble
ble
Bluetooth Low Energy for Linux / macOS
Stars: ✭ 264 (+1047.83%)
Mutual labels:  bluetooth, ble
Gormsson
Harald "Bluetooth" Gormsson was a king of Denmark and Norway.
Stars: ✭ 25 (+8.7%)
Mutual labels:  bluetooth, ble
SmartSpin2k
Transform your spin bike into a Smart Trainer!
Stars: ✭ 88 (+282.61%)
Mutual labels:  bluetooth, ble
app-xyo-nodejs
XYO Archivist/Diviner CLI
Stars: ✭ 41 (+78.26%)
Mutual labels:  bluetooth, ble
coBlue
Use Bluetooth Low Energy for remote commands, file transfer, Based on bluez Bluetooth protocol stack (BLE Terminal)
Stars: ✭ 41 (+78.26%)
Mutual labels:  bluetooth, ble
Gesture-Detecting-Macro-Keyboard
Glorified Bluetooth macro keyboard with machine learning (TensorFlow Lite for Microcontrollers) running on an ESP32.
Stars: ✭ 68 (+195.65%)
Mutual labels:  bluetooth, ble
rpi3-wifi-conf
A simple Python script to configure wifi over bluetooth for a Raspberry Pi 3
Stars: ✭ 112 (+386.96%)
Mutual labels:  python-script, bluetooth
sblendid
A JavaScript Bluetooth Low Energy (BLE) Library
Stars: ✭ 60 (+160.87%)
Mutual labels:  bluetooth, ble
mi-lamp-re
💡 Reverse Engineering Notes for the Yeelight Bedside Lamp (BLE)
Stars: ✭ 35 (+52.17%)
Mutual labels:  bluetooth, ble
ChromeBluetooth
Demo of a "Stress Display" using Chrome Bluetooth. Reads Heart-rate data, and displays "stress" colors to a smart bulb. (Uses a SBT5007 smart bulb)
Stars: ✭ 14 (-39.13%)
Mutual labels:  bluetooth, ble
ganglion-ble
Web Bluetooth client for the Ganglion brain-computer interface by OpenBCI
Stars: ✭ 27 (+17.39%)
Mutual labels:  bluetooth, ble
contact-tracer
A prototype contact tracer app for COVID-19 pandemic response
Stars: ✭ 50 (+117.39%)
Mutual labels:  bluetooth, ble

Bluetooth Service (PyBluez) with RFCOMM sockets

This application connects two devices over Bluetooth and allows one to send messages to the other using json. The sending device runs bleClient.py, and the receiving device runs bleServer.py

Getting Started

How to setup a bluetooth server in a Raspberry Pi so an Linux can connect to it.

Pre-quisites

This python-script uses Bluez, Linux's Bluetooth protocol stack, we'll be using PyBluez, a Python API for accessing the bluetooth resources using the bluez protocol.

Installation

sudo apt-get install python-pip python-dev ipython

sudo apt-get install bluetooth libbluetooth-dev

sudo apt-get install bluez-utils blueman

sudo apt-get install bluez python-bluez

sudo pip install pybluez`

You've installed the Python 2 version of the bluez bindings. Either run the script using python2 or install the Python 3 bindings. Since they aren't packaged, you would need to install them using pip:

sudo python3 -m pip install pybluez`

Setup your Raspberry Pi

Make your device discoverable

sudo hciconfig hci0 piscan

Scanning for devices run the inquiry example:

sudo python inquiry.py

Running the Bluetooth Server on RaspberryPi:

sudo python bleServer.py

Running the Bluetooth Client on Linux box:

sudo python bleClient.py

Known Issues

Traceback (most recent call last):
  File "/usr/share/doc/python-bluez/examples/simple/rfcomm-server.py", line 20, in <module>
    profiles = [ SERIAL_PORT_PROFILE ],
  File "/usr/lib/python2.7/dist-packages/bluetooth/bluez.py", line 176, in advertise_service
    raise BluetoothError (str (e))
bluetooth.btcommon.BluetoothError: (2, 'No such file or directory')

Possible fixes

Make sure you are using sudo when running the python script Make sure you have the serial profile loaded. How to enable the serial profile.

As it turns out, the culprit is bluetoothd, the Bluetooth daemon. Using SDP with bluetoothd requires deprecated features for some silly reason, so to fix this, the daemon must be started in compatibility mode with bluetoothd -C (or bluetooth --compat).

You need to run the Bluetooth daemon in 'compatibility' mode. Edit /lib/systemd/system/bluetooth.service and add '-C' after 'bluetoothd'. Reboot.

sudo sdptool add SP

Or

Find location of bluetooth.service by:

systemctl status bluetooth.service

Then edit bluetooth.service and look for ExecStart=/usr/libexec/bluetooth/bluetoothd Append --compat at the end of this line, save, and then run

service bluetooth start

If all goes well, you should be able to successfully run

sudo sdptool browse local

Finally, reset the adapter:

sudo hciconfig -a hci0 reset

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated. Please read the contribution guidelines first.

Reference

Bluetooth Programming with Python 3

Bluetooth programming with Python - PyBluez

Bluetooth for Programmers

Bluetooth Python extension module

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].