Summary of Contents for Microchip Technology RN4870
Page 1
® RN4870/71 Bluetooth Low Energy Module User’s Guide 2016 Microchip Technology Inc. DS50002466A...
Page 2
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. Microchip received ISO/TS-16949:2009 certification for its worldwide Silicon Storage Technology is a registered trademark of headquarters, design and wafer fabrication facilities in Chandler and Microchip Technology Inc.
Page 3
® Object of Declaration: RN4870/71 Bluetooth Low Energy Module 2016 Microchip Technology Inc. DS50002466A-page 3...
Page 4
® RN4870/71 Bluetooth Low Energy Module User’s Guide NOTES: 2016 Microchip Technology Inc. DS50002466A-page 4...
Energy Module and provides a brief overview of its various features. • Chapter 2. “Command Reference” – This chapter provides information on the commands used to configure the RN4870/71 Bluetooth Low Energy Module with examples. • Chapter 3. “Embedded Scripting Feature”...
Bluetooth Low Energy Fundamentals. • Appendix B. “Status Response Summary Quick Reference” – This appendix provides a quick reference of all the status messages returned by RN4870 and summarizes the ASCII commands. CONVENTIONS USED IN THIS GUIDE This manual uses the following documentation conventions:...
® RN4870/71 Bluetooth 4.2 Low Energy Module Data Sheet (DS50002489A) This document provides the technical specifications for the RN4870/71 module and is available for download from the Microchip website (www.microchip.com) THE MICROCHIP WEBSITE Microchip provides online support via our website at www.microchip.com. This website is used as a means to make files and information easily available to customers.
Technical support is available through the website at: http://www.microchip.com/support. DOCUMENT REVISION HISTORY Revision A (April 2016) This is the initial release of this document. 2016 Microchip Technology Inc. DS50002466A-page 10...
Custom GATT Services 1.2.3 The RN4870/71 has the capability to define up to five public and four private custom defined GATT services. Each custom service allows up to eight characteristics. All service definitions are saved in on-board Non-Volatile Memory (NVM) configuration settings.
When RN4870/71 is connected to another BLE device and is in Data mode, the RN4870/71 acts as a data pipe: any serial data sent into RN4870/71 UART is trans- ferred to the connected peer device via Transparent UART Bluetooth service. When data is received from the peer device over the air via Transparent UART connection, this data outputs directly to UART.
ACCESSING THE RN4870/71 OVER UART The most common application for the host MCU to control the RN4870/71 is via ASCII commands. For development and prototyping purposes, using a terminal emulator to send commands and data over UART is recommended. Any terminal emulator, such ®...
Page 14
® RN4870/71 Bluetooth Low Energy Module User’s Guide NOTES: 2016 Microchip Technology Inc. DS50002466A-page 14...
Appendix B. “Status Response Summary Quick Reference”. SET AND GET COMMANDS Set and Get commands are used to configure features and functions of the RN4870/71 module. The format of the Set and Get commands are provided in Table 2-1. The Set command starts with character “S”...
S%,<pre>,<post> 2.4.3 This command sets the pre and post delimiter of the status string from RN4870/71 to the host controller. The pre and post delimiter are up to four printable ASCII characters. If no parameter is given to the post delimiter, then the post delimiter is cleared; if no parameter is given to the pre-delimiter, then both pre and post delimiters are cleared.
Page 17
BLE link. The parameters are described in Table 2-2. Once a remote device exchanges pin codes with the RN4870/71 device, a link key is stored for future use. The device automatically and permanently stores up to eight peer devices in flash memory. TABLE 2-2:...
Page 18
Non-connectable beacon and connectable advertisement are both enabled. Refer to commands IB (2.6.20) and NB (2.6.21) to configure beacon payload. Default: Example: // Enable both beacon and advertisement SC,2 Response: // Success // Syntax error or invalid parameter 2016 Microchip Technology Inc. DS50002466A-page 18...
Page 19
2.4.8 SDA,<H16> This command sets the appearance of RN4870/71 in GAP service. It expects one 16-bit hex input parameter. Bluetooth SIG defines the appearance code for different devices. Please refer to Bluetooth SIG web site for details (https://www.bluetooth.org/en-us). Default: 0000...
Page 20
This command resets the configurations into factory default. The first parameter must be 1. Example: SF,1 Response: Reboot after Factory Reset // Reboot // Syntax error or invalid parameter Note: This command causes an immediate reboot after invoking it. 2016 Microchip Technology Inc. DS50002466A-page 20...
Page 21
Command SO enables or disables low-power operation of RN4870/71. It expects one single digit as input parameter. If the input parameter is 0, then RN4870/71 runs 16 MHz clock all the time, therefore, can operate UART all the time. On the other hand, if the input parameter is 1, then RN4870 enables Low-Power mode by running 32 kHz clock with much lower power consumption.
Page 22
Pairing (SSP) authentication method in BLE if a fixed passkey is desirable. In this way, RN4870 is not required to display the passkey if the remote peer already knows the passkey. The user must to understand the security implication by using the fixed passkey.
Page 23
2.4.22 SS,<hex8> This command sets the default services to be supported by the RN4870 in GAP server role. The input parameter is an 8-bit bitmap that indicates the services to be supported as a server. Supporting service in server role means that the host MCU must supply the values of all characteristics in supported services and to provide client access to those values upon request.
Page 24
• (Interval + 16)*(Latency + 1) < Timeout * 8/3 Default: 0006,0000,0200 Example: // Set the interval to be 125 ms, latency to be ST,0064,0002,0064 // 2 and timeout to 1 second Response: // Success // Syntax error or invalid parameter 2016 Microchip Technology Inc. DS50002466A-page 24...
Page 25
Table 2-8 shows the pin indexes and the corresponding RN4870/71 pins. Note that some pins apply only to RN4870, some others to RN4870/71 and rest is available to both RN4870 and RN4870/71. The second parameter is an 8-bit hex of function to be assigned to the pin. The...
2.5.2 Command GK gets the current connection status. It expects no input parameter. If the RN4870/71 is not connected, the output is none. If the RN4870/71 is connected, command GK returns the following connection information: <Peer BT Address>,<Address Type>,<Connection Type>...
// End Command mode 2.6.4 !,<0,1> RN4870/71 has the capability of Remote Command mode over UART Transparent connection. Remote Command mode uses UART Transparent service. Therefore, it is necessary to enable UART Transparent service using command SS before accessing Remote Command mode feature.
Page 28
• Both local and remote devices support UART Transparent feature. • The two devices are already connected and secured. Upon receiving the request to start the Remote Command session, the RN4870/71 accepts the request if the following conditions are met: •...
Page 29
The first parameter is the PWM channel to be used in this command. Two PWM chan- nels are supported. Channel 1 is on pin P22 and channel 2 is on pin P23. If pin P22 has been assigned to a system function, such command is ignored and RN4870 returns error message.
Page 30
The third and fourth parameters are 16-bit hex values, defining maximum and compare values, respectively. RN4870 follows standard PWM operations. The clock source decides the unit time used in maximum and compare values. Maximum value multiplying time unit is the PWM period;...
Page 31
Once bonded, security materials are saved in both end of the connection. Therefore, reconnection between bonded devices does not require authentication, so reconnec- tion can be done in a very short time. 2016 Microchip Technology Inc. DS50002466A-page 31...
Page 32
// Failed in security %ERR_SEC% 2.6.14 This command makes RN4870/71 try to connect to the last bonded device. When this command is used to reconnect to a bonded device, the RN4870/71 automatically secures the link once the connection is established.
Page 33
2.6.16 C<1-8> RN4870/71 can store the MAC addresses of up to eight bonded devices. The C com- mand provides an easy way to reconnect to any stored device without typing the MAC address of stored device, if such device uses public address. When this command is used to reconnect to a bonded device, RN4870/71 automatically secures the link once the connection is established.
Page 34
Low Energy Module User’s Guide 2.6.19 Command I is used to initiate UART Transparent operation with RN4677 or RN4678. This command expects no input parameter. Once this command is issued, RN4870/71 automatically enters Data mode. Example: // Start UART Transparent with RN4020 and...
Page 35
As a peripheral, any device not listed in the white list cannot be con- nected with a local device. RN4870/71 supports up to 16 addresses in the white list. If the white list is full, any attempt to add more addresses returns an error.
Page 36
The return value of command M is the signal strength in dBm. Example: // Check the signal strength of last communication // with peer device Response: // Signal strength reading <RSSI> // Not connected 2016 Microchip Technology Inc. DS50002466A-page 36...
Page 37
0. In Power-Saving mode (refer to command SO 2.4.19), UART_RX_IND pin must be pulled high before entering Dormant mode. If the input parameter is 0, then RN4870/71 enters Dormant mode immediately, without giving any response. If any other input...
Page 38
Command Z cancels connection attempt started by command C before a connection is established. Command Z does not expect any parameter. Example: // Cancel attempt to establish a connection Response: // Success // Already connected 2016 Microchip Technology Inc. DS50002466A-page 38...
• An active connection exists • Peer device supports server role services. • RN4870/71 issues command CI before initiating client role service. Optionally, command LC takes one input parameter. If the input parameter is letter “P”, then only the Universally Unique Identifiers (UUID) of all services are printed out.
Page 40
2 means indication started. Example: // Display all server services 2.7.4 Command LW lists the current script stored in NVM. Example: // Display current script content Response: <Content of script> 2016 Microchip Technology Inc. DS50002466A-page 40...
Bluetooth devices. For use cases not covered by public service, Bluetooth allows the creation of a private service. The RN4870 provides private and public services/characteristics in a GATT server and can work with private service/characteristics in a GATT client role.
Page 42
4. Use command PS to set the UUID for the second service 5. Use one or more command PC to add one characteristic at a time to the second service 6. Repeat step 4 and step 5 to define more services if necessary 2016 Microchip Technology Inc. DS50002466A-page 42...
When the RN4870 acts as a server, all service characteristics are stored locally. This is called Server Services. Services where RN4870 acts as a client are called Client Ser- vices. In this case all data and configurations of characteristics are stored remotely in a peer device.
Page 44
Endian) starts the indication and value 0x0000 stops both. To start notification or indi- cation depends on service specification as well as on the property of the characteristic. Refer to Table A-1 Appendix A. “Bluetooth Low Energy Fundamentals” Figure 2-2 for details. 2016 Microchip Technology Inc. DS50002466A-page 44...
Page 45
2.9.4 Command CI is used to start client operation on the RN4870/71. RN4870/71 starts as a GATT server by default. If the user also prefers RN4870/71 to act as a GATT client, command CI must be issued first. Command CI performs essential service discovery process with the remote GATT server and acquires supported public and private services and characteristics on the remote GATT server.
RN4870/71 module. For more details on the Embedded Scripting Feature, refer to Chapter 3. “Embedded Scripting Feature”. 2.10.1 Command WC clears the script, if any, loaded in the RN4870/71. It expects no parameters. Default: Example: // Clear the script loaded in RN4870/71 module...
Page 47
UART line by line. Once all script lines are entered, type escape key ESC to exit Script Input mode. Default: Example: // Enter Script Input mode 2016 Microchip Technology Inc. DS50002466A-page 47...
Page 48
® RN4870/71 Bluetooth Low Energy Module User’s Guide NOTES: 2016 Microchip Technology Inc. DS50002466A-page 48...
By using the RN4870 Embedded Scripting feature, operations and functions can be executed by script engine. A script consists of ASCII commands that do not need to be compiled or processed. The script remains in the RN4870/71 NVM and does not alter the core firmware in any way.
Page 50
Comments 3.1.3 RN4870/71 script engine handles the script line by line. Each line starts with multiple spaces or tabs and ends with return or line feed. Even though space is generally prohibited within a command, spaces or tabs are allowed in assignments and logic expressions.
Page 51
Remote Function Call 3.1.6 3.1.6.1 FUNCTION DEFINITIONS RN4870/71 supports three custom functions. These functions are defined as ?FUNC1, ?FUNC2 and ?FUNC3. Each function can be associated with write operation of a char- acteristic handle using the following syntax: %handle = ?FUNCx...
Page 52
If private characteristic is configured to be able to notify and the peer device has started notification, the return value is automatically sent to the peer device. Otherwise, the peer device needs to read the same handle to get the return value. 2016 Microchip Technology Inc. DS50002466A-page 52...
2. Power on the RN4870 module 3. Turn on Bluetooth and open SmartDiscover App on the Apple device 4. Click the RN4870 module from the scan device list in SmartDiscover App to con- nect to the module. Refer to Figure 4-1.
Page 54
UUID, access properties, notification/indication and also to enable notification, read and write the charac- teristic based on the access supported. Refer to Figure 4-3. FIGURE 4-3: CHARACTERISTIC ACCESS 2016 Microchip Technology Inc. DS50002466A-page 54...
6. Enter R,1 to reboot the module for the configuration to take effect 7. Turn on Bluetooth and open SmartData App on the Apple device 8. Click the RN4870 module from the scan list in SmartData App to connect to the module. Refer to Figure 4-4.
Page 56
RN4870/71 Bluetooth Low Energy Module User’s Guide 12. Type any data on the serial terminal of the RN4870 to send data from RN4870 to SmartData App which is received and printed on the receive view of the Smart- Data App. Refer to...
The RN4870 can initiate BLE connection in Central (GAP) mode to another BLE device supporting the UART Transparent service. The command sequence is as follows: 1. Using a terminal emulator on host PC, open a connection to RN4870 PICtail on the enumerated COM port.
Page 58
® RN4870/71 Bluetooth Low Energy Module User’s Guide NOTES: 2016 Microchip Technology Inc. DS50002466A-page 58...
0b00000100 Write value of characteristic without acknowledgment response from client to server Read 0b00000010 Read value of characteristic. Value is sent from server to client Broadcast 0b00000001 Broadcast value of characteristic Note 1: Currently not supported in RN4870 2016 Microchip Technology Inc. DS50002466A-page 59...
Page 60
Write, Read, Indication and Notifications. Write-REQ enables client to update characteristic values on the Peripheral's GATT server. The write requests can be performed using RN4870 CHW and CUW commands. For more details on GATT characteristic access commands, refer to Section 2.9 “Characteristic Access...
MCU sending the data, such as UART Transparent stream, be able to recognize status messages. The delimiters of the status messages can be changed using the S% command. TABLE B-1: STATUS MESSAGES RETURNED BY RN4870 Status Message Description Default Delimiter (%)
Page 62
® RN4870/71 Bluetooth Low Energy Module User’s Guide TABLE B-1: STATUS MESSAGES RETURNED BY RN4870 (CONTINUED) Status Message Description Default Delimiter (%) Start of Remote Command mode %RMT_CMD_ON% Read value <hex> for characteristic handle <hdl> %RV,<hdl>,<hex>% Debugging information when running script.
Page 63
Create and use a resolvable random address &R Start advertisement Start bonding process Connect to peer device as central Display RN4870 critical information Start scanning as central Start UART Transparent with RN4020 and RN4677/4678 Set advertisement content immediately Set beacon content immediately...
Page 64
Write remote characteristic value as client Discover remote services/characteristics as client Read local characteristic value as server Write local characteristic value as server Script Control Clear current script Pause script execution Run script Write script 2016 Microchip Technology Inc. DS50002466A-page 64...
Need help?
Do you have a question about the RN4870 and is the answer not in the manual?
Questions and answers