Features: BLE Cycling Sensor
Features: BLE Cycling Sensor
Features
Cycling Power Profile in CP Sensor and Broadcaster role operation
Cycling Speed and Cadence Service
DeepSleep mode support
LED status indication
General Description
This example demonstrates the Cycling Speed and Cadence Service (CSCS) and Cycling Power
Service (CPS). Cycling Speed and Cadence simulates a cycling activity and reports the
simulated cycling speed and cadence data to a BLE central device using CSCS. Cycling Power
simulates cycling power data and reports the simulated data to a BLE central device using CPS.
Project Configuration
The example project consists of the following components: BLE, Global Signal, UART, digital
output pin, digital input pin. The Global Signal Reference and WDT_Interrupt component is used
for the ISR configuration from Watchdog Timer. This timer works over low power deep sleep
mode, therefore used as a general timer for simulation purpose. The output pins are used to
reflect the line signal output on the LED. The input pin is configured to the resistive pull up mode
and is used to wake device from low power hibernate mode. The top design schematic is shown
in Figure 1.
Cypress Semiconductor Corporation • 198 Champion Court • San Jose, CA 95134-1709 • 408-943-2600
BLE Cycling Sensor PSoC® Creator™ Example Project
The BLE component is configured as Cycling Power Profile in CP Sensor and Broadcaster role
operation. Cycling Speed and Cadence service is added to CPP. Both services cover full sensor
functionality required for cycling sensor.
Page 2 of 8
PSoC® Creator™ Example Project BLE Cycling Sensor
Page 3 of 8
BLE Cycling Sensor PSoC® Creator™ Example Project
Page 4 of 8
PSoC® Creator™ Example Project BLE Cycling Sensor
Project Description
The project demonstrates BLE component functionality configured as a Cycling sensor.
One callback function (AppCallBack()) is required to receive generic events from BLE Stack.
CyBle_GappStartAdvertisement() API is called after CYBLE_EVT_STACK_ON event to start
advertising with the packet shown in Figure 4. CpsCallback() callback function receives events
from the Cycling Power Service and CscsCallback() callback function receives events from the
Cycling Speed and Cadence Service.
On advertisement timeout, the system remains in the hibernate mode. Press the mechanical
button on CY8CKIT-042 BLE (SW2) to wake up the system and start re-advertising. BLE
subsystem and CPU enters into low power Deep-Sleep mode between connection and
advertising intervals. BLE subsystem automatically wakes up to maintain connection and
advertising data transfer.
The instantaneous power, accumulated torque, wheel revolution and accumulated energy are
simulated and send when notification of the Cycling Power Measurement characteristic is
enabled by Client. Sensor Location characteristic is configures to “Top of shoe” and it could be
updated by Client through write to Cycling Power Control Point characteristic with “Update
Sensor Location” Op Code.
The measurement interval value is set to 1 second.
To indicate that the device is advertising, the green LED is blinking. The red LED is turned on
after disconnection to indicate that no Client is connected to the device. When a Client is
connected successfully, both red and green LEDs are turned off.
The project simulates Cycling Power Measurements characteristic with instantaneous power,
accumulated torque, cumulative wheel revolution and accumulated energy values. Following
table contains example of simulated data and expected calculation results.
Last
Expected Accumulated Expected
Instantaneous Expected Cumulative Wheel
Accumulated Instantaneous Energy Accumulated
Power Accumulated Wheel Event
Torque Speed Value Energy
[W] Torque Revolution Time
[km/h] [kJ] [kJ]
[1/2048s]
1 200 64960 2030.0 1000 63000 N/A 65532 65532
2 201 65280 2040.0 1008 65048 60.48 65534 65534
3 202 64 2050.0 1016 1560 60.48 0 65536
4 203 384 2060.0 1024 3608 60.48 2 65538
5 204 704 2070.0 1032 5656 60.48 4 65540
Page 5 of 8
BLE Cycling Sensor PSoC® Creator™ Example Project
The Power Vector characteristic is simulated with cumulative crank revolutions and last crank
event time values. Example is shown in the table below.
Expected
Cumulative Crank Last Wheel Event Time Instantaneous
Revolutions [1/1024s] Cadence [rpm]
1 65470 9300 N/A
2 65530 10324 60
3 54 11348 60
4 114 12372 60
5 174 13396 60
Refer to Cycling Power Profile and Cycling Speed and Cadence Profile specifications for
calculation details.
Expected Results
You can use CySmart app on a Windows PC, Android or iOS BLE-compatible device as Client
for connection to Cycling Sensor.
To use CySmart Windows application as Cycling Power and Cycling Speed Client:
Connect the CySmart BLE dongle to a USB port on the PC.
Launch CySmart app and select connected dongle in dialog window.
Reset development kit to start advertising by pressing SW1 button.
Click Start Scan button to discover available devices.
Select Cycling Sensor in the list of available devices and connect to it.
Click Pair, then Discover All Attributes, then Read All Characteristics, and finally
Enable All Notifications in CySmart app.
Enable notifications for Cycling Power and/or for Cycling Speed and Cadence:
Page 6 of 8
PSoC® Creator™ Example Project BLE Cycling Sensor
Page 7 of 8
BLE Cycling Sensor PSoC® Creator™ Example Project
© Cypress Semiconductor Corporation, 2009-2015. The information contained herein is subject to change without notice. Cypress Semiconductor Corporation assumes no responsibility for the
use of any circuitry other than circuitry embodied in a Cypress product. Nor does it convey or imply any license under patent or other rights. Cypress products are not warranted nor intended to
be used for medical, life support, life saving, critical control or safety applications, unless pursuant to an express written agreement with Cypress. Furthermore, Cypress does not authorize its
products for use as critical components in life-support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress
products in life-support systems application implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges.
PSoC® is a registered trademark, and PSoC Creator™ and Programmable System-on-Chip™ are trademarks of Cypress Semiconductor Corp. All other trademarks or registered trademarks
referenced herein are property of the respective corporations.
Any Source Code (software and/or firmware) is owned by Cypress Semiconductor Corporation (Cypress) and is protected by and subject to worldwide patent protection (United States and
foreign), United States copyright laws and international treaty provisions. Cypress hereby grants to licensee a personal, non-exclusive, non-transferable license to copy, use, modify, create
derivative works of, and compile the Cypress Source Code and derivative works for the sole purpose of creating custom software and or firmware in support of licensee product to be used only in
conjunction with a Cypress integrated circuit as specified in the applicable agreement. Any reproduction, modification, translation, compilation, or representation of this Source Code except as
specified above is prohibited without the express written permission of Cypress.
Disclaimer: CYPRESS MAKES NO WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, WITH REGARD TO THIS MATERIAL, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress reserves the right to make changes without further notice to the materials described herein.
Cypress does not assume any liability arising out of the application or use of any product or circuit described herein. Cypress does not authorize its products for use as critical components in life-
support systems where a malfunction or failure may reasonably be expected to result in significant injury to the user. The inclusion of Cypress’ product in a life-support systems application
implies that the manufacturer assumes all risk of such use and in doing so indemnifies Cypress against all charges.
Use may be limited by and subject to the applicable Cypress software license agreement.
Page 8 of 8