Skip to end of metadata
Go to start of metadata


The RN42 is a Class 2 certified Bluetooth module from Microchip.  It includes an embedded Bluetooth stack that supports SPP and DUN Bluetooth profiles.  A special version of firmware also supports HID Bluetooth profile.  A PCB trace antenna was included on the module to eliminate the need for antenna design and castellated edges make the module simple to solder onto any baseboard.  Any host device can interface with the module through a simple UART interface.  The RN42 supports baud rates up to 3Mbps and SPP data rates up to 300kbps (master).  This page is meant to help familiarize you with these modules.  You will find some useful links and downloads below, as well as some tutorials and design considerations on various features of the module.  The RN-42-EK board was used as a simple evaluation board for the module.

  • RN42-I/RM  -  Class 2 certified Bluetooth module with PCB trace antenna
  • RN-42-EK  -  Eval board for RN42 module
  • RN42 Landing Page  -  Microchip online product page
  • Tera Term  -  Free terminal emulator software for serial communication with PC

Hardware Description


The RN-42-EK board was used to evaluate the RN42 module.


If your computer has a built-in Bluetooth adapter, you can use that to communicate with a single RN42 module.  If you don't have a built-in Bluetooth adapter in your computer, you can still experiment with the RN42...you'll just need two modules.  You can connect the module(s) to your computer using a hard-wired connection.  I would recommend using the RN-42-EK board to evaluate the module since it comes with an on-board USB interface.  You don't need to worry about interfacing with any USB/UART bridge cable.  The RN-42-EK comes with everything you need to start prototyping with the RN42. 

Here are some additional items you might find useful:

Helpful Accessories

RN-42-EK Pin Assignments

Setting Up Your Terminal

Once you have your module hard-wired to your computer, you need to setup your terminal software with the proper settings to properly communicate over UART.  There are many free terminal programs available like Tera Term or RealTerm.  If you are running Windows XP, you will have HyperAccess installed by default.  Tera Term is my terminal emulator of choice.  It supports multiple serial communication protocols, file transfer protocols, and also has a built in scripting language.  For the purposes of this page, we are just interested in simple UART communication, so I will show you how to configure Tera Term to communicate with these modules.

  1. Download Tera Term (link)
  2. Open a Tera Term window
  3. Make sure the RN42 is properly connected to your computer and that it is powered on
  4. Select the "Setup" dropdown from the Tera Term menu bar
  5. Click on "Serial Port"
  6. Select the port corresponding to whatever bridge device you are using.  You may need to wait for the USB driver to finish installing.
  7. Use the following serial settings:
    • Baud:  115,200 (use 9600 if jumper 4 is set)
    • Data Bits: 8
    • Parity: None
    • Stop Bits: 1
    • Flow Control: None
  8. You can leave transmit delay set to zero.
  9. Press OK to apply your changes.

You should be ready to communicate with your module over UART.  To test it out, type the characters '$$$' and you should get 'CMD' as a response.  If not, double check your connections and serial settings.  Make sure all the Ground pins are connected!  If you want to see every character that you type, you can turn on local echo by selecting "Setup" from the menu bar and clicking on "Terminal".  The "Terminal Setup" dialog box has a check box for enabling/disabling local echo.  Also, within the "Terminal Setup" dialog box, I like to set the New-line Receive setting to CR+LF.  That way when you send a command to the RN42, it will send a newline before displaying a response.


RN42 UART Commands


I know you want to start wireless transmission right away without even having to think, but just tap the brakes for a minute.  Let's take a quick look at some of the UART commands as they will be involved in later sections.

There are four types of UART commands for the RN42:

  • Get Commands:  Used for reading configuration
  • Set Commands:  Used for setting configuration.  Need to reboot or power-cycle the device for "Set" commands to take effect.
  • Change/Action Commands:  Used for temporarily changing settings or causing immediate actions
  • GPIO Commands:  Used for manipulating I/O pins

The module must be put in Command Mode in order to properly receive commands.  This is accomplished by sending '$$$' over UART.  You should get 'CMD' as a response indicating the module is in Command Mode.  Type 'X' and press <enter> to view all of the current settings for the module.  To exit Command Mode, send three minus signs and press enter (- - -<enter>).

The image shown to the right displays the serial readout after sending the 'X' command.  We can see the firmware revision and date loaded at the top.  Then we see the General Settings section which includes the module's Bluetooth address, name, UART baudrate, mode of operation, authentication setting, 4-digit pin code, whether or not bonding is enabled, and the remote address stored in memory.  Next, we see the Advanced Settings which are specific to the Bluetooth standard and how you want your link setup.  We won't mess with any Advanced settings on this page.  At the bottom of the readout, we see the Other Settings section.  This is where you can set the Bluetooth profile, CMD character, enable sniff mode, enable low power mode, change the TX power, set/read I/O pins, set/read the sleep timer, enable Debug mode, and switch roles.

I recommend reading through all of the available commands in the Command Reference Guide.  For now, let's just touch on a few important ones.

 Set / Get Authentication Setting
  • Set Syntax: SA,<value><enter>
  • Get Syntax: GA<enter>
  • Factory default authentication setting is '1' which requires a host device to verify it wishes to connect to a remote device.  For auto-connect feature to work, Authentication needs to be set to '0' or '4'.
  • Example:  Set Authentication Setting to Open Mode

 Set / Get Mode
  • Set Syntax: SM,<value><enter>
  • Get Syntax: GM<enter>
  • Read or set the current mode of operation.  By default, the RN42 is set as a slave device (0).
  • Example:  Set Module to Master Mode (1)
 Set / Get Name
  • Set Syntax: SN,<string><enter>
  • Get Syntax: GN<enter>
  • Read current name or set a unique name for the Bluetooth device.
  • Example:  Set module name to 'MyDevice'
 Set / Get Remote Address
  • Set Syntax: SR,<value><enter>
  • Get Syntax: GR<enter>
  • Read or set the address of the remote device you intend to communicate with.
  • Example:  Set Remote Address to '00066663D0BF'
 Set / Get UART Baud Rate
  • Set Syntax: SU,<value><enter>
  • Get Syntax: GU<enter>
  • Change the UART baud rate
  • Example:  Change UART baud rate to 57,600 bps
 Set / Get Transmit Power Setting
  • Set Syntax: SY,<value><enter>
  • Get Syntax: GY<enter>
  • Read or set the transmit power for the RN42
  • Need to reboot module for setting to take effect
  • Example:  Set Transmit Power to -5 dBm
 Restore Factory Default
  • Set Syntax: SF,1<enter>
  • Get Syntax: none
  • Restores all settings to factory default values except for the module name
  • Example:  Restore Factory Settings
 Inquery Scan
  • Syntax:  IN<value1>,<optional value2><enter>
  • <value1> is the scan time in seconds
  • <value2> is the desired COD you are scanning for and is an optional parameter
  • Example:  Perform a 10 Second Scan for Any Bluetooth Device
  • Connect to Known Address Syntax:  C,<address><enter>
  • Connect to Remote Address Stored in Memory Syntax:  C<enter>
  • Displays "Trying" after sending the Connect command
  • Can check connection status using GK command (see below)
  • Example:  Connect to Address 000666674655
 Get Connection Status
  • Get Syntax:  GK<enter>
  • Returns 1,0,0 if connected
  • Returns 0,0,0 if not connected
  • Example:  Check Connection Status
  • Syntax: R,1<enter>
  • Perform software reboot of the device
  • Device needs to be rebooted after changing configuration for the changes to be applied.
  • Example:  Reboot the Device
 Set / Get Pin Direction (GPIO0~7)
  • Set Syntax:  S@,<hex value><enter>
  • Get Syntax:  G@<enter>
  • <hex value> is a 2-byte value
  • First byte of <hex value> contains the GPIO mask (only pins set to '1' will be written)
  • Second byte of <hex value> contains the value to write to the pin (1=output, 0=input)
  • This setting will be lost when power is removed
  • Example:  Set GPIO3 as input and GPIO4 as output
 Set / Get Pin Value (GPIO0~7)
  • Set Syntax:  S&,<hex value><enter>
  • Get Syntax:  G&
  • <hex value> is a 2-byte value
  • First byte of <hex value> contains the GPIO mask (only pins set to '1' will be written)
  • Second byte of <hex value> contains the value to write to the pin
  • For outputs, a value of 1 will set the pin level high, a value of 0 will set the pin level low.
  • For inputs, a value of 1 will set the pull-up resistor, a value of 0 will set the pull-down resistor.
  • Example:  Set GPIO2 high level (assuming GPIO2 is configured as output ahead of time)
 Set / Get Pin Value (GPIO8~11)
  • Set Syntax:  S*,<hex value><enter>
  • Get Syntax:  G*<enter>
  • <hex value> is a 2-byte value
  • First byte of <hex value> has no effect
  • Second byte of <hex value> contains the value to write to the pin (lsb corresponds to GPIO8)
  • GPIO8~11 can only be used as outputs, but G* can still be used to read the current value
  • A value of 1 will set the pin level high, a value of 0 will set the pin level low.
  • Example:  Set GPIO8~11 high


Connecting to Remote Devices

Alright, it's time to get our hands dirty.

Authentication Setting

By default, SSP authentication is enabled on the RN42 module.  That means that the host will receive a prompt and you will need to confirm that you want to pair with the device.  This allows you to easily connect a single RN42 with a PC or Android device.  You simply confirm you want to pair with the slave, and begin wirelessly transmitting data (you may need to enter the default pin 1234 to pair with the device)......but what if you're not using your computer's built-in Bluetooth adapter?  If you have two RN42 modules that you want to automatically connect to each other, the default authentication setting will cause problems.  By default, two RN42 modules won't automatically connect without software configuration.  You'll need to change the authentication setting to a value of either 0 (for Open Mode) or 4 (for Pin Code mode).  Open mode will disable authentication and allow connection without a passcode or verification of any kind.  Pin Code mode will require a 4-digit code to complete the connection.  The default pin code for the RN42 is '1234' which is hard-coded into every module.  Since the pin code matches in each device by default, Authentication setting 4 will allow automatic connection between two RN42 modules.  Here's a breakdown of how to change the Authentication setting (remember if you are connecting a single RN42 to your computer, you don't need to worry about this):

  1. Connect your RN42 to your PC and make sure the module is powered up.
  2. Enter command mode by sending '$$$' (should get 'CMD' response)
  3. Use the SA command to change Authentication setting (SA,0<enter>)
  4. Reboot the device to save and apply changes (R,1<enter>)
  5. Repeat steps 1-6 for the second RN42 module

Automatic Connect

Once authentication is disabled, the module can be bootstrapped to an automatic configuration using the appropriate I/O settings.  To enable automatic communication with no host controller configuration, externally drive PIO3 and PIO6 high on one device and only PIO3 on the second device.  This can be done using external jumpers, dip-switches, or pull-up resistors.  For safety reasons, you should always use a pull-up resistor between the I/O pin and VDD, even if you are using jumpers or dip-switches (see Manipulating GPIO section below for details).  On power up, as long as authentication is disabled, the devices will automatically connect and then any data received over UART will be immediately transmitted to the remote device.  It's a good idea to power the slave device first and wait a few seconds before powering up the master.  The master will typically fail to pair with the slave if they are powered up simultaneously.  When connected, the green LED on the RN-42-EK will turn solid green.

Manual Connect

The connection process can be completely software controlled if desired.  One of the devices will need to be configured as the master.  You can externally drive PIO6 high (with pull-up) to enable auto-master mode, or you can manually configure the module as a master using the SM command.  If you know the address of the remote device you want to connect to, you can hard code the address into the master using the SR command.  If you don't know the address ahead of time, you'll probably want to scan for devices using the I or IN commands.  The IN command is faster, but doesn't return the Bluetooth name (see Command Reference Guide for more information).  Here's a breakdown of how you would use the SM, IN, SR, and C commands to connect to a remote device through software:

  1. Connect two RN42 modules to your PC and make sure each module is powered up.
  2. Setup separate serial ports for each device with the settings listed in the Setting Up Your Terminal section above.
  3. Put each module in command mode by sending '$$$' (should get 'CMD' response)
  4. Configure the first device as a master using the 'SM' command (SM,1<enter>)
  5. For each module, make the Authentication setting '0' or '4' using the SA command (SA,0<enter>)
  6. Reboot the slave device to apply the new configuration using the 'R' command (R,1<enter>)
  7. Have the master perform a 10 second scan using the 'IN' command (IN10<enter>)
  8. If the slave is within range, the master should find it and spit out its address.
  9. Use the 'SR' command to store the address of the remote device (SR,<address><enter>)
  10. Reboot the master device to apply the new configuration using the 'R' command (R,1<enter>)
  11. Enter command mode again on the master by sending '$$$' (should get 'CMD' response)
  12. Use the 'C' command to connect to the address stored in memory (C<enter>)

The screenshot below shows the terminal windows during the manual connection procedure for the master and slave devices on the left and right, respectively.  You can see the slave device was the third device found in the Inquiry scan (Roving Networks devices use the 0x1F00 COD).  There is no feedback in the terminal that you have successfully connected to the remote device except to try sending characters.  After connecting, characters typed in one terminal appeared in the second terminal.  You can physically see the LED turn solid green on each RN-42-EK board when they have successfully connected.

Master (left) and Slave (right) Terminal Output During Manual Connection

Sending Wireless Data

Once the master and slave are connected, the Bluetooth link is seen as a transparent serial (UART) connection between the two hosts.  In the example above, two PC terminal programs were used as the hosts and ASCII characters were used as the data.  However, a microcontroller could also be used as the host controller for the RN42.  Anything transmitted over UART will be received wirelessly by the remote device.  The exception to this is if one of the modules is placed in Command Mode.  As long as a module is in Command Mode, nothing will get transmitted wirelessly.  However, as long as you don't mess with the link settings, the modules will remain connected and wireless transmission will resume once Command Mode is exited (- - -<enter>).

Note:  The "T,1<enter>" command can be used to enable Bluetooth transmission while in Command mode.

Manipulating GPIO

The RN42 has a handful of GPIO pins that can be used for miscellaneous purposes.  If you are using a microcontroller or FPGA to control the RN42, this gives you the opportunity to increase your I/O count.  If you are using a terminal program as your host, it gives you some command based control over some digital I/O pins.  Most GPIO pins are used by the firmware in some way.  I would recommend not using the GPIO if you don't need to.  If you need to use the GPIO pins on the RN42, I would recommend using GPIO9~11.  These pins can only be used as outputs, but they aren't used by the firmware in any way.  GPIO3 and GPIO6 can be used if auto-connect isn't desired and could be used as digital inputs. 

Here is a breakdown of the GPIO pins on the RN42 and how they are used by firmware.

Available GPIODefault FunctionApplicable UART Commands
GPIO2Output - Status Pin (1=connected, 0=disconnected)Not recommended for miscellaneous use.
GPIO3Input - Auto discovery (high to enable)SQ,4  S@  S&  S%  S^
GPIO4Input - Restore Factory DefaultsNot recommended for miscellaneous use.
GPIO5Output - Status Pin, toggles based on state, low when BT connectedNot recommended for miscellaneous use.
GPIO6Input - Set BT Master (1=auto master)SQ,4  S@  S&  S%  S^
GPIO7Input - Set UART Baud Rate (1=9600, 0=115200/firmware control)Not recommended for miscellaneous use.
GPIO8Output - RF data TX/RXNot recommended for miscellaneous use.
GPIO9Input - pull-down enabledG*  S*
GPIO10Input - pull-down enabledG*  S*
GPIO11Input - pull-down enabledG*  S*


See the RN42 UART Commands section above for command-based usage of these pins.

Note: If you are designing a custom board and plan on utilizing GPIO3, 4, 6, or 7 and their hardware bootstrapping features, you need to use pull-up resistors between these pins and Vcc, even if you are using jumpers or dip-switches.  If you don't use pull-ups and connect Vcc directly to one of these pins, it will be fine as long as they are configured as inputs.  But if you unintentionally configure one as an output, and Vcc is connected to one or more of these pins, you will have a dead short from VCC to GND which could wreck your module and/or power supply.  There is no downside to adding pull-up resistors other than it takes a little bit more board space and adds pennies to your design cost.  Both are negligible tradeoffs for most applications.  You've been warned...do yourself a favor and USE PULL-UPS.

Restoring Factory Settings

There are a variety of reasons why you may want to restore factory settings.  You could have misconfigured something and want to start from scratch.  Maybe you are pulling a module from the field and want to restore factory settings while it sits on a shelf.  It's also possible that you are unable to communicate with the module locally due to UART baud rate or framing issues.  Whatever the reason, rest assured there are a couple of ways to restore factory default values.

Hardware Restore

If you are unable to communicate with the module locally over UART, or if it's simply more convenient to perform a hardware restore, GPIO4 can be used in a special sequence to restore factory settings to the RN42.  It's typically recommended to break out GPIO4 to a jumper or dip-switch with a pull-up to VDD to make it easy for the user to control GPIO4 externally.  Here is the procedure for a hardware restore:

  1. GPIO4 must be pulled high on power up.  The green LED on the eval kit will blink 2-3 times very quickly on power-up indicating that it's watching for the rest of the sequence.
  2. Toggle GPIO4 low.
  3. Toggle GPIO4 high.
  4. Toggle GPIO4 low.
  5. Toggle GPIO4 high.  The green LED on the eval kit will blink 2-3 times very quickly indicating that the module has been reset.

It's recommended to wait approximately 1 second between toggling GPIO4.

Software Restore

If UART communication with the RN42 is readily available, it's very easy to restore factory settings using the SF command.  The SF command will reset all settings except the module's Bluetooth Name.  Here is the procedure for a software restore.

  1. Power the module up and setup the UART link.
  2. Put the module in command mode by sending '$$$' (should get 'CMD' response)
  3. Use the SF command to restore factory default values (SF,1<enter>)
  4. Reboot the device to apply the settings using the 'R' command (R,1<enter>)

You can verify settings were restored by entering command mode and sending the 'X' command.

Contact the Author

The purpose of this page was to help you get started with RN42 modules and make it easier for you to implement them in your own design.  They are very handy modules that make Bluetooth communication easy to achieve and take care of much of the required FCC testing for you.  However, they do have a few quirks to them that can be frustrating at times and I hope this page eliminates some of that frustration.  If you have questions, feedback, or would like to see something added to the wiki, let me know at eewiki@digikey.com.  I hope you enjoy experimenting with the RN42 from Microchip!

   -   Scott S.



  • No labels