Arduino BLE connection with RN4871U-V module

Hi

I want a Bluetooth BLE chip like the DFRobot Beetle BLE connect to an RN4871U-V module.
Could it be possible with the Beetle, or do I need something else in order to get a connection working?

The goal is, that when the Beetle (or another arduino style device with BT BLE) gets power, it should automatically connect to the RN4871U-V module and receive sensor-data. (from the RN4871)

In the manual of the RN4871 https://cz.mouser.com/datasheet/2/268/RN4870_71_Data_Sheet_DS50002489E-2005789.pdf
is written:
The RN4870 supports two built-in GATT services:

  • Device information public service
  • UART transparent private service, which handles data streaming function

Does this mean I could use the Beetle BLE to connect to this chip with a correct programmed sketch?

Thanks.

Welcome to the forum.

Why do you want to use this module?

Same question, why do you want to use this one?

Both honest questions, because if you need to use one for a specific reason, it will set some parameters.

BLE uses a Generic Attribute Profile (GATT). There are two devices a peripheral/server and a central/client. The peripherals have characteristics (data you can read or/and write) and services (collections of characteristics).

To make life "easier" for you some devices already implement some services. But that means the other side needs to support that service. If the other device supports a different service to make life "easier" it will not work. So, when you use two devices of the same kind you may have a easier life (not really).

When you use a device that support the ArduinoBLE library, setting up GATT is as easy as it gets.

If you have the GATT information from another device, you can implement that after looking at one or two examples.

If you can answer the questions above and maybe also tell me, how do you intend to program the other devices (tool and library), I can provide some more specific information.

Hi Klaus (bist du auch deutscher? ),
thank you very much for answering.

I have to connect to the RN4871U-V module, because I want to build a Lightgun for the PC.
For that Lightgun I want to use a modified Airsoft Gun with a Mosfet Board inside.
This mosfet Board has optical sensors on it, so every time the trigger is pressed or the selector plate of the gun is moved, these sensors will register it.
On the Board itself is a BLE chip to connect to a smartphone app for changing things.
I talked to the development department of that company, and they told me, that on the Mosfet board I want to buy, the RN4871U-V module is used.
With the android App "Serial Bluetooth Terminal", I can connect to this Board and see the Sensor Data in real-time.
This is the board:
https://www.jefftron.net/leviathan/leviathan-v3

The DFR Beetle would be the perfect fit size wise, because it's tiny, and I would have enough room to store it in the Airsoft.
After that, the sensor data from the mosfet board have to go to a device like the beetle.

Then there is a second arduino I'm using for this project.
On this one there is already an IR camera mounted and a software installed. This software translates the IR camera movements into mouse coordinates. The software is called "Gun4IR".
On the arduino with the "gun4ir" software on it, you can solder cables to the pins. One Pin is for the trigger, the others are for various Buttons you can connect.

I thought that I could connect the Beetle Pins to that "gun4ir" Arduino.
So every time the optical sensors of the mosfet board registers a specific movement, the Beetle gets that Info via Bluetooth and send it directly to the other Arduino with a wired connection. *in theory

Well, I thought at first I have to know what Hardware I can use for that job. :slight_smile:

OK, so you are fixed on the RN4871U-V module. You will need to figure out whether you can write a sketch for the DFR Beetle that will allow you to create characteristics and services.

With these products software is equally important.

I had a look at the jefftron app in the iOS store and it looks like there are quite a lot of options. You will need to do some re-engineering if you want to make use of all of them. Just reading the sensor data is probably fairly easy.

It may still be a good idea to get a Arduino Nano 33 IoT. It is the cheapest BLE enabled Arduino for the ArduinoBLE library. It will be useful as a reference when something does not work.

Thanks, Klaus, for looking into it :wink:

Alright, so even if I get a code running on the Nano 33 IoT, that doesn't mean it would run on a beetle, right?

You mean the software that comes with the hardware? Or the software I'm going to write for these devices?

The company owner showed me how I can read the sensor data in real time. At least in the android app "serial bluetooth terminal". In this app, I just have to send a command with the factory password he provided me. Then the device is sending the data.
Would it be a good idea to ask him what kind of services his BT chip has implemented?

I think it's a good idea to get the Nano 33 IoT at first. These devices are fairly cheap anyway. Do I need something else?

Thanks for your time!

The RN4870 supports two built-in GATT services:
Device information public service
UART transparent private service, which handles data streaming function
The company owner showed me how I can read the sensor data in real time. At least in the android app "serial bluetooth terminal". In this app, I just have to send a command with the factory password he provided me. Then the device is sending the data.
Would it be a good idea to ask him what kind of services his BT chip has implemented?

If the Serial Bluetooth Terminal is the one from Kai Morich, then it makes sense that it would recognize, write to, and read from this device.

The app documentation says that the BLE implementation by Bluetooth Serial Terminal includes UUIDs for several widely used serial profiles

  • Nordic Semiconductor nRF51822 (Nordic UART Service)
  • Texas Instruments CC254x
  • Microchip RN4870/1
  • Telit Bluemod

Here's the documentation of Microchip RN4870 transparent uart service.
https://microchipdeveloper.com/wireless:ble-mchp-transparent-uart-service

Thanks cattledog.
Sorry for the noob question, but how can I use this information? All these Transparent UART Service examples are for using android. Does this mean I could adapt this to an Arduino?

I found a github page for a RN4870 library.

could this be the right way to start experimenting with getting a connection from the Arduino to the RN4871?
Or is this library only for configuring the RN4870 chip?

I'm still not sure where to start.

No. It is for using a SmartEverything board (Arrow Electronics?) for bidirectional communication with that chip as well as configuration. I think it is some sort of M0 board with an integrated bluetooth module.

There is a posting on the github library page that says

This library has been developed to support the RN4870 on the SmartEverything Board that actually is ArduinoZero/GenuinoZero Hw compatible.

I'm still not sure where to start.

Me neither, but probably not with that library.

You have talked about using a Beetle BLE which I understand has an AT328 processor and uses an onboard bluetooth chip CC2540. I believe that chip supports a UART GATT service compatible with the Microchip RN4870.

I have no knowledge of a Beetle BLE, so all I can say is to start working with it and learn how to write BLE UART code with it. I think the cc2540 is similar to and HM10, so you might be able to find some information there.

I found with communication sketches; it is useful to have at least two devices. For peripheral devices you can use a generic BLE app on your smartphone. For writing the central device sketch (which you must do because the RN4871 is a peripheral) you may be able to use a BLE app to create a BLE peripheral but with a second Arduino this is going to be a lot easier.

I do not have a RN4871, but I created a peripheral sketch that implements these characteristics. I already wrote most of the code for a central device. When you have the hardware, I can provide you the example as a starting point.

I suspect the beetle does not use the ArduinoBLE library. You would need to rewrite the code using the functions provided by the BLE library for the beetle. The overall principle should be the same, but the classes and function are very likely different.

Ok, thanks for pointing that out.
I received an answer from DFRobot, they just told me:
„Ordinary Bluetooth module can establish a connection after the master-slave configuration is configured through the AT command, as long as the connection is established once, it can be automatically connected in the future
Regarding the RN4871U you mentioned, we have not tested it and cannot be sure“

I get what you're saying but the RN4871 should act as a master, as far as I understand, right?
So you suggest that I should maybe start with two Nano 33 IoT´s?
Or perhaps one Nano ioT as the peripheral device (configured with your sketch to act as a master like the one on the optical board) and than try to connect with a Beetle BLE?
I see it coming.. In the end I will end up with two Nanos and a Beetle haha.. but why not

Sounds like fun

There is no master/slave in BLE unlike in SPI.
The RN4871 is a peripheral/server and your device will be the central/client. The peripheral decides the rules (services, characteristics and their properties). The central starts the connection and decides what to read/write and when. Both peripheral and central can end the connection.

Got it, thanks! :wink:
So you wrote a sketch that I can use for the Nano 33 IoT, that have the characteristics from the RN4871. So in theory, when I get a connection working with a nano33 on which your sketch is running and the other Nano33, it possibly will work with the optical board, right?
Do you have a github page where I can download it?