Temperature Sensor Broadcast Code Example

Table of Contents

Introduction

The temperature sensor broadcast code example is a simple code example that leverages the integrated temperature sensor on the MSP432 to broadcast the temperature over BLE. This code example has the advantage over the Sensors BoosterPack code example in the sense that it does not require any additional sensor booster pack. This project leverages the MSP432’s floating point unit to provide both Celsius and Fahrenheit temperature data.

Hardware Prerequisites

Temperature Sensor Broadcast requires the standard configuration of an MSP-EXP432P401R LaunchPad with an attached BOOSTXL-CC2650 BoosterPack. This hardware configuration is shown in the below image:

MSP432 LaunchPad with CC2650 BoosterPack

Note that early versions of MSP432 silicon may not have temperature calibration data calibrated. If the part number on the MSP432 starts with “XMS” instead of “MSP432” then this example may return bogus data.

Software Prerequisites

This code example has been tested with IAR Embeded Workbench 7.80.3 and Code Composer Studio v7.1. For more information on how to import this project into your IDE workspace and build/run, please refer to the main user’s guide.

Service/Profile Table

Purpose UUID Format Unit Properties Profile Source
Temperature Broadcast (C) 0xFFE1 IEEE-754 32-bit floating point °C Notification temperature_profile.c
Temperature Broadcast (F) 0xFFE2 IEEE-754 32-bit floating point °F Notification temperature_profile.c

Usage

Once the Temperature Sensor Broadcast code example starts the output to the terminal will notify the user of initialization and then set the state of the application to idle.

Temperature Sensor Initialization

In idle mode, the application is in a low power mode and not actively advertising. In order to start advertising, the S1 switch on the LaunchPad needs to be pressed. The S1 switch can be found on the left side of the LaunchPad as pictured below:

Button Positions

Once the S1 button is pressed, the device will start advertising itself with a device name of “MSP432 Thermometer”. Also note that once advertising (and while connected) the LED on the MSP432 LaunchPad’s LED1 pin is turned red to signify activity.

LED indicating activity

After connecting to the MSP432 Thermometer device, the terminal screen should print that the peer was connected and also print the ID of the peer:

Connection Log

At this point the device as connected and successfully negotiated the connection details. Scrolling down past the product information (this might be different depending on your client) there should be a list of two different characteristics and their corresponding properties/values (these are described in detail in the following sections):

List of characteristics

Temperature (C) (UUID: 0xFFF1)

The first characteristic is a notification characteristic that broadcasts temperature readings approximately at a period of five seconds. Note that the temperature readings are reported in floating point value and the mobile client may need to be updated to display floating point legibly.

Temperature broadcast in C

Temperature (F) (UUID: 0xFFF2)

The second characteristic is the same characteristic as the first one, however broadcasting in Fahrenheit:

Temperature broadcast in F

SBL Update

Updating the firmware on the CC2650 BoosterPack uses the SBL libraries to invoke the CC2650’s bootloader and transfer the new firmware over serial. For Temperature Sensor Broadcast, the method to trigger this invocation is to press and release the S2 button on the LaunchPad. Note that in order to trigger the firmware update, no active BLE device can be connected. Once S2 has been pressed, LED2 on the LaunchPad will toggle red to signal the BSL start:

SBL LED

The console screen will print the status of the firmware update as well as signal when the update has finished. At the end of the update the status of the update will be printed over the serial port and the MSP432 will reboot itself:

SBL log