Explore Command Mode


This hands-on application example outlines basic command mode operation for the RN4020.

You will learn:

  • How to setup basic communications between your PC and the RN4020.
  • How to enter command mode
  • Commands that review the current configuration settings of the module
  • Commands that reset the module


Hardware Tools

Tool About Purchase
RN4020 Bluetooth Low Energy PICtail™/PICtail Plus

Software Tools

This lab requires the following software tools:

 Connection Diagram

A host is required to enter commands that configure the module. The following connections are required at a minimum:


If you are using the RN4020 PICTail, UART_TX, UART_RX and WAKE_SW are already connected as shown.

In an embedded application, WAKE_SW is connected to a digital output pin of the host MCU, to control entry/exit from Command mode. The MCU Interfacing page covers the complete pin interface in more detail.


The following procedure is performed on a Windows 7 computer, using Tera Term terminal emulator software.


Module Overview

The following diagram depicts the key components of the RN4020 PICTail.



Connect Module to PC

Connect the RN4020 to your computer using the supplied USB cable.


By default, the RN4020 PICTail powers up in Command mode, as indicated by the Blue WAKE LED.


Use The Device Manager to find the COM Port Number

Before you start Tera Term, you need to determine the COM port number assigned to the connection.

Select Start —> Control Panel —> System and Security —> System —> Device Manager

Expand "Ports" and note the COM port number as shown here.



Launch Tera Term and Open Assigned COM Port

Start Tera Term, and open the assigned COM port number with the following settings:

  • 115200 baud, 8-bits, No Parity, 1-stop bit


The first command we want to issue is the "+" command. This toggles the local echo on and off. Now that we have entered this command while in Command mode, it allows all typed characters to be echoed to the output. The module will respond with "Echo On".



Next, we might want to set our device's name. We can do that by issuing the SN,<string> command. For example, if I want to name my device DeveloperHelp, I would issue the following command:


After we issue that command, the module will respond with "AOK".


To view critical information about our device over the UART, we simply issue the D command:


and the module will respond with the following information:

  • Device MAC Address
  • Device Name
  • Device Connection Role (Central or Peripheral)
  • Connected Device: Show the MAC address and address type (Public or Random) if connected, or “no” if no active connection
  • Bonded Device: Show the MAC address and address type (Public or Random) if connected, or “no” if no bonding device
  • Server Services: Bitmap of services that are supported in the server role
  • Features(1): Current value of features bitmap. Refer to “SR” command
  • Transmit Power(1): Current value of transmit power. Refer to “SP” command


To verify which Firmware Version we have on our module, we can use the "V" command.


The module will respond with the following:



A reboot is required for most Set commands to ensure the new settings will take effect. The reboot command "R" has a mandatory parameter of '1'.


The module will respond with Reboot and then CMD to indicate it is back in Command mode.



The last command we will go over in this brief introduction is the SF command. This command resets the configurations to the factory default at the next reboot. The parameters for this command can be either ‘1’ or ‘2’.


When the input parameter is ‘1’, a majority of the settings will be restored to the factory default, but some settings, such as device name, device info, script and private services, stay the same. When the input parameter is ‘2’, all parameters are restored to factory default. For this example we entered SF,1 and the module responds with "AOK".



This lab has briefly introduced you to some of the ASCII commands used to control and configure the RN4020 module. To learn more about the RN4020, the RN4020 PICTail, or to view the entire RN4020 command set, please view the following:

20th Annual
Microchip MASTERs Conference 2016
Register now - Deadline: July 29

JW Marriott Desert Ridge Resort-Phoenix, AZ

© 2016 Microchip Technology, Inc.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.