Skip to content

Latest commit

 

History

History

Thermocouple

Thermocouple Examples

This example has simple code for reading temperature from a thermocouple click board and also an application that sends temperature data to Initial State.

Hardware

Plug the click board into the mikroBUS header on the Fieldbus Gateway. This example code uses the hardware.spiBCAD peripheral exposed by the mikroBUS header.

Please note: This example code can be modified for use with a different imp by simply changing the spi configuration. MOSI is not necessary to read the thermocouple.

Basic Usage - Read Temperature from a Thermocouple

This example shows how to read temperature from a thermocouple click board and log the result. It shows how to configure the SPI and has one function readThermoCoupleTemp(), which will return the temperature as an integer. The thermocouple runs on 3.3v. The range of the thermocouple is -270 to 1372 degrees celsius.

Instructions

This example has side device code only.

Simple Application - Send Temperature Data to Inital State

This example sends temperature data read from a thermocouple click board to the cloud service Initial State.

Device Code

The device code builds on the Basic Usage example to create a Thermocouple class. It uses the FiedbusGateway HAL (Hardware Abstraction Layer) to configure the hardware. The example then uses an Application class to read temperature from the Thermocouple and send it to the agent in a loop. The application also sets up a listener that recieves a blink message from the agent that will blink one of the LEDs on the Fielbus Gateway.

Agent Code

The Agent code listens for temperature readings from the device. When a reading is received the temperature is checked to see if it is above a threshold. Then both the tempertature and temperatureAlert are sent to Initial State. When the data is received by Initial State a blink message is then sent to the device.

Instructions