Main Content

readMagneticField

Read data from the magnetometer sensor on BBC micro:bit board

Description

example

[data] = readMagneticField(obj) reads data from the Magnetometer sensor connected to the BBC micro:bit board, specified as a microbit object.

Examples

collapse all

Create a connection to the BBC micro:bit hardware connected to the COM4 port., and read the magnetic field along the three axes of the BBC micro:bit hardware.

>>m = microbit('COM4');
>>[data] = readMagneticField(m)

data = 

   -33.2 -9.8 -134.8

Input Arguments

collapse all

BBC micro:bit hardware connection, specified as a microbit object, created with the microbit function.

Output Arguments

collapse all

Three-dimensional data of the surrounding magnetic field intensity. The data is measured along the x-, y-, and z- axes, relative to the position of the board.

Data Types: double

Version History

Introduced in R2017b