In continuation to my earlier blog on [demonstrating wireless point-to-point out of the box connectivity based on SMAC]
This document demonstrates the simulation of the Heart rate sensor (emulating by connecting a potentiometer) using NXP Bluetooth Low Energy Software for the KW40Z wireless microcontroller platforms.
The starting point is to port an existing BLE example application project that is available in the current KW40Z Connectivity Software package.
This document covers installation of the software packages, hardware setup, build and usage of the provided demo applications.
The KW40Z is a highly-integrated single-chip device that enables Bluetooth Smart/Bluetooth Low Energy (BLE) v4.1 and IEEE 802.15.4-2011 RF connectivity for portable, extremely low-power embedded systems. Applications include portable health care devices, wearable sports and fitness devices, AV remote controls, computer keyboards and mice, gaming controllers, access control, security systems, smart energy and home area networks.
The KW40Z MCU integrates a 2.4 GHz transceiver supporting a range of FSK/GFSK and O-QPSK modulations, an ARM Cortex-M0+ CPU, 160 KB Flash and 20 KB SRAM, BLE Link Layer hardware, 802.15.4 packet processor, hardware security and peripherals optimized to meet the requirements of the target applications. The KW40Z has enough on-chip memory to concurrently run both a Bluetooth Low Energy stack and an IEEE 8021.5.4 MAC/PHY for multi-mode applications.
The platform features a composite USB device called OpenSDA which serves as debugger interface and as a USB-to-serial converter via a virtual COM port application. Several firmware images can be programmed on the OpenSDA device, such as these:
- developer.mbed.org/handbook/CMSIS-DAP
- segger.com/opensda.html
- http://www.pemicro.com/opensda/
Pre-requisite:
- FRDM-KW40ZFRDM-KW40Zwith CMSIS DAP Link bootloader(to perform openSDA drag and drop
Install the boot loader driver with OpenSDA_V2_1.bin from below segger link:
https://www.segger.com/downloads/jlinkopensda
- Smart phone with installed “Kinetis BLE Toolbox” Android app
- Installed KW40Z_Connectivity_Software_1.0.0.exe software package
Bluetooth Low Energy
The Software Development Package provides a Bluetooth Low Energy v4.1-compliant host stack and controller implementation with a set of GATT-based profiles and services implemented on top.
Bluetooth Low Energy Heart Rate Monitor (Reference Design)
The BLE Heart Rate Sensor is a portable device operated by a rechargeable battery. It includes the proper circuitry to obtain and process ECG signals for heart rate calculation. A SoC that includes a M0+ core microcontroller and a BLE radio acquires processes and reports the gathered information via BLE to an enabled Smartphone or device.
The ECG signal is obtained from the finger tips and processed by the Kinetis KW40Z SoC Then the user’s heart rate is calculated and transmitted to a smartphone application using BLE The reference design can be powered by a Li-Ion coin-cell battery Due to the low-power features of Kinetis KW40Z MCU a 3.6V 200mA/h Li-Ion coin-cell rechargeable battery can provide the power of up to 40 hours of continuous use The NXP MC34671MC34671 is in used as a battery charger solution for the device
The Heart Rate Sensor application implements a GATT server and the following profile and services: Heart Rate Profile v1.0
- Heart Rate Service v1.0
- Battery Service v1.0
- Device Information Service v1.1
The application behaves as a GAP peripheral node. It enters the GAP General Discoverable Mode and waits for a GAP central node to connect. When the collector configures notifications, the sensor starts sending heart rate measurements every second.
Each of Wireless Connectivity Stack comes with a list of demo applications and driver examples ready to be compiled and run.
Link to Bluetooth Heart Rate Monitor Reference Design|NXP
Note:
We are showing just a“simulation(actual sensors are not there and they are emulated by potentiometer of Heart rate sensor with Freedom board FRDM-KW40ZFRDM-KW40Z
FRDM-KW40ZFRDM-KW40Zand BLE HEART Monitor reference design are different
Steps involved:
The first step is to download the “KW40Z_Connectivity_Software_1.0.1.exe” installer
Download and install KW40Z_Connectivity_Software_1.0.0.exe from below link
The package contains various demo applications that can be used to get a first feel for the software.
After installing installer automatically creates or updates the KSDK13_FWK524_PATH environment variable required by the KW40Z BLE projects. Once the above steps are performed, you can start using the Bluetooth Low Energy Demo Applications.
After installing, you will find below resources inside the connectivity software path:
The example projects are been located in below link:
C:\Freescale\KW40Z_Connectivity_Software_1.0.1\ConnSw\examples\bluetooth
There are two options in executing the Heart rate sensor example project:
1) Build and Run a Bluetooth LE Example Application.
or
2) Flashing a Binary Image File without Using an IDE. Use the precompiled binary provided by KW40Z Connectivity Software which is located at
“C:\Freescale\KW40Z_Connectivity_Software_1.0.1\ConnSw\tools\binaries”
To go with option-1 we need to have a copy of the IAR Embedded Workbench for ARM version 7.40.2 or higher. This connectivity software package does not include support for any other toolchains.
I am going with option-2 i.e to flash a pre-existing binary image file and demonstrate using android app “Kinetis BLE Toolbox”
The KW40Z connectivity software package contains in the ConnSw\tools\binaries folder a series of pre-compiled binary applications that can be flashed onto a development board.
In order to flash the corresponding binaries to the FRDM-KW40ZFRDM-KW40Z board the best approach is to use the OpenSDA on-board interface CMSIS-DAP Mass Storage Device functionality by simply dragging and dropping the binary image in the mass storage drive exposed by this OpenSDA firmware
Plug on the frdm-kw40z hardware board to your computer via usb cable
After plugging in you will get the below AutoPlay DAPLink window (you board gets detect as DAPLink drive)
Open the DAPLink folder and copy paste the “BLE_HRS_frdmkw40z.bin” file from the location “C:\Freescale\KW40Z_Connectivity_Software_1.0.1\ConnSw\tools\binaries”
Now paste this file into the DAPLink folder as shown below:
Now your target board is ready to execute
I have installed Kinetis BLE Toolbox Android app on Samsung smart phone as shown below:
After flashing the board, the sensor is put in deep sleep (all 4 LEDs are off). To wake up and start advertising, press the SW4 button. When in GAP Discoverable Mode, the LED1 is on. When the central node connects to the peripheral, LED1 remains solid.
To disconnect the node, hold the SW4 button pressed for 2-3 seconds. The node re-enters the GAP Discoverable Mode when the SW4 button is pressed again.
By default the heart rate value format is set to 8 bits and the contact status is on.
To vary the heart rate value, use the potentiometer on the back of the board.
To make the Heart Rate Sensor visible, press the SW4 button to start sending advertisements. The sensor name “FSL_HRS” shows on the device when its scanning is active. A solid LED1 indicates a successful connection between the two devices. Hold the SW4 button pressed for 2-3 seconds anytime to get the sensor to initiate disconnect.
If configured, the sensor notifies the application with heart rate measurements every second. Also, the battery level and various device information is exposed for reading.
Follow below steps to execute the project
Step-1:
To make the Heart Rate Sensor visible, press the SW4 button.
Step-2: open the Kinetis BLE Toolbox app in your smart phone, for the first time it will ask its Bluetooth to switch on
Now your app will look like as shown below:
Step-3: Click on Heart rate icon
Step-4: You can find “FSL_HRS” Bluetooth device on the App as shown below:
Click on FSL_HRS to select this device. Then you can see the status as connected as shown below:
Step-5: Now vary the potentiometer to see the sensor value as shown below:
You can see the corresponding graphical value on the app as shown below:
The Video output execution is shown in below video:
Happy Executing the Heart rate sensor example using app on smart phone on KW40Z (wireless MCU)...