External nRF52840 module on STM32 MCU

Hi,

Currently I am trying to integrate a nRF52840 DK with my STM32 L4 board, but I can’t seem to find any existing solution to communicate between the two boards.

I have read this question External nRF51822 module? - Question | Mbed (from 4 years ago) and would like to know if there’s any update to external nRF module support on mbed.

I am aware of other solutions like RedBearLabs with a nRF8001 shield which can be serialized with an application board over SPI, but does this mean I have to use hardware-specific libraries for nRF external bluetooth modules and therefore unable to utilise mbed’s BLE API?

What are other alternative external BLE modules I can use in conjunction with an application board (STM32 L4) using mbed?

Many thanks in advance!

1 Like

Hi,

Can you use UART?
nRF52840 DK should have more than enought power to run MbedOS. Do you need external application board?
This is one example of external BLE module:
https://os.mbed.com/components/X-NUCLEO-IDB05A1/

Regards,
Pekka

@ziqiyap that’s a really good question that I’ve been asking myself.

PR #12456 will bring the ability to use ST’s BlueNRG-MS module as an external module and communicate to it through HCI.

In the case of nRF52840 DK it is not yet possible to do that. You’d need to implement the HCI driver and transporter for this module but also pre-program this module to accept incoming commands through SPI or UART.

This means programming the external module + implementing a lot of things for mbed.

One alternate solution that we are investigating would be to program the nRF52840 with the attributes, services, etc., that we need, connect the module to our application mcu through UART (easier I’d say) or SPI and implement a simple custom communication protocol to pass data between the two.

That way you might get the best of both world : SoftDevice for the nRF52840 and mbed for the application mcu. But that still means flashing both the module and the mcu at first.

1 Like

Hi Pekka,

Thanks for your reply. To answer your questions:

  1. UART can be used, but it seems like there’s no interface API for me to talk to the nRF52840 DK board from my STM32 L4 board.
  2. I do need an external application board for my use case – I am hoping to abstract the hardware communication module from my application board (meaning if I want to change my communication module from BLE to WiFi, I do not have to change my application too much)

I have looked into the external BLE module (X-NUCLEO-IDB05A1) and it seems like there needs to be an additional wrapper library in order to use the mbed BLE API for the expansion board: X_NUCLEO_IDB0XA1 - BLE_API wrapper library for STMicroelectronics' B… | Mbed
Makes sense to me, since it’s not possible to “target” the external BLE module in my build.

So my question is: Does all BLE expansion boards (for BLE) require their own additional wrapper library?

Hi Ladislad,

Thank you for your detailed response.
I’m happy to hear that there are efforts to support external BLE modules! Will definitely keep track of this development.

It seems like the SoftDevice on nRF modules does not support HCI

Your alternate solution seems more plausible as it is possible to set nRF module as a communication module using SoftDevice.

The question is how would mbed handle the communication protocol to the external nRF module? It seems like an additional BLE wrapper library will be needed to handle the communication to the external module.

In this case you do not need a BLE wrapper, you just decide on commands you want to send with a specific frame, you receive the frame, read it, act on it and then send data out.

One example could be:

  • from your phone you send a value through BLE to a specific service
  • the BLE module receives it and decides to send the value to the mcu through UART. It sends a communication frame (that you designed) with the value
  • the mcu gets a uart data available and reads the data and decides what to do with it.

You’ll need to work on two separated code base, one for the module, one for the mcu. The communication protocol will be shared.

One other advantage is that in this case you will be able to use the full feature firmware update over the air of the BLE module. That will only update the BLE module.

For the mcu, as you’ll be using UART (I think it’s easier), you can customize the bootloader and also update the firmware through the BLE module.

Ah I understand now!

I was thinking of having my application directly interface with nordic’s SoftDevice protocol stack over UART. I might have made things more complicated that it should be…

I now realise I can write two mbed programs to get the BLE module to talk to my application MCU over UART.

Thank you for your clear explanation!

In an ideal world yes, but they are some known bugs with nRF52840, see

BLE power consumption using CORDIO stack too high

If you’re already using a mcu from ST, I would investigate the BlueNRG-M2. It is not supported by mbed but you can use the ST software suite (MX and Cube) to write the necessary firmware for the module.

Or if you want to stick with nRF52840, take a look at SoftDevice.

My feeling with both is that they seem overly complicated and I don’t like the way the code is written. If power consumption is not an issue for you, stay with mbed for both.

1 Like