RN4020 Explore Command Mode
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
- RN-4020-PICtail
- RN4020 Bluetooth Low Energy PICtail™/PICtail Plus
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.
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.
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 in the accompanying image.
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 responded with "AOK".
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:
- RN4020 Bluetooth Low Energy Module User's Guide
- RN4020 Bluetooth Low Energy Module Datasheet
- RN4020 PICtail™/PICtail Plus Board User’s Guide