Due to high demand expect some shipping delays at this time, orders may not ship for 1-2 business days.

Bluefruit SPI Friend as HID Device with Rapsberry Pi Pico
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Bluefruit SPI Friend as HID Device with Rapsberry Pi Pico

by AngryChihuahua04 on Fri Feb 26, 2021 9:05 pm

Hello to all! I am semi-new to the world of coding and electronics as I have some experience with normal Raspberry Pi boards, but new to microcontroller boards such as the Pico. I am also very new to Bluetooth commands and protocol, so please forgive me for any errors in the code. I am currently working on a project that uses the Pico with the Adafruit Bluefruit SPI Friend. The main purpose is to have some buttons connected to the Pico and to broadcast the HID commands such as VOLUME+ and VOLUME- from the Pico to a connected device. I have it wired up to the Pico as shown in the picture below.
resized pico.jpg
Picture of the wired up Pico
resized pico.jpg (452.64 KiB) Viewed 142 times

I am able to successfully power the board and broadcast a new name for the Bluetooth module. However, the error I am running into is when I use the AT+BLEKEYBOARDEN=1 command. When this command is run, the console gets an error that says "RuntimeError ('Timed out waiting for a response.',) If this command is omitted, my device can connect to it just fine. Any suggestions on how to fix this?
Code: Select all | TOGGLE FULL SIZE
import board
import busio
import digitalio
from adafruit_bluefruitspi import BluefruitSPI
import time

spi_bus = busio.SPI(clock=board.GP2, MOSI=board.GP3, MISO=board.GP4)
cs = digitalio.DigitalInOut(board.GP5)
irq = digitalio.DigitalInOut(board.GP6)
rst = digitalio.DigitalInOut(board.GP1)
bluefruit = BluefruitSPI(spi_bus, cs, irq, rst, debug=False)

connected = None

print("Initializing Bluetooth module")
bluefruit.command_check_OK(b"AT+FACTORYRESET", delay=1)

#Print Bluetooth Module Info
print(str(bluefruit.command_check_OK(b"ATI"), "utf-8"))


#Main Loop
while True:
        print("Waiting for a connection to Bluefruit LE Connect ...")
        # Wait for a connection ...
        dotcount = 0
        while not bluefruit.connected:
            print(".", end="")
            dotcount = (dotcount + 1) % 80
            if dotcount == 79:

        connected = bluefruit.connected
        print("Connected to Glasses!")

        connection_timestamp = time.monotonic()
        while True:
            # Check our connection status every 3 seconds
            if time.monotonic() - connection_timestamp > 3:
                connection_timestamp = time.monotonic()
                if not bluefruit.connected:

    except RuntimeError as e:

Any help is appreciated!

Posts: 18
Joined: Mon Aug 19, 2019 6:26 pm

Re: Bluefruit SPI Friend as HID Device with Rapsberry Pi Pic

by adafruit2 on Wed Apr 07, 2021 1:35 pm

hmm we really dont recommend this technique anymore, but it sounds like its mostly working. did you try upgrading the module BLE firmware via the app?

Site Admin
Posts: 19959
Joined: Fri Mar 11, 2005 7:36 pm

Please be positive and constructive with your questions and comments.