Version 2 of the BBC micro:bit was released very recently. It has new capabilities, such as a speaker and microphone for audio capture and sound generation but it retains many of the things we came to know and love in V1 of the micro:bit, including Bluetooth. Most importantly, it has way more memory.
Thanks for the Memory
V1 had only 16Kb RAM and the standard runtime code known as the DAL plus the Bluetooth software stack from Nordic Semiconductor consumed 14kb or 15kb depending on configuration. This meant that you were only able to contribute very small amounts of your own code, a serious constraint.
V2 of the micro:bit has a whopping 128Kb RAM which has tremendous implications for what you can get done with the new device. Not only will you be able to write much more substantial code for your micro:bit, but you will be able to use Bluetooth in previously impossible ways. Micro:bit V1 could only act as a Bluetooth GAP peripheral whereas V2 can be a GAP peripheral, GAP central or.... both (see references below). In simple terms this will mean that micro:bits will be able to communicate directly with other micro:bits. And Bluetooth has far better range and reliability than the vanilla "radio" technology.
Compatibility
Significantly, the hex file format has been changed and the new format is known as the universal hex. This format works on both V1 and V2 micro:bit hardware (subject to memory limitations and hardware features used). So, the best course of action is to rebuild your old scripts so that you have hex files which will work with both micro:bit versions. That's what I'll be doing with the Bitty Software open source code examples.
But how can you tell which type a hex file is? It's quite simple. A v1 format hex file is about 700Kb in size but an equivalent universal hex format file will be about 1.8Mb.
Codal
Micro:bit V2 uses new runtime code known as Codal. It serves the same purpose as the DAL on a V1 micro:bit, providing drivers and a framework and APIs which make it easier to create your own applications.
Bluetooth
Micro:bit V1 had a pretty old version of Bluetooth Low Energy (LE), compliant with version 4.1 of the Bluetooth core specification which was released back in 2013. Bluetooth has changed in many ways since then.
Micro:bit V2 has a version Bluetooth LE which is compatible for version 5.1 of the Bluetooth core specification. Version 5.0 added some amazing capabilities to Bluetooth including the ability to communicate over a range of about 1 kilometre using something called the LE Coded PHY. Such capabilities are optional however, so a device with 5.0 or later compatibility does not necessarily have all of the features in that or later releases. From a quick glance at the documentation for the Nordic Semiconductor S113 stack which is used by Codal, it looks like the long range LE Coded PHY capability is not supported. That's a shame.
The collection of Bluetooth services that constitute the device's Bluetooth profile, have been reimplemented in Codal. This is great news because it means applications such as Bitty Data Logger will continue to work unchanged and unaware that the remote device is a V2 or V1 micro:bit.
I did some basic testing and was largely successful. I found and reported a few glitches which I expect will be fixed soon. Here are my test results:
Issue 28: bluetooth all services hex file has an issue (long standing, I imagine). The magnetometer service does not transmit compass bearing data. The sample code probably needs to calibrate the magnetometer at start-up.
OK: accelerometer service
OK: magnetometer service (provided the magnetometer is calibrated first)
Issue 26: button service - Notifications rarely sent on button A long press. Worked once on button B but never subsequently. A single click and release (short press) works and transmits a value of 1 as expected, but holding the button down for 2 seconds or more (long press) does not transmit anything (expected a value of 2).
OK: event service
OK: LED service
OK: Temperature service
OK: UART service
Issue 27: IO Pin service not working - Switching on pin 0 (and perhaps others) does not work. Tested by connecting an LED to pin 0 and then writing 0x000101000200 to the pin data characteristic.
Conclusion
Reference Material
micro:bit V1 technical specifications: https://tech.microbit.org/hardware/1-5-revision/
micro:bit V2 technical specifications: https://tech.microbit.org/hardware/
GAP peripheral? GAP central? Bluetooth roles and micro:bit
Makecode beta site for V2 micro:bit hex file generation: https://makecode.microbit.org/beta#
Bitty Software code examples: https://github.com/bittysoftware
Lancaster University DAL source: https://github.com/lancaster-university/microbit-dal
Lancaster University Codal source: https://github.com/lancaster-university/codal-microbit-v2
Nordic Semiconductor S113 Bluetooth LE stack: https://infocenter.nordicsemi.com/index.jsp?topic=%2Fstruct_nrf52%2Fstruct%2Fs113.html
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.