The Microbit_Magnetometer provides the ability to configure the BBC micro:bit’s on-board magnetometer and receive one or more magnetometer samples via the appropriate methods.
ReadMagnetometerBearing – Read a single bearing sample from the micro:bit. On successful read, the
MagnetometerBearingReceived event
will be run.ReadMagnetometerData – Read a single sample of magnetometer data from the micro:bit. On successful read, the
MagnetometerDataReceived event will be
run.ReadMagnetometerPeriod – Read the current report rate for the micro:bit magnetometer. After the period is read, it will
be received by the
MagnetometerPeriodReceived event.RequestMagnetometerBearingUpdates – Request notifications of changes in the micro:bit’s bearing. Changes in the bearing will be
reported at a rate determined by the last period value set by a call to
WriteMagnetometerPeriod. Bearing data
will be reported through the
MagnetometerBearingReceived event.RequestMagnetometerDataUpdates – Request notifications of changes in the micro:bit’s magnetometer. Changes in the magnetometer
will be reported at a rate determined by the last period value set by a call to
WriteMagnetometerPeriod. Magnetometer
data will be reported through the
MagnetometerDataReceived event.StopMagnetometerBearingUpdates – Stop receiving updates from the micro:bit’s magnetometer. Note that there may be pending
messages from the device that will still be reported through the
MagnetometerBearingReceived event.StopMagnetometerDataUpdates – Stop receiving updates from the micro:bit’s magnetometer. Note that there may be pending
messages from the device that will still be reported through the
MagnetometerDataReceived event.WriteMagnetometerPeriod – Use the WriteMagnetometerPeriod method to change how frequently the micro:bit
sends magnetometer data to App Inventor. The period is measured in milliseconds. According to
the micro:bit specification, valid values are 1, 2, 5, 10, 20, 80, 160 and 640 milliseconds.
Parameters:
Magnetometer_Period (number) —
The new magnetometer reporting period, in milliseconds.MagnetometerBearingReceived – The MagnetometerBearingReceived event is run whenever bearing samples are
received from the micro:bit. This is usually a result of performing a
read or
request operation. The bearing value is
reported as degrees relative to North.
Parameters:
bearing_value (number) —
The bearing from North, in degrees.MagnetometerDataReceived – The MagnetometerDataReceived event is run whenever magnetometer samples are
received from the micro:bit. This is usually a result of performing a
read or
request operation. The X, Y, and Z values are in
milli-teslas, and so should be scaled by 1/1000.
Parameters:
MagnetometerPeriodReceived – The MagnetometerPeriodReceived event is run after the micro:bit’s magnetometer
period is read from the device.
Parameters:
Magnetometer_Period (number) —
The current reporting interval for the micro:bit’s magnetometer, in milliseconds.WroteMagnetometerPeriod – The WroteMagnetometerPeriod event is run after the micro:bit reports its period
as requested by an earlier call to the
ReadAccelerometerPeriod method.
Parameters:
Magnetometer_Period (number) —
The reporting periodf or the micro:bit’s magnetometer, in milliseconds.