The keyboard works wonderfully over bluetooth. However, how can I decrease its power consumption even more? The answer is simple, and has been used with many products before, such as logitech keyboards: dongles.
With standard bluetooth, one of the halves of the keyboard acts as a central, whereas the other one acts as a peripheral. The peripheral is mostly asleep and only wakes up when an interrupt is triggered by a keypress. The central, however, has to listen to the peripheral to be ready when it sends its keypresses. It can then relay the information to the computer. The disadvantage of such a system is that the peripheral will last much longer than the central, as it is asleep most of the time. A solution, however, is to program a dongle as a central, and have both halves act as peripherals. This provides many advantages:
- As both halves are peripherals, they are both asleep most of the time, which increases the battery life by almost an order of magnitude
- The dongle, being plugged into the computer, acts as a USB keyboard. This means that the keyboard can still be used on computers where bluetooth is not available, or in certain situations where bluetooth cannot be used (e.g. in BIOS)
First, to test the firmware, I used the left half of the first iteration as a dongle:
It's however not a very compact solution...
In the end, I chose to go with the nRF52840 MDK USB Dongle by Makerdiary. What is great about this dongle is that it has an exposed reset button, as well as broken out SWD pads.
The integrated UF2 bootloader can only be accessed by pressing the reset button while inserting the board. Not very practical, if you ask me. Moreover, it is not compatible with the UF2 file generated when compiling the ZMK firmware, probably because of different partitions (softdevice, flash, ...). To solve both of these issues, I simply built and compiled the Adafruit nRF52 UF2 bootloader for the MDK nRF52840 dongle. It can then be flashed to the dongle with a J-Link after unlocking it with nRF Command Line Tools. I've also observed that the bootloader needed to be compiled with softdevice for it to work correctly.