Gyroscope

Periodically read gyroscope sensor data and display on a ZentriOS terminal.

API Features Demonstrated

Platforms

This app works on:

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 gyroscope sensor data and display on a ZentriOS terminal.

Usage Instructions

See Connecting a Zentri AMW106 to an InvenSense MPU9250.

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 Gyroscope App
Initialisation successful!
Getting data....
X: 1 deg/sec
Y: 0 deg/sec
Z: 1 deg/sec
Getting data....
X: -99 deg/sec
Y: -67 deg/sec
Z: -49 deg/sec
Getting data....
X: 4 deg/sec
Y: 10 deg/sec
Z: -9 deg/sec
Getting data....
X: -37 deg/sec
Y: -27 deg/sec
Z: 21 deg/sec

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_gyro_data.

read_gyro_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: