I just bought XIAO-ESP32-C3 off of DigiKey, and after playing around with it for a bit, I cannot get anything related to a keyboard to work, more specifically the ESP32-BLE-Keyboard library found here and the default Arduino keyboard library (used default example sketches and slightly modified versions of those examples to no prevail). My original plan was to make a USB macro keyboard that has both USB HID and BLE Keyboard connectivity, but I just realized that this microcontroller doesn’t support USB HID in the first place, so that is a mistake on my part. I can live without USB connectivity, however, as long as the Bluetooth works.
I have already set up the Arduino IDE for this board, and confirmed that it works with a few sketches using the GPIO pins.
Does anyone have any tips on this? If this microcontroller doesn’t support anything I need, what is another good alternative? (other requirements are a 3.7v battery connection with charging circuit, at least 8 GPIO pins, and USB type C connector.) I obviously would prefer to use what I already have on hand if possible, but I would like this option just in case.
Thanks in advance for your help, and please let me know if you need anything else.
Hi there,
Yes, Digikey is a good source for seeed parts also. Now as far as the old demo’s , You probably used the latest BSP 3.01 or? Just roll back to the older BSP for the Older demo’s to work. 2.0.14 is one I use to do that testing. Espressif changed BSP to be more compatible with ESP-IDF and a lot of the original API’s and compatibilities got removed.
HTH
GL PJ
If it’s the keyboard emulation stuff , that will be the case, check the search for other threads, I posted some compiler output so the Lib version can be seen.
Thank you. Where can I find the BSP, and how do I check the current version? I come from older 8 bit Arduinos, so these new microcontrollers are a learning curve for me.
I read the getting started guide Here but didn’t find anything about a BSP. It does mention the firmware though, so is this the same thing? If so, do I find the older versions on the GitHub pages with the current firmware?
Ok ok. I didn’t realize that was called BSP (I’m pretty familiar with the boards manager btw), I thought it was for on-device firmware lol.
I tried both 2.0.11 and 2.0.14, and both gave me the same issue as before. I can connect to the bluetooth, but it repeatedly connects and disconnects, throwing authentication errors in the serial monitor. I tried this on both windows and linux and the same thing happens.
Should I try using the ESP-IDF for programming instead of arduino IDE? Not sure where to start if I have to do that though.
Thanks for the help
Edit: I tried playing around with a generic ESP-32S I had laying around, and the code compiles and runs on there without issue. This is something specific to either the xiao or more likely the C3 chip. (can’t use this microcontroller since its too big and doesn’t have usb c or a battety connector, hence the need for the xiao)
Hi there,
SO post your code , let’s see what you missed. It should work if the pins are correct.
I would stay away from the ESP-IDF unless you want to get lost in the documentation.
Arduino IDE ver 2.0.x all work fine.
The C3 is slightly different, than the ESP32 generic so stands to reason its not plug and play code.
only the BSP’s matter when dealing with older demos. 2.0.11 and .14 are good testers. I use 2.0.11 mostly because it just works. I do update to the later ones if there’s a reason but only if it’s required for other compatibility.
HTH
GL PJ
I did some more digging, and apparently this is a common issue with the C3 chip in general. There is a protocol difference between the standard ESPs and the C3s, and that has to be defined in the librarys BleKeyboard.cpp file. Thanks to @maker114 on github for answering the issues awhile ago, and thanks to google for letting me find it lol. Heres the entire thread for future readers.
More specifically, I edited line 130 in the BleKeyboard.cpp file of the library as follows:
//pSecurity->setAuthenticationMode(ESP_LE_AUTH_REQ_SC_MITM_BOND);//default security protocol. Changed for C3 as per github issue reccomendation
pSecurity->setAuthenticationMode(ESP_LE_AUTH_BOND);//for ESP32-C3 Protocol
Also, after changing this, I was able to use the current BSP (3.0.2) without issue. This protocol difference also explains the weird authentication errors I was getting in the serial monitor. Thanks again for the help