RN4020 Explore Command Mode

Last modified by Microchip on 2023/11/10 11:11

Objective

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

You will learn:

  • How to set up 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

Reference Materials

Hardware Tools

Software Tools

Back to Top


Connection Diagram

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

Connection Diagram

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.

Back to Top


Procedure

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.

Board View of Key components of the RN4020 PICtail

Connect Module to PC

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

Board view of RN4020 connected to PC

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 in the accompanying image.

Device Manager showing COM port

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

Tera Term window

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

TeraTerm window showing the "+" command which toggles the local echo on and off

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:

TeraTerm window showing SN,<string> 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:

TeraTerm window showing 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

TeraTerm window showing D command response from module

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

TeraTerm window showing V command

The module will respond with the following:

TeraTerm window showing Firmware Version as a result of V command

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.

TeraTerm window showing the reboot command "R" with a mandatory parameter of 1

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

TeraTerm window responds with "Reboot" and then "CMD"

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.

TeraTerm window showing SFcommand

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 responded with "AOK".

TeraTerm window showing module responding with "AOK".

Back to Top

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:

Back to Top