Issue
I want to connect two Raspberry Pi's with each other over Bluetooth. Next, I want to send a command (in Python) to the other Raspberry Pi.
I want to use this for some home automation things for example to send a temperature from one pi via bluetooth to the other, without Wi-Fi.
I have been googling this for a very long time and couldn't find a good tutorial which worked for me. Thanks.
Solution
To connect two raspberry pi devices first you need to install following packages:
- connman
- pi-bluetooth
- bluetooth
- bluez
- python-bluez
Check if Bluetooth is enabled with command "hciconfig -a". Example output when Bluetooth is TURNED OFF:
hci0: Type: Primary Bus: UART
BD Address: B8:27:EB:9D:51:6B ACL MTU: 1021:8 SCO MTU: 64:1
DOWN
RX bytes:668 acl:0 sco:0 events:34 errors:0
TX bytes:423 acl:0 sco:0 commands:34 errors:0
Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH SNIFF
Link mode: SLAVE ACCEPT
You can enable it with a command "connmanctl enable bluetooth". Now when you check again with "hciconfig -a" you should see something like this
hci0: Type: Primary Bus: UART
BD Address: B8:27:EB:9D:51:6B ACL MTU: 1021:8 SCO MTU: 64:1
UP RUNNING
RX bytes:1385 acl:0 sco:0 events:75 errors:0
TX bytes:1193 acl:0 sco:0 commands:75 errors:0
Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH SNIFF
Link mode: SLAVE ACCEPT
Name: 'raspberrypi'
Class: 0x6c0000
Service Classes: Rendering, Capturing, Audio, Telephony
Device Class: Miscellaneous,
HCI Version: 4.1 (0x7) Revision: 0x8b
LMP Version: 4.1 (0x7) Subversion: 0x6119
Manufacturer: Broadcom Corporation (15)
To pair both raspberries follow instructions from the section "Using the Command Line" on this site
If you want to communicate using python you can look at the code in this repository
Answered By - Renard Korzeniowski