pic24fj xlp bluetooth le iot demo user’s guideww1.microchip.com/downloads/en/devicedoc/pic24fj iot...

23
2016 Microchip Technology Inc. PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide

Upload: vuongdiep

Post on 07-Sep-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

2016 Microchip Technology Inc.

PIC24FJ XLP Bluetooth LE IoT Demo

User’s Guide

Page 2: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

Information contained in this publication regarding deviceapplications and the like is provided only for your convenienceand may be superseded by updates. It is your responsibility toensure that your application meets with your specifications.

Note the following details of the code protection feature on Microchip devices:• Microchip products meet the specification contained in their particular Microchip Data Sheet.

• Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the intended manner and under normal conditions.

• There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data Sheets. Most likely, the person doing so is engaged in theft of intellectual property.

• Microchip is willing to work with the customer who is concerned about the integrity of their code.

• Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not mean that we are guaranteeing the product as “unbreakable.”

Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of ourproducts. Attempts to break Microchip’s code protection feature may be a violation of the Digital Millennium Copyright Act. If such actsallow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.

Trademarks

The Microchip name and logo, the Microchip logo, AnyRate, dsPIC, FlashFlex, flexPWR, Heldo, JukeBlox, KeeLoq,

MICROCHIP MAKES NO REPRESENTATIONS ORWARRANTIES OF ANY KIND WHETHER EXPRESS ORIMPLIED, WRITTEN OR ORAL, STATUTORY OROTHERWISE, RELATED TO THE INFORMATION,INCLUDING BUT NOT LIMITED TO ITS CONDITION,QUALITY, PERFORMANCE, MERCHANTABILITY ORFITNESS FOR PURPOSE. Microchip disclaims all liabilityarising from this information and its use. Use of Microchipdevices in life support and/or safety applications is entirely atthe buyer’s risk, and the buyer agrees to defend, indemnify andhold harmless Microchip from any and all damages, claims,suits, or expenses resulting from such use. No licenses areconveyed, implicitly or otherwise, under any Microchipintellectual property rights unless otherwise stated.

Microchip received ISO/TS-16949:2009 certification for its worldwide headquarters, design and wafer fabrication facilities in Chandler and Tempe, Arizona; Gresham, Oregon and design centers in California and India. The Company’s quality system processes and procedures are for its PIC® MCUs and dsPIC® DSCs, KEELOQ® code hopping devices, Serial EEPROMs, microperipherals, nonvolatile memory and analog products. In addition, Microchip’s quality system for the design and manufacture of development systems is ISO 9001:2000 certified.

page 2

KeeLoq logo, Kleer, LANCheck, LINK MD, MediaLB, MOST, MOST logo, MPLAB, OptoLyzer, PIC, PICSTART, PIC32 logo, RightTouch, SpyNIC, SST, SST Logo, SuperFlash and UNI/O are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.

ClockWorks, The Embedded Control Solutions Company, ETHERSYNCH, Hyper Speed Control, HyperLight Load, IntelliMOS, mTouch, Precision Edge, and QUIET-WIRE are registered trademarks of Microchip Technology Incorporated in the U.S.A.

Analog-for-the-Digital Age, Any Capacitor, AnyIn, AnyOut, BodyCom, chipKIT, chipKIT logo, CodeGuard, dsPICDEM, dsPICDEM.net, Dynamic Average Matching, DAM, ECAN, EtherGREEN, In-Circuit Serial Programming, ICSP, Inter-Chip Connectivity, JitterBlocker, KleerNet, KleerNet logo, MiWi, motorBench, MPASM, MPF, MPLAB Certified logo, MPLIB, MPLINK, MultiTRAK, NetDetach, Omniscient Code Generation, PICDEM, PICDEM.net, PICkit, PICtail, PureSilicon, RightTouch logo, REAL ICE, Ripple Blocker, Serial Quad I/O, SQI, SuperSwitcher, SuperSwitcher II, Total Endurance, TSHARC, USBCheck, VariSense, ViewSpan, WiperLock, Wireless DNA, and ZENA are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.

SQTP is a service mark of Microchip Technology Incorporated in the U.S.A.

Silicon Storage Technology is a registered trademark of Microchip Technology Inc. in other countries.

GestIC is a registered trademarks of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of Microchip Technology Inc., in other countries.

All other trademarks mentioned herein are property of their respective companies.

© 2016, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved.

ISBN:

2016 Microchip Technology Inc.

Page 3: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

PIC24FJ IoT DEMO USER’S GUIDE

Table of Contents

Preface ........................................................................................................................... 5Chapter 1. Introduction

1.1 Overview ...................................................................................................... 111.2 PIC® Microcontrollers with XLP Technology ................................................ 111.3 Microchip RN4020 Module ........................................................................... 111.4 Android Application ...................................................................................... 12

Chapter 2. Hardware2.1 Hardware Requirements .............................................................................. 132.2 Hardware Connections ................................................................................. 15

Chapter 3. Demo Instructions3.1 Installing Android Application on SmartPhone or Tablet .............................. 173.2 Establishing Connection between Android Application and RN4020 Module ..

173.3 LED Control .................................................................................................. 193.4 Switch Status ................................................................................................ 193.5 128-bit AES Encryption ................................................................................ 203.6 128-bit AES Decryption ................................................................................ 20

Chapter 4. Power SavingWorldwide Sales and Service .................................................................................... 23

2016 Microchip Technology Inc. DS00000A-page 3

Page 4: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

PIC24FJ IoT Demo User’s Guide

DS00000A-page 4 2016 Microchip Technology Inc.

Page 5: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

PIC24FJ IoT DEMO USER’S GUIDE

Preface

INTRODUCTIONThis preface contains general information that will be useful to know before using the PIC24FJ IoT Demo. Topics discussed in this preface include:• Document Layout• Conventions Used in this Guide• Warranty Registration• Recommended Reading• The Microchip Web Site• Development Systems Customer Change Notification Service• Customer Support• Document Revision History

DOCUMENT LAYOUTThis user’s guide describes how to use the PIC24FJ IoT Demo. The document is orga-nized as follows:• Chapter 1. “Introduction” – This chapter introduces the reader to the PIC24FJ

IoT Demo.• Chapter 2. “Hardware” – This chapter discusses the hardware requirements and

their connections for the demo.• Chapter 3. “Demo Instructions” – This chapter provides instructions to

establish connection between the Android application and the RN4020 module.• Chapter 4. “Power Saving” – This chapter discusses the power saving aspect of

the demo.

NOTICE TO CUSTOMERS

All documentation becomes dated, and this manual is no exception. Microchip tools and documentation are constantly evolving to meet customer needs, so some actual dialogs and/or tool descriptions may differ from those in this document. Please refer to our web site (www.microchip.com) to obtain the latest documentation available.

Documents are identified with a “DS” number. This number is located on the bottom of each page, in front of the page number. The numbering convention for the DS number is “DSXXXXXA”, where “XXXXX” is the document number and “A” is the revision level of the document.

For the most up-to-date information on development tools, see the MPLAB® IDE on-line help. Select the Help menu, and then Topics to open a list of available on-line help files.

2016 Microchip Technology Inc. DS00000A-page 5

Page 6: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

PIC24FJ IoT Demo User’s Guide

CONVENTIONS USED IN THIS GUIDEThis manual uses the following documentation conventions:

DOCUMENTATION CONVENTIONSDescription Represents Examples

Arial font:Italic characters Referenced books MPLAB® IDE User’s Guide

Emphasized text ...is the only compiler...Initial caps A window the Output window

A dialog the Settings dialogA menu selection select Enable Programmer

Quotes A field name in a window or dialog

“Save project before build”

Underlined, italic text with right angle bracket

A menu path File>Save

Bold characters A dialog button Click OKA tab Click the Power tab

N‘Rnnnn A number in verilog format, where N is the total number of digits, R is the radix and n is a digit.

4‘b0010, 2‘hF1

Text in angle brackets < > A key on the keyboard Press <Enter>, <F1>Courier New font:Plain Courier New Sample source code #define START

Filenames autoexec.bat

File paths c:\mcc18\h

Keywords _asm, _endasm, static

Command-line options -Opa+, -Opa-

Bit values 0, 1

Constants 0xFF, ‘A’

Italic Courier New A variable argument file.o, where file can be any valid filename

Square brackets [ ] Optional arguments mcc18 [options] file [options]

Curly braces and pipe character: { | }

Choice of mutually exclusive arguments; an OR selection

errorlevel {0|1}

Ellipses... Replaces repeated text var_name [, var_name...]

Represents code supplied by user

void main (void){ ...}

DS00000A-page 6 2016 Microchip Technology Inc.

Page 7: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

Preface

WARRANTY REGISTRATIONPlease complete the enclosed Warranty Registration Card and mail it promptly. Sending in the Warranty Registration Card entitles users to receive new product updates. Interim software releases are available at the Microchip web site.

RECOMMENDED READINGThis user’s guide describes PIC24FJ IoT Demo. The device-specific data sheets contain current information on programming the specific microcontroller or digital signal controller devices. Other useful documents are listed below. The following Microchip documents are available and recommended as supplemental reference resources.For more information on PIC24FJ devices, Cypto module or RN4020 module refer to:• www.microchip.com/PIC24FJ128GB204• www.microchip.com/PIC24FJ128GA204• www.microchip.com/PIC24FJ256GB410• www.microchip.com/RN4020• AN1861 “Bluetooth® Smart Communication Using Microchip RN4020 Module and

16-bit PIC® Microcontroller“

2016 Microchip Technology Inc. DS00000A-page 7

Page 8: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

PIC24FJ IoT Demo User’s Guide

THE MICROCHIP WEB SITEMicrochip provides online support via our web site at www.microchip.com. This web site is used as a means to make files and information easily available to customers. Accessible by using your favorite Internet browser, the web site contains the following information:• Product Support – Data sheets and errata, application notes and sample

programs, design resources, user’s guides and hardware support documents, latest software releases and archived software

• General Technical Support – Frequently Asked Questions (FAQs), technical support requests, online discussion groups, Microchip consultant program member listing

• Business of Microchip – Product selector and ordering guides, latest Microchip press releases, listing of seminars and events, listings of Microchip sales offices, distributors and factory representatives

DEVELOPMENT SYSTEMS CUSTOMER CHANGE NOTIFICATION SERVICEMicrochip’s customer notification service helps keep customers current on Microchip products. Subscribers will receive e-mail notification whenever there are changes, updates, revisions or errata related to a specified product family or development tool of interest.To register, access the Microchip web site at www.microchip.com, click on Customer Change Notification and follow the registration instructions.The Development Systems product group categories are:• Compilers – The latest information on Microchip C compilers and other language

tools. These include the MPLAB® C compiler; MPASM™ and MPLAB® 16-bit assemblers; MPLINK™ and MPLAB® 16-bit object linkers; and MPLIB™ and MPLAB® 16-bit object librarians.

• Emulators – The latest information on the Microchip MPLAB® REAL ICE™ in-circuit emulator.

• In-Circuit Debuggers – The latest information on the Microchip in-circuit debugger, MPLAB® ICD 3.

• MPLAB IDE – The latest information on Microchip MPLAB® IDE, the Windows® Integrated Development Environment for development systems tools. This list is focused on the MPLAB® IDE, MPLAB® SIM simulator, MPLAB® IDE Project Man-ager and general editing and debugging features.

• Programmers – The latest information on Microchip programmers. These include the MPLAB® PM3 device programmer and the PICkit™ 3 development programmers.

DS00000A-page 8 2016 Microchip Technology Inc.

Page 9: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

Preface

CUSTOMER SUPPORTUsers of Microchip products can receive assistance through several channels:• Distributor or Representative• Local Sales Office• Field Application Engineer (FAE)• Technical SupportCustomers should contact their distributor, representative or FAE for support. Local sales offices are also available to help customers. A listing of sales offices and locations is included in the back of this document.Technical support is available through the web site at: http://support.microchip.com

DOCUMENT REVISION HISTORY

Revision A (July 2016)This is the initial released version of the document.

2016 Microchip Technology Inc. DS00000A-page 9

Page 10: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

PIC24FJ IoT Demo User’s Guide

NOTES:

DS00000A-page 10 2016 Microchip Technology Inc.

Page 11: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

PIC24FJ IoT DEMO USER’S GUIDE

Chapter 1. Introduction

1.1 OVERVIEWBluetooth® has emerged as a standard of choice for connecting local embedded appli-cations through a router, smartphone or tablet. Today, Bluetooth is known to provide easy and temporary connectivity to smartphones and tablets, and is supported in many Android® and iOS® applications. Many applications only need simple command and control, or a quick status update from a sensor. By catering to these needs Bluetooth Low Energy (BLE) has evolved to support these low-duty cycle applications. However, when the application is a simple command and control, the power consump-tion is also expected to be as low as possible. Power consumption has become one of the foremost concerns for embedded system designers. It is important that a microcon-troller not only consumes as little power as possible, but also provides features that allow for minimal power consumption in the rest of the design as well. Microchip’s eXtreme Low Power PIC® Microcontrollers and RN4020 BLE module help in achieving low power consumption.This demonstration shows the simple communication between the RN4020 module and a BLE supporting smartphones or tablets. The RN4020 module is controlled by the PIC24FJ MCU which also includes a hardware Crypto engine used for AES encryption in the demonstration. The demonstration is built using standard development tools from Microchip including the Explorer 16 Board, PIC24FJ Controller Plug-In Module (PIM), and BLE PICtailTM Plus Daughter Card. These readily available tools helps to easily replicate the demo. The demo is supported by the MCU firmware and an application that will run on an Android phone or tablet.

1.2 PIC® MICROCONTROLLERS WITH XLP TECHNOLOGYAs more electronic applications require low power or battery power, energy conserva-tion becomes paramount. Today’s applications must consume little power and, in extreme cases, last for up to 15–20 years while running from a single battery. To enable applications like these, products with Microchip’s eXtreme Low Power (XLP) Technol-ogy offer the industry’s lowest currents, where extreme low power applications spend 90% to 99% of their time.The PIC24FJ device used in this demo has an integrated hardware Crypto engine. The Crypto engine is intended to accelerate applications that need cryptographic functions. The Crypto engine supports AES and DES/TDES ciphers. A 128-bit AES is shown in this demo.

1.3 MICROCHIP RN4020 MODULEThe BLE, also known as Bluetooth Smart, is intended for low-duty cycle devices that support low-data throughput and can operate for a longer duration compared to other protocols from a coin cell battery. BLE operates in the same spectrum band (i.e., 2.400 GHz to 2.4835 GHz ISM band) as Classic Bluetooth technology, but uses a different set of channels and different modulation techniques.

2016 Microchip Technology Inc. DS00000A-page 11

Page 12: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

PIC24FJ IoT Demo User’s Guide

For additional information related to Bluetooth and its specifications, refer to “Bluetooth Core Specification V4.0” from the following web site: http://www.bluetooth.orgThe Microchip RN4020 is a fully-certified Bluetooth Version 4.1 module for adding low-power wireless capability to applications and products.

1.4 ANDROID APPLICATIONThe Android application (16-bit XLP BLE AES Demo) interacts with the RN4020 BLE PICtail plus module. The smart phone or tablet in which the application is installed should support Bluetooth 4.0 or newer. The application is compatible with Android 5.0 lollipop and lower versions.

1.4.1 Main Functionality of the IoT Application:• Discover BLE devices nearby• Toggle the LEDs on the Explorer 16 Board• Reflect the switch state of the Explorer 16 Board• Receive 128-bit AES encrypted data (Cipher Text) from the PIC24FJ device for a

given plain text• Receive 128-bit AES decrypted data from the PIC24FJ device for a given Cipher

Text

Note: This demo is based on the RN4020 PICtail module with 1.20 firmware version. To get the firmware version refer to commands in RN4020 data sheet.

DS00000A-page 12 2016 Microchip Technology Inc.

Page 13: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

PIC24FJ IoT DEMO USER’S GUIDE

Chapter 2. Hardware

2.1 HARDWARE REQUIREMENTSHardware requirements to run this demo are as follows: 1. Power Supply (9V)

https://www.microchipdirect.com/ProductSearch.aspx?Keywords=AC0020142. One of the following microcontrollers is required for the Explorer 16 Board:

- PIC24FJ128GB204 PIM (Part # MA240036) - PIC24FJ128GA204 PIM (Part # MA240037) - PIC24FJ256GB410 PIM (Part # MA240038)

The device needs to be programmed on the Explorer 16 Board with supported hex file which can be downloaded from: www.microchip.com/PIC24IoTDemo To learn more about loading a hex file, view the following video: https://www.youtube.com/watch?v=pEMORwwuyos

FIGURE 2-1: MICROCONTROLLERS

2016 Microchip Technology Inc. DS00000A-page 13

Page 14: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

PIC24FJ IoT Demo User’s Guide

The jumper settings on the PIMs for this demo are listed in Table 2-1

3. RN4020 Bluetooth PICtail Daughter Card with JP1 jumper placed (Part # RN-420-PICtail)

4. Explorer 16 Development Board (Part # DM240001) – Both PIM and PICtail Daughter Card plug directly into the Explorer 16 Board

TABLE 2-1: JUMPER SETTINGS FOR MICROCONTROLLERSPIC24FJ128GA204 PIM PIC24FJ128GB204 PIM PIC24FJ256GB410 PIM

J1 at POT J1 at USBID —J2 at Temp J2 at SC_RX J2 - Default (2-3)J3 at SC-RX J3 at SC_TX —J4 at SC-TX J4 at EE_CS J4 - Default (2-3)J5 at EE-CS J5 at VBUS/PMD6 J5 - Default (2-3)J6 at PMWR J6 at POT J6 - Position (1-2)— J7 at TEMP J7 - Default (2-3)— J8 at PGC1 —— J9 at PGD1 —— — Remove R4(0R) resistor

DS00000A-page 14 2016 Microchip Technology Inc.

Page 15: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

Hardware

2.2 HARDWARE CONNECTIONS1. Mount the RN4020 Bluetooth PICtail Daughter Card on the Explorer 16 Develop-

ment Board’s PICtail Plus slot. Ensure that the Pin No1 of PICtail is aligned to Pin No1 of the PICtail Plus slot as shown in following images:

2. Mount the PIC24FJ PIM in the U1 socket as shown in the following images:

2016 Microchip Technology Inc. DS00000A-page 15

Page 16: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

PIC24FJ IoT Demo User’s Guide

3. On the Explorer 16 Board ensure to: a) Connect the Switch S2 to PIM end

b) Connect Jumper J7 to PIC24 end

c) Mount Jumper JP2 as shown in the following image

4. Power up the Explorer 16 Board using a 9V power supply

DS00000A-page 16 2016 Microchip Technology Inc.

Page 17: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

PIC24FJ IoT DEMO USER’S GUIDE

Chapter 3. Demo Instructions

3.1 INSTALLING ANDROID APPLICATION ON SMARTPHONE OR TABLET

To install the application, execute the following:1. Enable “Unknown Sources” on Android - to enable Unknown Sources go to

Settings > Security and check the box next to “Unknown Sources”2. Download the .apk file “com.microchip.iotdemo-2.apk” from:

www.microchip.com/PIC24IoTDemo3. Install the .apk file4. Navigate to the directory where the .apk file has been downloaded5. Tap the .apk file and an installation dialogue box will pop-up. Select the “Install”

button to install the .apk on your Android device.

3.2 ESTABLISHING CONNECTION BETWEEN ANDROID APPLICATION AND RN4020 MODULE

1. On power-up of the Explorer 16 Board the following is observed:a) The WAKE LED of the RN4020 module will turn ON

b) The LED D7 starts flashing every 0.5 seconds

Note: The phone or tablet supports Bluetooth 4.0 or newer, and it runs on Android 5.0 lollipop or newer versions.

2016 Microchip Technology Inc. DS00000A-page 17

Page 18: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

PIC24FJ IoT Demo User’s Guide

2. Run the “16XLP BLE AES Demo” application on the Android device

While the application runs the following events occur:a) If the Bluetooth is OFF, the application will request to turn ON the Bluetooth

- Select “Allow”

Selecting IoT_BLE establishes connection between the Android phone or tablet and RN4020 module on the Explorer 16 Board.b) The application will scan for the BLE enabled modules in the vicinity. If found,

it displays the name as “IoT_BLE”.

c) This also opens the interactive screen on the tablet or smartphone.

DS00000A-page 18 2016 Microchip Technology Inc.

Page 19: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

Demo Instructions

d) Connection status is reflected with CONN LED ON in RN4020 PICtail module and LED D7 ON in the Explorer 16 Board.

3.3 LED CONTROLAs shown in the following images the application controls turning ON and OFF of the LED D9 and D8 independently on the Explorer 16 Board. This demonstrates controlling an end application remotely from the phone or tablet.

3.4 SWITCH STATUS The application also reflects the status of S3 and S4 switches of the Explorer 16 Board. Changing the status of the switches on the Explorer 16 Board will reflect in the ON/OFF status changing on the application. This demonstrates communication of sensor infor-mation or data from an end application to a phone or tablet.

2016 Microchip Technology Inc. DS00000A-page 19

Page 20: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

PIC24FJ IoT Demo User’s Guide

3.5 128-BIT AES ENCRYPTIONTo protect the data in the end application, the data can be encrypted locally, before being sent to/from the board (end application) to the phone or tablet, and sometimes on to a cloud-based storage.For 128-bit AES encryption:1. On the application, in the “Plain Text” field enter the hex numbers to be

encrypted. Plain text can be a maximum of 32 characters and any text lesser than 32 char-acters will be appended with 0s by the application.Similar to the one available in the following link, there are online tools for AES encryption:http://aes.online-domain-tools.com/

2. After entering the data to be encrypted on the application, select the “Encrypt” button. The PIC24FJ device will encrypt the data by using the default 128-bit Key “95 A8 EE 8E 89 97 9B 9E FD CB C6 EB 97 97 52 8D”.Encrypted data will be displayed in “Cipher Text” field.

3.6 128-BIT AES DECRYPTIONFor 128-bit AES decryption:1. Enter the hex numbers to be decrypted in the “Cipher Text” field.

Cipher text can be a maximum of 32 characters and any text lesser than 32 char-acters will be appended with 0s by the application.

2. After entering the data to be decrypted, select the “Decrypt” button. The PIC24FJ MCU will decrypt the data and it will be displayed in the “Decrypted Text” field.

DS00000A-page 20 2016 Microchip Technology Inc.

Page 21: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

PIC24FJ IoT DEMO USER’S GUIDE

Chapter 4. Power Saving

If there is no activity, either in the Android application or on the Explorer 16 Board, for 1 minute, the BLE module and the PIC24FJ device enter Seep mode to save power. Simultaneously, the following events occur:• The WAKE LED of the BLE module will turn OFF• The LED D7 on the Explorer 16 Board turns OFF• Activities in the application will be disabled

2016 Microchip Technology Inc. DS00000A-page 21

Page 22: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

PIC24FJ IoT Demo User’s Guide

The RN4020 and PIC24FJ will wake up by asserting either the S3 or S4 switch on the Explorer 16 Board.

DS00000A-page 22 2016 Microchip Technology Inc.

Page 23: PIC24FJ XLP Bluetooth LE IoT Demo User’s Guideww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ IoT Demo User... · PIC24FJ XLP Bluetooth LE IoT Demo User’s Guide. ... Italic characters

DS00000A-page 23 2016 Microchip Technology Inc.

AMERICASCorporate Office2355 West Chandler Blvd.Chandler, AZ 85224-6199Tel: 480-792-7200 Fax: 480-792-7277Technical Support: http://www.microchip.com/supportWeb Address: www.microchip.comAtlantaDuluth, GA Tel: 678-957-9614 Fax: 678-957-1455Austin, TXTel: 512-257-3370 BostonWestborough, MA Tel: 774-760-0087 Fax: 774-760-0088ChicagoItasca, IL Tel: 630-285-0071 Fax: 630-285-0075ClevelandIndependence, OH Tel: 216-447-0464 Fax: 216-447-0643DallasAddison, TX Tel: 972-818-7423 Fax: 972-818-2924DetroitNovi, MI Tel: 248-848-4000Houston, TX Tel: 281-894-5983IndianapolisNoblesville, IN Tel: 317-773-8323Fax: 317-773-5453Los AngelesMission Viejo, CA Tel: 949-462-9523 Fax: 949-462-9608New York, NY Tel: 631-435-6000San Jose, CA Tel: 408-735-9110Canada - TorontoTel: 905-695-1980 Fax: 905-695-2078

ASIA/PACIFICAsia Pacific OfficeSuites 3707-14, 37th FloorTower 6, The GatewayHarbour City, KowloonHong KongTel: 852-2943-5100Fax: 852-2401-3431Australia - SydneyTel: 61-2-9868-6733Fax: 61-2-9868-6755China - BeijingTel: 86-10-8569-7000 Fax: 86-10-8528-2104China - ChengduTel: 86-28-8665-5511Fax: 86-28-8665-7889China - ChongqingTel: 86-23-8980-9588Fax: 86-23-8980-9500China - DongguanTel: 86-769-8702-9880 China - GuangzhouTel: 86-20-8755-8029 China - HangzhouTel: 86-571-8792-8115 Fax: 86-571-8792-8116China - Hong Kong SARTel: 852-2943-5100 Fax: 852-2401-3431China - NanjingTel: 86-25-8473-2460Fax: 86-25-8473-2470China - QingdaoTel: 86-532-8502-7355Fax: 86-532-8502-7205China - ShanghaiTel: 86-21-5407-5533 Fax: 86-21-5407-5066China - ShenyangTel: 86-24-2334-2829Fax: 86-24-2334-2393China - ShenzhenTel: 86-755-8864-2200 Fax: 86-755-8203-1760China - WuhanTel: 86-27-5980-5300Fax: 86-27-5980-5118China - XianTel: 86-29-8833-7252Fax: 86-29-8833-7256

ASIA/PACIFICChina - XiamenTel: 86-592-2388138 Fax: 86-592-2388130China - ZhuhaiTel: 86-756-3210040 Fax: 86-756-3210049India - BangaloreTel: 91-80-3090-4444 Fax: 91-80-3090-4123India - New DelhiTel: 91-11-4160-8631Fax: 91-11-4160-8632India - PuneTel: 91-20-3019-1500Japan - OsakaTel: 81-6-6152-7160 Fax: 81-6-6152-9310Japan - TokyoTel: 81-3-6880- 3770 Fax: 81-3-6880-3771Korea - DaeguTel: 82-53-744-4301Fax: 82-53-744-4302Korea - SeoulTel: 82-2-554-7200Fax: 82-2-558-5932 or 82-2-558-5934Malaysia - Kuala LumpurTel: 60-3-6201-9857Fax: 60-3-6201-9859Malaysia - PenangTel: 60-4-227-8870Fax: 60-4-227-4068Philippines - ManilaTel: 63-2-634-9065Fax: 63-2-634-9069SingaporeTel: 65-6334-8870Fax: 65-6334-8850Taiwan - Hsin ChuTel: 886-3-5778-366Fax: 886-3-5770-955Taiwan - KaohsiungTel: 886-7-213-7828Taiwan - TaipeiTel: 886-2-2508-8600 Fax: 886-2-2508-0102Thailand - BangkokTel: 66-2-694-1351Fax: 66-2-694-1350

EUROPEAustria - WelsTel: 43-7242-2244-39Fax: 43-7242-2244-393Denmark - CopenhagenTel: 45-4450-2828 Fax: 45-4485-2829France - ParisTel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79Germany - DusseldorfTel: 49-2129-3766400Germany - KarlsruheTel: 49-721-625370Germany - MunichTel: 49-89-627-144-0 Fax: 49-89-627-144-44Italy - Milan Tel: 39-0331-742611 Fax: 39-0331-466781Italy - VeniceTel: 39-049-7625286 Netherlands - DrunenTel: 31-416-690399 Fax: 31-416-690340Poland - WarsawTel: 48-22-3325737 Spain - MadridTel: 34-91-708-08-90Fax: 34-91-708-08-91Sweden - StockholmTel: 46-8-5090-4654UK - WokinghamTel: 44-118-921-5800Fax: 44-118-921-5820

Worldwide Sales and Service

06/23/16