Thermometer

Periodically read thermometer 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 AMW106 Moray evaluation board, connected via the I2C interface to an SI7021 humidity and temperature sensor, such as supplied with the ASG001 Zentri Backpack.

Description

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

Usage Instructions

Open a ZentriOS serial terminal to the device. See Getting Started, Opening a ZentriOS Terminal.

This app requires no interaction.

Output to the ZentriOS terminal is similar to:

> Starting Thermometer App
Initialisation successful!
Getting data....
Temperature: 25.26 deg C
Getting data....
Temperature: 25.27 deg C
Getting data....
Temperature: 25.26 deg C
Getting data....
Temperature: 25.25 deg C
Getting data....
Temperature: 25.28 deg C

Implementation

zn_app_init

The call to sensor_init configures the sensor.

The call to zn_event_register_periodic registers the periodic event read_data.

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