Arduino with RN4870/1

RN4870_01_800The RN4870/1 is a small (only 12mm wide) BLE module from Microchip. What makes this a little bit special (when compared to modules like the HM-10) are the advanced features that allow you to create your own services and characteristics. This opens up true BLE functionality.

The RN4870 is very different to common hobbyist modules like the HM-10, AT-09, and BT05 and if this is all you have used you may need a refresher on BLE. Especially if you want to use your own services and characteristics.

It has been available for a while now and I am surprised it is not more popular in the hobby area.

This is a first look / getting started guide that I will add to as I get time.

RN4870/1 Features

  • Fully Qualified Bluetooth 4.2
  • Low Energy Module
  • Certified to FCC, IC, CE, KCC, NCC and SRRC
  • On-Board Bluetooth 4.2 Low Energy Stack
  • ASCII Command Interface API over UART
  • Scripting Engine for Hostless Operation
  • Beacon Private Service for Beacon Services
  • UART Transparent Service for Serial Data
  • Over The Air Remote Configuration

The RN48709/1 is configured using ascii commands similar to other BT modules. The main difference s that the The RN48709/1 has it’s own set of unique commands and does not use AT style commands. It also has a mini programming language built in. This means, depending on what you want to do, you may not need a MCU like the Arduino, the RN48709/1 can be used stand alone.

The UART Transparent Service for Serial Data allows an easy way to link 2 modules together. This can be considered a serial cable replacement, however, if this is all you need you may be better suited with the HM-05/06 or HM-10.

The The RN48709/1 has full BLE 4.2 functionality:

  • Secure AES128 Encryption
  • GAP, GATT, SM, L2CAP and Integrated Public Profiles
  • User Can Create up to Five Public and Four Private Services
  • Software Configurable Role as Peripheral or Central and Client or Server
  • Keyboard I/O Authentication

The RN4870/1 is available is a few different sizes/configurations. With shielding, without shielding, with antenna, without antenna, all pins available, only basic pins available.

Image from the Microchip RN784z data sheet.

Image from the Microchip RN4870/1 data sheet.

The ones I have are the RN4870-V/RM118 version. With antenna and all pins available.

These modules are more expensive that the common hobbyist modules like the HM-10 but they far more advanced, well supported with full data sheets and a user forum. Most questions, if not all, will have already been answered on the forum.

The RX4870/1 is a very small SMD board which makes it a little difficult for hobbyists. A basic breakout board can be built if you have fairly steady hands. Here is my rather lack lustre attempt. I mounted the module upside down so that I still have access to the pads should I need to add more connections later.
Not the best soldering I have ever done but the board is very small and the iron tip has seen better days.
RN4870_02_usbAdapter_800The connections are arranged to match the usb/serial adaptor I am using plus an extra GND.

I am surprised that there are not more pre-made breakout boards for this module. The only one I can find is the RN4870/1 Click from MikroElektronika.


Pins & Basic Circuit


The pins we are initially interested in are:
Pin 3 – GND
Pin 4 – VBAT (3.3v vcc in)
Pin 23 – UART_TX
Pin 22 – UART_RX
These are all you need to use the module but it is a good idea to add a LED to Pin 30 so you know if it is on or not.

The data sheet has full details for the other pins.


New modules have a basic beacon set up and we can use this to test if the module is working or not. For this just add vcc and GND. Remember these are 3.3v devices so use 3.3v not 5v.

Power the module, then use a BLE scanner app to find the beacon. Here I am using Android BLE Scanner by Bluepixel Technologies LLP but there are many similar apps.

Open the app, you should see the RN4870 (it may not have the same name),
connect to it,
open the first characteristic (Generic Access 0x1800, this is the device name)
read the characteristic data by clicking the small R icon
You should get the name again.

Now we know it is working we can try talking to it through a serial terminal program, something like Tera Term or the Arduino IDE.

Talking to the RN4870/1

To talk to the RM4870/1 we need a usb to serial adaptor. I am using this one but other 3.3v versions will work. Make sure it is 3.3v. At a push you could use a spare Arduino but I don’t go in to this here.

usb-serial-adapterHere is a adapter I am using. 3.3v or 5v can be selected.

Connect the RN4870 to the usb adapter and connect to a PC, note that I am using Windows 7, this will give you s COM port. Mine is COM5. Yours will be different.

For the first few examples I am using the Arduino IDE. The Arduino IDE does not have local echo (it does not display what you have entered) but you can turn on local echo in the RN4870 with the “+” command if you wish. Use the “+” command after entering data mode.

RN4870_11_serialMonitor_02If you check the data sheet you see that it has a default baud rate of 115200 and all commands require a carriage return CR character (\r).

The RN4870 can operate in data mode or command mode. It is in data mode by default so we need to change to command mode using the “$$$” command. Small caveat though, Microchip do not class “$$$” command as a command and it only works when there is no line end character. This really should be stated in the data sheet. So change the line endings to “No line ending” and enter $$$:

If the world loves you, or even likes you just a little bit, you will get a “CMD>” reply.

To return to data mode use “—\r”. This is 3 dash or minus characters + CR.

Now change the line endings back.

There are only a few commands that just return data. One of them is “V” and this returns the firmware version.
Here you can see that the modules I have are using firmware V1.18.3. This is not the latest and I will look at updating it later. The latest firmware, at the time of writing, is v1.28.3.

“GNR” gets the name of the connect device. Of course, for this to work the module as to be connected to something. With the serial monitor still open. Use the BLE scanner app to connect to the RN4870.

When the module connects it sends the connection details to the serial monitor:

Now we have a connection we can get the name of the connected device with “GNR”

When you break the connection, the RN4870 outputs a “%DISCONNECT%” message.

This post will continue as I get time.

Leave a Reply

Your email address will not be published. Required fields are marked *

+ eight = 14

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>