Page 1 of 1

L432KC and NRF24L01

Posted: Sun Jun 20, 2021 12:17 am
by spookyy524
I cannot get these L432KC nucleo boards communicating over NRF24L01 transceivers. I am very confident on the wiring as I have checked it many times so I feel like it is somehow a software issue. However, running the exact same code on two f411RE nucleo boards it works perfectly. I need to get the two L4 boards communicating for this project and I need help!

I have attached my transmit and receive code below and I would really appreciate any advice!

Transmit:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7,8); //CE, CSN

const byte address[][6] = {"05140", "05141"};
const int buttonPinOpen = 3;
const int buttonPinClose = 4;

int buttonStateOpen = 0;
int buttonStateClose = 0;

void setup() {
Serial.begin(9600);

pinMode(buttonPinOpen, INPUT);
pinMode(buttonPinClose, INPUT);


radio.begin();
radio.openWritingPipe(address[0]);
radio.setPALevel(RF24_PA_MAX);
radio.setChannel(125);

}

void loop() {
buttonStateOpen = digitalRead(buttonPinOpen);
buttonStateClose = digitalRead(buttonPinClose);

if (buttonStateOpen == HIGH){
const char text[] = "Open door";
if(radio.write(&text, sizeof(text))){
Serial.println("it did it");
}
Serial.println(text);
}
if (buttonStateClose == HIGH){
const char text[] = "Close door";
radio.write(&text, sizeof(text));
Serial.println(text);
}

delay(500);

}




The receive code:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
//#include <LiquidCrystal.h>

//const int rs = 9, en = 10, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
//LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
//int backLight = 15;

int a = 7; //pinMap(Mapped Pin) - for mapped pin refer the attacted image
int b = 8;


RF24 radio(a,b); //CE, CSN

const byte address[][6] = {"05140", "05141"};



void setup() {
Serial.begin(9600);

//pinMode(backLight, OUTPUT);
//digitalWrite(backLight, HIGH);
//lcd.begin(16, 2);
//lcd.print("hello, world!");


radio.begin();
radio.openReadingPipe(0, address[0]);
radio.setPALevel(RF24_PA_MIN);
radio.setChannel(125);
radio.startListening();


}

void loop() {
if(radio.available()){
//lcd.clear();
char text[32] = "";
radio.read(&text, sizeof(text));
Serial.println(text);
Serial.println("we");
//lcd.print(text);
delay(500);
//lcd.clear();

}
else{
//Serial.println("whoopsies");
//lcd.clear();
}

}


Would appreciate any advise!

Re: L432KC and NRF24L01

Posted: Sun Jun 20, 2021 8:00 am
by ag123
check if spi is working e.g. read the status registers etc from nrf24

Re: L432KC and NRF24L01

Posted: Sun Jun 20, 2021 8:43 am
by fpiSTM
Pay attention to the pin configuration. Lot of soldier bridges and same pins available on different headers...

Re: L432KC and NRF24L01

Posted: Sun Jun 20, 2021 9:09 am
by fro
I'd advise to:
- check the return value from radio.begin() (https://nrf24.github.io/RF24/classRF24. ... e6fb9c4ba8)
- try to explicitly specify the SPI pins (e.g. https://github.com/stm32duino/wiki/wiki ... tance-pins)
- check the Nucleo pins you are using again as fpiSTM suggests (https://www.st.com/resource/en/user_man ... ronics.pdf)
- glance over code examples in https://forum.arduino.cc/t/simple-nrf24 ... emo/405123