If you are looking for a way to create your own Bluetooth Low Energy (BLE) services and characteristics with Arduino, you may want to consider the RN4870 1 module from Microchip. This module is a small (only 12mm wide) BLE device that supports full BLE 4.2 functionality, including secure AES128 encryption, keyboard I/O authentication, scripting engine for hostless operation, and more. In this article, we will show you how to get started with Arduino and RN4870 1, and how to use the UART transparent service for serial data over the air.
What You Need
To follow this tutorial, you will need:
An Arduino board (we used a Beetle BLE)
An RN4870 1 module (we used the RN4870-V/RM118 version with antenna and all pins available)
A breakout board for the RN4870 1 module (you can make your own or buy one online)
Some jumper wires and a breadboard
A USB cable to connect the Arduino to your computer
The Arduino IDE installed on your computer
A BLE scanner app on your smartphone (we used nRF Connect)
Here is how to connect the Arduino and the RN4870 1 module:
The RN4870 1 module communicates with the Arduino via UART, so we need to connect the TX and RX pins of both devices. We also need to connect the VCC and GND pins to provide power to the module. Optionally, we can connect a LED to pin 13 of the Arduino to indicate when data is received.
This code uses the SoftwareSerial library to create a serial communication between the Arduino and the RN4870 1 module. The module operates at a default baud rate of 115200, so we need to match that in our code. The code also uses a buffer array to store the incoming data from the module until an end of line character (\\n) is received. Then, it prints the buffer content to the serial monitor and toggles a LED state. This way, we can see what data is sent from the module and when.