Magnetometer
Periodically read magnetometer sensor data and display on a ZentriOS terminal.
- SDK directory:
apps/sensors/magnetometer
- Zentri App Store:
ZENTRI-SEMAGNETO
API Features Demonstrated
Platforms
This app works on:
- AMW004 - Zentri Mackerel evaluation board - additional hardware required
- AMW106 - Zentri Moray evaluation board - additional hardware required
- NXP-SCCK - NXP Secure Cloud Connectivity Kit - additional hardware required
Requirements and Prerequisites
This app requires a ZentriOS device, such as an AMWx06-E03 (Moray), connected via the I2C interface to a MPU-9250 gyroscope sensor from Invensense.
Description
Periodically read magnetometer sensor data and display on a ZentriOS terminal.
Usage Instructions
See Connecting a Zentri AMW106 to an InvenSense MPU-9250.
Open a ZentriOS serial terminal to the device. See Getting Started, Opening a ZentriOS Terminal.
Build, download and run the app. It displays a message similar to the following on the ZentriOS terminal:
Starting Magnetometer App
Initialisation successful!
Getting data....
X: -27 uT
Y: -1 uT
Z: -90 uT
Getting data....
X: -28 uT
Y: -1 uT
Z: -89 uT
Getting data....
X: -28 uT
Y: -2 uT
Z: -90 uT
where X/Y/Z values reflect periodic sensor readings.
Implementation
zn_app_init()
- The call to sensor_init configures the sensor.
- The call to zn_event_register_periodic registers the periodic event
read_magn_data
.
read_mag_data()
- The call to sensor_has_new_data determines whether new data is ready.
- If data is available, sensor_get_data reads the data. The data is formatted and logged to the ZentriOS terminal.
Source
See: