Go Down

Topic: Bi-directional communication between Arduinos pro Mini´s with NRF24L01 (Read 85 times) previous topic - next topic

rodrigocirilo

Hi guys, I need some help.

I made a simple code to make a bi-directional communication between two Arduinos.

When pressing the button on any one of them, the other receives the info and flashes the led.

When loading the code I change the radioID to have the reverse pipes between them.

Well, on one side I send the signal and the other receives it, conversely the information does not go.

I inverted the NRF24L01 between the Arduinos and the same thing continues, the NRF that sent starts to receive what it received starts to send, but it seems that it is something on the Arduino, because the LED on pin 13 of the pro mini is the SCK pin of the SPI, in an arduino it behaves in a way when sending the info it erases right afterwards it lights up, in the other that receives more it does not send it blinks fast, then afterwards it erases and lights up again.

my code:





Code: [Select]
#include <nRF24L01.h>
//#include <SPI.h>
#include <RF24.h>

#define radioID 0
RF24 radio(7, 8);

char text[32] = "";
const char texto[] = "nrftest";

byte node_A_address[6] = "NodeA";
byte node_B_address[6] = "NodeB";


//-------------------------------------------------------------------------------------
// SETUP  SETUP  SETUP  SETUP  SETUP  SETUP  SETUP  SETUP  SETUP  SETUP  SETUP  ///////
//-------------------------------------------------------------------------------------
void setup()
{
  pinMode(2, OUTPUT);
  pinMode(10, INPUT_PULLUP);
  radio.begin();


 #if radioID == 1
  radio.openWritingPipe(node_B_address);
  radio.openReadingPipe(1, node_A_address);
 #else
  radio.openWritingPipe(node_A_address);
  radio.openReadingPipe(1, node_B_address);
 #endif 
 
  radio.setPALevel(RF24_PA_MIN);
  radio.setDataRate(RF24_250KBPS);
  radio.startListening();

delay(500);
}

void loop()
{
  if(radio.available() )
  {
      radio.read( &text, sizeof(text) );   
     String transData = String(text);
    if(transData == "nrftest")
     {     
       digitalWrite(2, HIGH);
       delay(50);
       digitalWrite(2, LOW);
       delay(5);
       transData = "";
     }
  }

  if(!digitalRead(10))
  {
     radio.stopListening();
     delay(50);
     radio.write(&texto, sizeof(texto) );
     delay(250);
     radio.startListening();
  }
}
 

rodrigocirilo

well, after a lot of software analysis, I saw that the NRF24L01 had a cold solder at the SCK termination, I solved it and solved the problem.

groundFungus

Code: [Select]
pinMode(10, INPUT_PULLUP);
If you are using SPI, pin 10 must be an OUTPUT even if it is not used as the slave select.

 See the SPI reference.

Since this library supports only master mode, this pin should be set always as OUTPUT otherwise the SPI interface could be put automatically into slave mode by hardware, rendering the library inoperative.
You will save everyone's time if you read and follow the forum guidelines.  :)           
https://forum.arduino.cc/index.php/topic,148850.0.html

Go Up