Magnetometer#

Hardware Interface#

Defined in namespace hal

#include <libhal/magnetometer.hpp>

class magnetometer#

Magnetic field strength sensing hardware abstraction interface.

Magnetometers are usually used for determining the strength of a magnetic field, or calculating compass headings. If the device that the magnetometer is mounted on, tends to move, or change its own orientation, then it is helpful to use an accelerometer or tilt sensor in order to determine appropriate heading for compass calculations.

Subclassed by hal::soft::inert_magnetometer

Public Functions

inline read_t read()#

Read the latest magnetic field strength sensed by the device.

Returns:

read_t - magnetic field strength data

struct read_t#

Result from reading the accelerometer.

Public Members

gauss x#

Magnetic field strength in the X axis, relative to the device’s reference frame.

gauss y#

Magnetic field strength in the Y axis, relative to the device’s reference frame.

gauss z#

Magnetic field strength in the Z axis, relative to the device’s reference frame.