Can the Pi Zero W automatically connect a bluetooth device?

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
dubyazero
Posts: 13
Joined: Fri Mar 24, 2017 7:15 pm

Can the Pi Zero W automatically connect a bluetooth device?

Post by dubyazero »

I basically want to set up a Zero W to have the built in bluetooth automatically connect a specific device - a keyboard in this case - on bootup. The idea being to run Kodi using the keyboard as control (which needs automatic connection) while leaving the single usb port free for a usb stick with media.

Is there a way to do so? There are so many things I can think of to do with the Zero W and DietPi if this can work.
User avatar
k-plan
Posts: 416
Joined: Sun Feb 28, 2016 5:28 pm

Re: Can the Pi Zero W automatically connect a bluetooth devi

Post by k-plan »

dubyazero wrote:I basically want to set up a Zero W to have the built in bluetooth automatically connect a specific device - a keyboard in this case - on bootup.
Untested option (only by google-searching)

How can I auto-connect keyboard after reboot?

The keyboard can only be connected over Bluetooth and the Pi is not setup to auto-connect to on boot.
After doing the initial pairing you can setup a simple cron task to automate this by following the steps below:

1.) From command line type

"bluetoothctl"
and make a note of keyboard MAC address.

2.) Run crontab with the -e flag to edit the cron table:

"crontab -e"
The first time you run crontab you’ll be prompted to select an editor; if you are not sure which one to use, choose “nano” by pressing Enter.

3.) To connect bluetooth keyboard automatically every time Raspberry Pi starts up, write:

@reboot echo "connect MAC-ADDRESS-OF-KEYBOARD" | bluetoothctl
Change MAC-ADDRESS-OF-KEYBOARD with the real MAC address of your bluetooth keyboard you noted Step 1.

Save and Exit crontab.

You should now be able to auto-connect to keyboard after reboot without a need of a input.

Source:
http://nexdock.com/support-raspberry-pi/

If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal and Bitcoin.
Post Reply