1

Hello everyone.

First of all, I know you're going to tell me to send my question on the stm32duino forum. But I tried to enter the stm32duino forum and I didn't succeed (I think their forum is closed). So I'll be happy if you could try to help me here.

So, I want to use the nRF24L01 module to communicate between the STM32 Nucleo-L432KC and the Arduino Uno. such that both the STM32 Nucleo-L432KC and the Arduino Uno will be transceivers.

My nRF24L01 module pin connections are:

For the nRF24L01 module to the Arduino Uno:

  • CE => D7
  • CSN => D8
  • MOSI => D11
  • MISO => D12
  • SCLK => D13

For the nRF24L01 module to the STM32 Nucleo-L432KC:

  • CE => PB0
  • CSN => PB1
  • MOSI => D11 (Other names: PB5, SPI3_MOSI)
  • MISO => D12 (Other names: PB4, SPI3_MISO)
  • SCLK => D13 (Other names: PB3, SPI3_SCLK)

I tried to send data from the Arduino Uno to the STM32 Nucleo-L432KC, and I got the data and everything was OK.

But when I tried to send the data from the STM32 Nucleo-L432KC to the Arduino Uno board, I didn't receive the data in the Arduino Uno (I use the Serial monitor in-order to print the data I receive).

My code:

For the Slave (STM32 Nucleo-L432KC) who send the data to the Arduino Uno:

#include <nRF24L01_STM32.h>
#include <RF24_config_STM32.h>
#include <RF24_STM32.h>
#include <SPI.h>

RF24 myRadio(PB0, PB1); //CE Pin, CSN Pin
//----------------------------------
//Rest of connections to the Nucleo-L432KC:
//   nRF    Nucleo-L432KC
//  MISO      D12 (Other names: PB4, SPI3_MISO)
//  MOSI      D11 (Other names: PB5, SPI3_MOSI)
//  SCLK      D13 (Other names: PB3, SPI3_SCLK)


//My Slave (Nucleo-L432KC) and Master (Arduino Uno) addresses:
const uint64_t pipes[2] = {0xF0F0F0F0AA , 0xF0F0F0F066}; // {Master (Arduino Uno) address , Slave (Nucleo-L432KC) address}

const char test[] = "test"; // junk string to send between the slave and the master in-order to check the communication between them



void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600); //Start Serial communication
  delay(1000);
  //Init SPI config:
  SPI.begin(); 
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);
  //---------------------------

  //Init my nRF radio:
  myRadio.begin();                      //Starting the Wireless communication
  myRadio.setRetries(15, 15);
  myRadio.setChannel(0x4c);             // Set the communication channel
  myRadio.setPALevel(RF24_PA_MAX);      // Set the nRF power level. RF24_PA_MAX => maximum power
  myRadio.openWritingPipe(pipes[0]);    // Set the address of the Master (in-order to send back the requested data). Master address is: pipes[0]
  myRadio.openReadingPipe(1, pipes[1]); // Set the address of the Slave (in-order to receive the commands from the master). Slave address is: pipes[1]

  myRadio.stopListening();              // Set myRadio to transmitter mode (in-order to test the data communication: Slave send requested data to master)
  //---------------------------

}

// Send the data to the master (Arduino Uno) infinitely:
void loop() {
  delay(500);
  myRadio.write(&test, sizeof(test));
}

For the Master (Arduino Uno) who receive the data from the STM32 Nucleo-L432KC:

    // nRF24L01 libraries for Arduino platform:
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
//--------------------------
#include <SPI.h>


RF24 radio(7, 8); // CE Pin (D7), CSN Pin (D8)
//----------------------------------
//Rest of connections to the Arduino Uno:
//   nRF    Arduino Uno:
//  MISO      D12
//  MOSI      D11
//  SCLK      D13

//My Slave (Nucleo-L432KC) and Master (Arduino Uno) addresses:
const uint64_t pipes[2] = {0xF0F0F0F0AA , 0xF0F0F0F066}; // {Master (Arduino Uno) address , Slave (Nucleo-L432KC) address}


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600); //Start Serial communication
  delay(1000);

  //Init my nRF radio:  
  radio.begin();                       //Starting the Wireless communication
  radio.setRetries(15, 15);
  radio.setChannel(0x4c);              // Set the communication channel
  radio.setPALevel(RF24_PA_MAX);       // Set the nRF power level. RF24_PA_MAX => maximum power
  radio.openReadingPipe(1, pipes[0]);  // Set the address of the Master (in-order to receive back the requested data from the slave). Master (Arduino Uno) address is: pipes[0]
  radio.openWritingPipe(pipes[1]);     // Set the address of the Slave (in-order to send the commands to it from the master). Slave(Nucleo-L432KC) address is: pipes[1]

  radio.startListening();              // Set radio to receiver mode (in-order to test the data communication: Slave send data data to master)  
}

// Receive the data from the slave (Nucleo-L432KC) infinitely:
void loop() {
    if (radio.available())              // Looking for the data.
  {
    char text[32] = "";                 
    radio.read(&text, sizeof(text));    // Saving the incoming data
    Serial.println(text);               // Printing the received data on the Serial monitor
  }
}

Both the Arduino Uno and the STM32 Nucleo-L432KC codes were compiled successfully.

Can you please help me and tell me what I'm doing wrong here and how to fix this?

Note: I use for the master and the slave a code that I found from the web (in multiple web pages).

Thank you for your help, Reshef

  • I'd suggest using the bold format for really things that you need to draw attention to and NOT use it for whole sentences. It just makes the post hard to parse through. p.s. a ~picture~ (schematic) is worth a thousand words. Instead of writing down what pin is used for what, a better picture could be conveyed if the schematic of your circuit could be included here instead. – Duck Dodgers Jul 26 at 9:06
  • Also I would remove the header files that you listed in your post. We can see those header files in the code? Right? Then why list them again separately? p.s. you made a nice effort in formatting your post. :) ! – Duck Dodgers Jul 26 at 9:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.