Home TI-Nspire Authoring TI-Nspire Scripting HQ Scripting Tutorial - Lesson 33

           


  

Scripting Tutorial - Lesson 33: BLE - Measuring Heart Rate

  

Lesson 30: Welcome to Bluetooth (BLE)

Supplement: Working with Scripts on the iPad

Lesson 31: BLE - Create your own TI-Nspire Remote

Lesson 32: BLE - Measuring Temperature with the Vernier Go Wireless Temp (UPDATED to include Vernier GoLink support)

Lesson 33: BLE - Measuring Heart Rate

Lesson 34: BLE - Measuring Temperature with the TI Sensor Tag

Lesson 35: BLE - Build Your Own Weather Station with the TI Sensor Tag

Lesson 36: BLE - Exploring Movement and Position with the TI Sensor Tag

Lesson 37: Lua, LaunchPads and BLE: Making Music via BLE

Lesson 38: Lua, LaunchPads and BLE: Real world data at your fingertips: Light, Ultrasonic Motion and more...

Lesson 39: Lua, LaunchPads and BLE: Build your own BLE Robot for under $USD40

  

Download supporting files for this tutorial

Download this page in PDF format

Texas Instruments TI-Nspire Scripting Support Page

       
  

Back in an earlier lesson of this sequence, you were introduced to the fundamentals of BLE using the Vernier Go Wireless Temp probe. You might remember how simple this process was, in comparison to the TI Sensor Tag. Where the SensorTag requires two-way communication between BLE device and script, the Vernier probe was happy just to broadcast temperature data. If the user knew the correct UUID, this could be readily captured.

In this lesson, we build another simple script, this time for a heart rate monitor. We will be using the Scosche RHYTHM+ but what is important to note is that the manufacturers of BLE heart rate monitors have agreed upon common UUIDs, and this means that your script should be much more versatile.

For such a script, then, you should need to know only two things - the UUID value, and the calculation by which the raw data is converted into usable values.

Starting with the Vernier script from Lesson 31, why not try converting this one yourself?

Use '2A37' as the UUID, and for the heart rate BPM value, if value = characteristic:getValue() then use local data = ble.unpack("u16",value), and heartBPM = data/256 (NOT 128 as for the Vernier probe!).

 
 

platform.apilevel = '2.5'

screen = platform.window
w = screen:width()
h = screen:height()

pcall(function () require 'bleCentral' end)

require "color"
local bleState = ''
local bleStatus = 'Stand by'
local peripheralName = ''
local myPeripheral = nil
local characteristicsFound = 0

-- RHYTHM+ Init Variables

local POLARH7_HRM_MEASUREMENT_CHARACTERISTIC_UUID = '2A37'
local heartBPM = nil
local nameCheckList = {'RHYTHM'}
local nameList = {'RHYTHM+'}

 
 

 
 

  
  

If you have a Heart Rate Monitor and Nspire iPad App, you may test this entire script by copying and pasting from this web page into the TI-Nspire Lua Script Editor.

Hopefully, by this stage, you are getting a feel for scripting for BLE using TI-Nspire and Lua. There are many opportunities for creative and interesting activities beginning with simple data collection based on physical personal data, suitable for mathematics classes from the middle years through to seniors. Of course, this is ideal STEM material, and will come to life in science and engineering classes, providing readily accessible real-world applications for content at all levels.

  
  

Back to Top

  

Home TI-Nspire Authoring TI-Nspire Scripting HQ Scripting Tutorial - Lesson 33