Tuesday, December 18, 2018

No more DRAW A CIRCLE

Bitty Data Logger users will probably have played with the micro:bit's magnetometer (AKA digital compass) at some point, as will many other micro:bit users, with or without the involvement of Bluetooth.

The magnetometer needs to be calibrated in the environment in which it is to be used, for accurate data to be acquired from it. Originally, simply including the MakeCode "Bluetooth magnetometer service" block was enough to both make the magnetometer data available over Bluetooth *and* initiate the calibration procedure automatically when the micro:bit code started. If you've seen this happen, you'll know that the old procedure starts with the text "DRAW A CIRCLE" scrolling across the micro:bit screen. A single LED then appears and by rotating the microbit with its edge facing upwards, you light each LED on the outer edge of the display. Once a complete "circle" has been drawn, calibration is complete and your micro:bit will continue starting up.

Here's a very simple MakeCode project that could be used with Bitty Data Logger to log magnetometer data:



Things changed in the latest release of the micro:bit firmware (known as the DAL). Now, calibration does not happen automatically. To calibrate your micro:bit's magnetometer you must now explicitly request this in code. There's a block available for just this purpose so you could, for example initiate magnetometer calibration when button A is pressed, like this:


This change may affect Bitty Data Logger users. Magnetometer data will not stream into the micro:bit, even with the right code on the micro:bit until you have calibrated it. Luckily it's possible to initiate calibration from within the Settings screen of Bitty Data Logger:


That's it! Happy data logging!

No comments:

Post a Comment

The Beginner's Guide to Bluetooth