4.2.1 BLE Sensor with Touch
WBZ351 Curiosity Board
Devices (Device): PIC32CX5109BZ31048(MCU) on WBZ351 module
Devices (Used, On-Board): CVD Touch, Analog Temperature Sensor, GREEN LED, User Button, User LED, USBUART converter
Hardware Block Diagram - Curiosity Board
Hardware Required
Tool |
Quantity |
---|---|
WBZ351 Curiosity Board | 1 |
QT7 XPRO Extension Board | 1 |
Micro usb cable | 1 |
Android/iOS Smartphone | 1 |
Software
TeratermSmartphone App
Microchip Bluetooth Data (MBD) iOS/Android app available in stores.Programming the precompiled hex file or Application Example
Programming the hex file using MPLABX IPE
Precompiled Hex file is located in
<Harmony Content Path>\wireless_apps_pic32cxbz3_wbz35\apps\ble\advanced_applications\ble_sensor_touch\hex\ble_sensor_touch.X.production.signed.hex
folder.Follow the steps mentioned here.
Caution: Users should choose the correct device and tool information.
Programming the Application using MPLABX IDE
Follow steps mentioned in of Running a Precompiled Example document.
Open and program the Application Example
ble_sensor_touch.x
located in<Harmony Content Path>\wireless_apps_pic32cxbz3_wbz35\apps\ble\advanced_applications\ble_sensor_touch\firmware
using MPLABX IDE.
<Harmony Content Path> how to find what is my Harmony Content Path.
Demo Description
This application demonstrates the capability of WBZ351 module to connect to a mobile phone through Bluetooth Low Energy (BLE). The GREEN LED on the Curiosity board can be controlled by mobile app. The WBZ351 device will also report the temperature data periodically to mobile phone through BLE. Similarly, the LED brightness can be controlled using Touch slider, button by connecting the QT7 XPRO add-on board to XPRO extension of curiosity board.The WBZ351 module will be a BLE peripheral device and will advertise on startup. The user can initiate the connection through mobile application. The advertisement payload holds the temperature information and the GREEN On/Off status.
Uses “BLE Sensor” sub app from the Microchip Bluetooth Data (MBD) mobile app for BLE demonstration:
Application is supported by iOS and Android OS
Available in respective app stores/play stores
When Connected(ING) to the application the BLUE color “User LED” will turn On:
Blinks the “User LED” with 500 ms blink interval when the device sending advertisement packets
Once connected, the “User LED” turns on solid
From the Smartphone App the following actions can be performed:
The GREEN LED can be switched On/Off from MBD mobile app
When LED is switched On, the GREEN LED Brightness can be changed from mobile app
From the WBZ351 module the following actions can be performed:
The GREEN LED can be switched On/Off from QT7 Touch Button. When LED is switched On, the GREEN LED Brightness can be changed using Touch Slider
The GREEN LED can be switched on/off by pressing the On board “User Button”:
When the “User Button” is pressed and released the GREEN LED is switched On with default color GREEN or the last stored color
When the “User Button” is pressed and released again, then the GREEN LED will be toggled from the previous state
Read the temperature sensor every 1 sec once and send the temperature value to mobile app when the temperature changes about 1 degree C
Testing
Install the Microchip Bluetooth Data (MBD) Smartphone App:
iOS/Android users can search for “Microchip Bluetooth Data” App in App Store and install
Enable Bluetooth on the Smartphone
Launch the MBD Smartphone App.
Supply power to WBZ351 Curiosity Board:
- Connect the QT7 Xplained Pro Extention board on Curiosity board extention as shown.
Connect a USB cable to the kit or a 4.2V Li-ion/Li-Po Battery. For more information refer to the Power Supply section of WBZ351 Curiosity Board User's Guide.
The User LED (blue (D5)) starts blinking on the Curiosity Board when the board is in advertisement mode.
UART Console Behavior:
- The application activity is shown as “Console Log” through on board UART-USB converter.
- Open Terminal (Example: Tera Term) to look for these logs - UART baud settings: 115200 8-N-1 without flow control.
- Control GREEN LED state On/Off as well as brightness from QT7 Touch Button/Slider.
-
Important:
If the QT7 XPRO board is not connected with WBZ351 curiosity board, by touching on curiosity board extention pins might cause the Touch detection. Hence Touch functionality is disabled by default.
To activate the Touch feature, press and hold USER BUTTON 1 (SW3) and then press the RESET button (SW1). Then release SW1 first and then release SW3.
-
Button 2 marked on QT7 XPRO board can switch On/Off the GREEN LED. Touch and release the Button 2. See the GREEN LED is On. A LED near to Button 2 will also glow.
-
The Slider can help to increase/decrease the brightness of GREEN LED. The lowest position will bring the brightness Low, and highest slider position will bring the GREEN LED brightness to High. The brightness are in the scale of 0 to 255.
-
Slide on the Touch slider and observe the GREEN LED brightness changes. The 6 LED's adjacent to Slider will also show the brightness level.
-
Touch and release the Button 2 and observe that GREEN LED is Off. All the Touch LED's also will be Off. Changing the slider position will not change the brightness until the LED is On by Button 2.
-
- Monitor LED state and Temperature from MBD Mobile App:
-
WBZ351 Curiosity Board starts in advertisement mode to advertise its presence on a smartphone and to allow access to LED on/off state and temperature sensor data.
-
Navigate through the Smartphone App as shown in the following figure to access the advertisement information.
-
- Control GREEN LED state On/Off as well as brightness from MBD App:
-
Click the device that shows up after initiating a scan to establish a connection with WBZ351 module.
Note:The GREEN LED state and brightness change by Touch button will get reflected in mobile app.
-
The User blue LED becomes solid once connection is established between the smartphone and WBZ351 module.
- Controls the GREEN LED state On/Off.
- This is greyed out and can not be changed as colour change is not supported. Only GREEN LED in RGB alone is controlled.
- Controls the brightness of GREEN LED when the LED is “On”.
-
Additional info
-
To disconnect the MBD Application running on your smart phone, you can do one of the following:
Press the reset button on WBZ351 Curiosity Board
Initiating a “Scan” on Smartphone App
Upon successful disconnection, the WBZ351 module starts in Advertisement.
Protocol Exchange
The communication protocol exchange between BLE sensor mobile app (BLE central) and WBZ351 module (BLE peripheral) is explained hereTouch (CVD) Configuration
This application implements the Touch peripheral function to control the GREEN LED brightness using QT7 XPRO extention. The details of Touch library component addition in the project and its configurations can be found here.