If your PicoCalc has a Pico 2 W, it can now use a Bluetooth keyboard alongside its own.
The pairing is kept on the SD card, so any program built with the code finds the same keyboard. For programmers, it’s two lines of CMake and one call, btkbd_init(), and the keyboard’s keys then come through the normal keyboard reads, so most programs need nothing else. Details are in bluetooth/README.md in picocalc-extras.
So far it handles “classic” Bluetooth keyboards, and it’s been tested with a Logitech K380. I’d really like to hear how other keyboards fare, good or bad. btpair’s D key shows the details, and F5 saves the screen as text, which makes a report easy.
As before, I designed and tested it; Claude (Anthropic’s AI) wrote the code.
1 Like
Ideas for anyone who wants to take Bluetooth further
The keyboard code uses BTstack, which comes with the Pico SDK and is licensed for the Pico 2 W, and BTstack can do a lot more than read a keyboard. It ships with working examples for each of these, so none of them start from scratch:
- The PicoCalc as a Bluetooth keyboard for a phone or tablet: the reverse of what btpair does (BTstack’s
hid_keyboard_demo).
- A media remote: play, pause, skip and volume for a phone’s music (AVRCP). No audio needed.
- Caller ID and call buttons for a phone left in a drawer: show who’s calling, answer, hang up, dial (the hands-free profile,
hfp_hf_demo), and even pull in the phone’s contacts (PBAP). There’s no microphone, so you’d talk on the phone or a headset. Someone on YouTube built a Bluetooth “brick phone” along these lines to keep their smartphone out of reach while working. For the audio, they found a dedicated hands-free module worked far better than doing it in software.
- Bluetooth Low Energy keyboards, which the current code doesn’t support yet (BTstack’s
hog_host_demo).
The shared code in picocalc-extras/bluetooth is a working starting point: the radio, pairing kept on the SD card, and BTstack running in the background. If you build any of these, I’d love to hear about it.
3 Likes
I been test a Logitech K480 and it works fine
Thanks Giovanni, that’s great to hear. One question if you remember: after pairing, did it start typing straight away, or only after you restarted the PicoCalc? My K380 pairs but sometimes stalls on that first connection until a power cycle, and I’m trying to work out whether that’s the K380 or something more general. Which version were you running, the released btkbd or btpair?
Thanks for trying the K480. That helped pin down what was going on with my K380. picocalc-extras v1.2 is out: it adds BLE keyboards and fixes two BTstack bugs that made the K380 stall on its first connection. If you try it and anything misbehaves, F5 in btpair now saves a Bluetooth log you can send me.
In my tests, too, it would freeze after pairing, and I had to restart it to get it to work.
I’ll try out the new version in the next few days and let you know how it goes.
Hi, I tried the new version of btpair 1.2 with the Keyron K6 keyboard, which is supposed to be a BLE device. The pairing worked correctly, and I didn’t need to reset it. However, it doesn’t work with the “Diamond” app. I tried resetting it, but it still isn’t recognized.
Thanks for trying it, Giovanni, and good to hear the K6 pairs now without a restart: that’s the fix in 1.2. Diamond v0.3 was built with the older Bluetooth code, before BLE keyboards were supported, so it can’t use the K6 yet. Diamond v0.3.1-alpha is the same Diamond with btpair 1.2’s Bluetooth: diamond-bt.uf2 at
The pairing you made with btpair carries over, as long as the keyboard isn’t put into pairing mode again (a BLE keyboard comes back as a new one then, and needs pairing again with btpair).
Very well. I tried the new version and works fine. Thanks.
Great, thanks for testing it, Giovanni. I’ve added the Keyron K6 to the list of keyboards that work in the README.