0% found this document useful (0 votes)
36 views1 page

GPM 61

This document discusses code for reading temperature data from an ANT+ sensor. It describes several variables used in the program, including DEVICE_TYPE and PERIOD. The TempeData class represents temperature values and parses sensor data pages to extract the current temperature. The parseCurrentTemp() function receives ANT messages and combines the least and most significant bytes to get the temperature reading in degrees. It explains how the two byte integer range maps to actual temperature values that can be negative. The initialize() function configures the device and radio channel to communicate with the temperature sensor.

Uploaded by

Pop
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views1 page

GPM 61

This document discusses code for reading temperature data from an ANT+ sensor. It describes several variables used in the program, including DEVICE_TYPE and PERIOD. The TempeData class represents temperature values and parses sensor data pages to extract the current temperature. The parseCurrentTemp() function receives ANT messages and combines the least and most significant bytes to get the temperature reading in degrees. It explains how the two byte integer range maps to actual temperature values that can be negative. The initialize() function configures the device and radio channel to communicate with the temperature sensor.

Uploaded by

Pop
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

There are several variables used throughout this program.

The
DEVICE_TYPE is the type of device with ANT+ technology we’re
working with, and the PERIOD refers to how often the sensor is
expected to send new data. The other variables relate to the con‐
figuration of the radio, and the data received from it (the data
variable).

This class represents the value from the sensor that we’re inter‐
ested in: the current temperature.

The data from the sensor comes back as data pages. This class
reads through each page, parsing the payload contained in the
page, and extracts the current temperature from it. The parse()
function calls the parseCurrentTemp() function and stores the
value it gets from it into the currentTemp field of the TempeData
variable, data.

This function receives the ANT message and extracts the cur‐
rent temperature from it. The ANT message comes in as an
array of bytes; elements 6 and 7 are the least significant and
most significant byte that, when combined, give us a two-byte
integer that contains the temperature.
The range of numbers that can be represented in two bytes is 0
to 65,535. Divided by 100, that gives us a range of 0 to 655.35
degrees, in .01 degree increments. However, temperatures can
be negative, so the values 0 to 32767 represent 0 to 327.67
degrees, while the values 32768 to 65535 represent the range
-327.67 to 0 degrees. Technically, 0 represents positive 0 and
65535 represents negative 0, but they are numerically equiva‐
lent.

This function assigns a radio channel for the ANT network,


then configures the device to communicate with the tempe sen‐
sor. It then creates a new TempeData object and stores it in the
data variable.

The open() function reopens the ANT communications chan‐


nel.

This closeSensor() function closes the ANT communications


channel.

Read Data from a Sensor | 49

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy