Explore Command Mode

 Objective

This hands-on application example outlines the 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

 Materials

Hardware Tools

Tool About Purchase
RN-4020-PICTAIL-50px.png
RN-4020-PICTAIL
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:

rn4020-dfu-ota-connection.png

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.

 Procedure

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

1

Module Overview

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

RN4020Components.png

2

Connect Module to PC

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

Connected1.png

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

3

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.

device-manager.png

4

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
start-tera-term.png

5

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".

EchoOn.png

6

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:

DeviceName.png

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

7

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

DeviceInfo.png

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
DeviceInfo2.png

8

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

VCommand.png

The module will respond with the following:

FirmwareVersion.png

9

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.

RebootModule.png

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

RebootCMD.png

10

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.

FactoryDefault.png

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".

FactoryDefault2.png

 Conclusions

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:

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
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.