Skip to main content

Magnetometer

Magnetometer

A magnetometer is a device that measures magnetic field or magnetic dipole moment.

To get started using it, you must use KmpMagnometer. To subscribe to changes to the device's magnetometer data, we invoke the startListening function. We can then process the results in our app.


_5
KmpMagnometer.startListening {
_5
val x = it.first
_5
val y = it.second
_5
val z = it.third
_5
}

To stop listening to acc changes, we use the function stopListening. It's important to deactivate the listener, so the component doesn't continue to broadcast magnetometer data changes to our app.


_1
KmpMagnometer.stoplistening()

Any Setup Required?

None