ItsyBitsy NRF52840 Express - BLE Keyboard issues

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
williecorto
 
Posts: 7
Joined: Thu Nov 02, 2023 2:22 pm

ItsyBitsy NRF52840 Express - BLE Keyboard issues

Post by williecorto »

I followed the tutorial at https://learn.adafruit.com/ble-hid-keyb ... s-and-code using the ItsyBitsy NRF52840 Express. It worked, but only when it was connected to a USB port on a PC and a data connection was made. I tried powering it with a few different TP4056 modules, a 3.7V lipo battery pack, and several USB chargers and got no BLE activity at all. BLE worked consistently after mounting the device or using cat to display serial output. It successfully connected to every device I had available, and the buttons worked as expected.

I also tested the device using an arduino sketch with similar BLE keyboard capabilities, and the problem remained.

I'm not sure what else to try at this point. Any ideas or pointers would be welcome.

Thanks

User avatar
mikeysklar
 
Posts: 17153
Joined: Mon Aug 01, 2016 8:10 pm

Re: ItsyBitsy NRF52840 Express - BLE Keyboard issues

Post by mikeysklar »

Can you run try a simple blink example to see if CircuitPython is running correctly when powered by a "dumb" USB plug or a LiPo?

Is there anything else connected to the ItsyBitsy?

Code: Select all

import board
import digitalio
import time

led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT

while True:
    led.value = True
    time.sleep(0.5)
    led.value = False
    time.sleep(0.5)

User avatar
williecorto
 
Posts: 7
Joined: Thu Nov 02, 2023 2:22 pm

Re: ItsyBitsy NRF52840 Express - BLE Keyboard issues

Post by williecorto »

Thanks for replying.

I have two buttons attached to pins 10 and 11 with a 10k pull up resistor on each button going back to the 3v pin, and I have a TP4056 module attached to bat and ground. Blinking the LED works when powered by the TP4056 module or a USB charger.

User avatar
mikeysklar
 
Posts: 17153
Joined: Mon Aug 01, 2016 8:10 pm

Re: ItsyBitsy NRF52840 Express - BLE Keyboard issues

Post by mikeysklar »

Thank you for doing the blink test.

What version of CircuitPython and library bundle are you running?

Are you able to run the example code unmodified without any buttons attached to the ItsyBitsy while over USB? If that works can you try the same thing on USB or battery power?

A few of these simple experiments should help pin down where the issue is coming from.

User avatar
williecorto
 
Posts: 7
Joined: Thu Nov 02, 2023 2:22 pm

Re: ItsyBitsy NRF52840 Express - BLE Keyboard issues

Post by williecorto »

It's currently running Circuitpython 8.2.7 with the 8x bundle. I also tried 9.0.0-alpha4 with similar results.

The unmodified script isn't really useful for testing here, so I adjusted it to send keystrokes automatically when connected. But I found that it exhibited the same behavior after the buttons were removed.

Perhaps it's time to try a new board.

Thanks again.

User avatar
mikeysklar
 
Posts: 17153
Joined: Mon Aug 01, 2016 8:10 pm

Re: ItsyBitsy NRF52840 Express - BLE Keyboard issues

Post by mikeysklar »

Looking at the guide for the ItsyBitsy nRF52840 Express there is a final page about a known bug with using the high speed SPI interface from a Battery. That is pretty different from your BLE not working with battery, but worth acknowledging.

Can you post a photo of how you are connecting the battery and charging modules? This chip wants to be connected?

Are you current on the bootloader 0.7.0?

User avatar
williecorto
 
Posts: 7
Joined: Thu Nov 02, 2023 2:22 pm

Re: ItsyBitsy NRF52840 Express - BLE Keyboard issues

Post by williecorto »

I had desoldered the first device by the time I read this post, so I don't have any pics of that to share. But I have gone on to purchase another ItsyBitsy NRF52840 express, a Seeed Studio XIAO nRF52840 Sense, and a Feather nRF52840 Express as was used in the original project. All three devices exhibit the exact same behavior when powered via gpio bat/gnd or USB without data (i.e. USB power adapter or a 'power only' cable). I have tried bootloaders 0.7.0 and 0.8.0 on all three Adafruit boards, and 0.8.0 on the Seeed device.

I did misstate the problem in an earlier post, but only slightly. The devices all advertise / connect / pair to any ble capable central device like an Android phone or a PC when powered by any source. But they only send keystrokes when connected via USB to a PC. I don't have the proper JST connector for the port on the Feather Express, but a few of those should arrive today. So I plan to try that when I get home this evening.

This is the Feather Express connected to a 3.7v lipo: https://imgur.com/fcOJhcz

User avatar
mikeysklar
 
Posts: 17153
Joined: Mon Aug 01, 2016 8:10 pm

Re: ItsyBitsy NRF52840 Express - BLE Keyboard issues

Post by mikeysklar »

I can try to reproduce your issue if you want to provide some minimum viable code to start with.

User avatar
williecorto
 
Posts: 7
Joined: Thu Nov 02, 2023 2:22 pm

Re: ItsyBitsy NRF52840 Express - BLE Keyboard issues

Post by williecorto »

That would be most welcome, as I can't help feeling that I may be missing something important. Thank you.

The current script has been trimmed down a bit, and just sends (or is supposed to send) "q" repeatedly.

Code: Select all

import time
import board
from digitalio import DigitalInOut, Direction, Pull
import adafruit_ble
from adafruit_ble.advertising import Advertisement
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.standard.hid import HIDService
from adafruit_ble.services.standard.device_info import DeviceInfoService
from adafruit_hid.keyboard import Keyboard
from adafruit_hid.keyboard_layout_us import KeyboardLayoutUS
from adafruit_hid.keycode import Keycode

hid = HIDService()

device_info = DeviceInfoService(software_revision=adafruit_ble.__version__,
                                manufacturer="Adafruit Industries")
advertisement = ProvideServicesAdvertisement(hid)
advertisement.appearance = 961
scan_response = Advertisement()
scan_response.complete_name = "CircuitPython HID"

ble = adafruit_ble.BLERadio()

k = Keyboard(hid.devices)

# Start Advertising
if not ble.connected:
    ble.start_advertising(advertisement, scan_response)

# Main Loop
while True:    
    k.send(Keycode.Q)        
    time.sleep(0.5)

User avatar
mikeysklar
 
Posts: 17153
Joined: Mon Aug 01, 2016 8:10 pm

Re: ItsyBitsy NRF52840 Express - BLE Keyboard issues

Post by mikeysklar »

Okay, this is a good start. If I can repeat this tomorrow with my ItsyBitsy nRF52840 we can start a github issue.

User avatar
mikeysklar
 
Posts: 17153
Joined: Mon Aug 01, 2016 8:10 pm

Re: ItsyBitsy NRF52840 Express - BLE Keyboard issues

Post by mikeysklar »

I was able to reproduce the issue you are seeing.

My ItsyBitsy had a legacy bootloader 0.2.13.

I updated with the Arduino IDE to 0.6.2 and manual drop of the UF2 image to 0.8.0.

Code: Select all

sklarm@grazie Downloads % cat /Volumes/ITSY840BOOT/INFO_UF2.TXT
UF2 Bootloader 0.8.0 lib/nrfx (v2.0.0) lib/tinyusb (0.12.0-145-g9775e7691) lib/uf2 (remotes/origin/configupdate-9-gadbb8c7)
Model: Adafruit ItsyBitsy nRF52840 Express
Board-ID: nRF52840-ItsyBitsy-revA
Date: Sep 29 2023
SoftDevice: S140 6.1.1
Ran you minimum viable code with:

Code: Select all

CircuitPython 8.2.8 
Lib Bundle: 2023-11-16 for adafruit_ble + adafruit_hid 
Executes without output to REPL and once paired with iOS device when I touch the bottom text input box I see the q's.

IMG_2196.jpeg
IMG_2196.jpeg (215.68 KiB) Viewed 872 times

As soon as I move the micro-USB data cable that I am powering the ItsyBitsy with from my computer to a "dumb wall plug" I'm no longer able to see the characters transfer.

Looks like a viable issue for the CircuitPython github repo. Are you comfortable opening it or would you like me to?

User avatar
williecorto
 
Posts: 7
Joined: Thu Nov 02, 2023 2:22 pm

Re: ItsyBitsy NRF52840 Express - BLE Keyboard issues

Post by williecorto »

I have created a bug report for the issue. Thank you for taking the time to reproduce it.

https://github.com/adafruit/circuitpython/issues/8672

User avatar
danhalbert
 
Posts: 5127
Joined: Tue Aug 08, 2017 12:37 pm

Re: ItsyBitsy NRF52840 Express - BLE Keyboard issues

Post by danhalbert »

This turned out to be an adafruit_hid library bug, and is fixed by https://github.com/adafruit/Adafruit_Ci ... D/pull/122. You can test the changes, or wait for the library release if you want.

User avatar
mikeysklar
 
Posts: 17153
Joined: Mon Aug 01, 2016 8:10 pm

Re: ItsyBitsy NRF52840 Express - BLE Keyboard issues

Post by mikeysklar »

@danhalbert,

Thank you for the super fast patch.

I was able to download the merged changes and confirm that my iOS device saw the q's coming through when powered by a "dumb" USB power source.

This is for @williecorto in case he would like to try. Since the merge has already occured there probably is no need to switch branches or pull the PR, just the git clone is fine.

Code: Select all

git clone https://github.com/adafruit/Adafruit_CircuitPython_HID.git
cd Adafruit_CircuitPython_HID
#git checkout -b ble-device-no-wait
#git pull origin pull/122/head
cp -pr adafruit_hid /Volumes/CIRCUITPY/lib 

User avatar
danhalbert
 
Posts: 5127
Joined: Tue Aug 08, 2017 12:37 pm

Re: ItsyBitsy NRF52840 Express - BLE Keyboard issues

Post by danhalbert »

Thanks for testing! This fix is now released as adafruit_hid version 6.0.2 and will be updated in the bundle tonight.

Locked
Please be positive and constructive with your questions and comments.

Return to “Itsy Bitsy Boards”