3pi with NRF24lo1+ Module not working!

Hi all!

I have connected Nrf24lo1+ with 3pi robot with following connections:
and I am using arduino libraries for nrf24 module.

1- I have uncommented #SPI_UART in RF24_config.h file
2- I have changed pins according to my connection in RF24_config.h file and pins_arduino.h
3- I have 2 3pi robots and i want to communicate both robots through their nrf modules.

lib link: https://github.com/tmrh20/RF24

unfortunatly, I haven’t been able to succeed. Kindly help me. Maybe I’m not using the right library
nrf24l01+ pins 3pi Robot pins Arduino library pin mapping
CE PD7 7
CSN PB0 8
SCK PD4 4
MISO PD0 0
MOSI PD1 1
IRQ PD2 2

SENDER CODE:

/*
* Getting Started example sketch for nRF24L01+ radios
* This is a very basic example of how to send data from one node to another
* Updated: Dec 2014 by TMRh20
*/

#include "RF24.h"
#include <SPI_UART.h>
//#include <SPI_UART.cpp>
#include <Pololu3pi.h>
#include <PololuQTRSensors.h>
#include <OrangutanMotors.h>
#include <OrangutanAnalog.h>
#include <OrangutanLEDs.h>
#include <OrangutanLCD.h>
#include <OrangutanPushbuttons.h>
#include <OrangutanBuzzer.h>
//#include "printf.h"

#define PD_7 7
#define PB_0 8
#define PD_4 4
#define PD_0 0
#define PD_1 1
#define PD_2 2


/****************** User Config ***************************/
/***      Set this radio as radio number 0 or 1         ***/
bool radioNumber = 1;

/* Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 & 8 */
RF24 radio(PD_7,PB_0);
/**********************************************************/

byte addresses[][6] = {"1Node","2Node"};

// Used to control whether this node is sending or receiving
bool role = 1;

void setup() {
  
pinMode(PD_7,OUTPUT);
pinMode(PB_0, OUTPUT);
pinMode(PD_4,OUTPUT);
pinMode(PD_0, INPUT);
pinMode(PD_1, OUTPUT);
pinMode(PD_2,OUTPUT);

  
  radio.begin();

  // Set the PA Level low to prevent power supply related issues since this is a
 // getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
  radio.setPALevel(RF24_PA_LOW);
  
  // Open a writing and reading pipe on each radio, with opposite addresses
  if(radioNumber){
    radio.openWritingPipe(addresses[1]);
    radio.openReadingPipe(1,addresses[0]);
  }else{
    radio.openWritingPipe(addresses[0]);
    radio.openReadingPipe(1,addresses[1]);
  }
  
  // Start the radio listening for data
  radio.startListening();
}

void loop() {
  
  
/****************** Ping Out Role ***************************/  
if (role == 1)  {
    
    radio.stopListening();                                    // First, stop listening so we can talk.
    
    
    //Serial.println(F("Now sending"));

    unsigned long start_time = 30;                             // Take the time, and send it.  This will block until complete
     if (!radio.write( &start_time, sizeof(unsigned long) )){
       ;//Serial.println(F("failed"));
     }
     OrangutanMotors::setSpeeds(0,start_time);
        
  
    // Try again 1s later
    delay(1000);
  }



/****************** Pong Back Role ***************************/

  if ( role == 0 )
  {
    radio.startListening();
    unsigned long got_time = 0;
    
    if( radio.available()){
                                                                    // Variable for the received timestamp
      while (radio.available()) {                                   // While there is data ready
        radio.read( &got_time, sizeof(unsigned long) );             // Get the payload
        OrangutanMotors::setSpeeds(got_time,0);

      }
     
      radio.stopListening();                                        // First, stop listening so we can talk   
      radio.write( &got_time, sizeof(unsigned long) );              // Send the final one back.      
      radio.startListening();                                       // Now, resume listening so we catch the next packets.     
      //Serial.print(F("Sent response "));
      //Serial.println(got_time);  
   }
 }




/****************** Change Roles via Serial Commands ***************************/

  

} // Loop

RECEIVER CODE:

/*
* Getting Started example sketch for nRF24L01+ radios
* This is a very basic example of how to send data from one node to another
* Updated: Dec 2014 by TMRh20
*/

#include "RF24.h"
#include <SPI_UART.h>
//#include <SPI_UART.cpp>
#include <Pololu3pi.h>
#include <PololuQTRSensors.h>
#include <OrangutanMotors.h>
#include <OrangutanAnalog.h>
#include <OrangutanLEDs.h>
#include <OrangutanLCD.h>
#include <OrangutanPushbuttons.h>
#include <OrangutanBuzzer.h>
//#include "printf.h"

#define PD_7 7
#define PB_0 8
#define PD_4 4
#define PD_0 0
#define PD_1 1
#define PD_2 2


/****************** User Config ***************************/
/***      Set this radio as radio number 0 or 1         ***/
bool radioNumber = 0;

/* Hardware configuration: Set up nRF24L01 radio on SPI bus plus pins 7 & 8 */
RF24 radio(PD_7,PB_0);
/**********************************************************/

byte addresses[][6] = {"1Node","2Node"};

// Used to control whether this node is sending or receiving
bool role = 0;

void setup() {
  
pinMode(PD_7,OUTPUT);
pinMode(PB_0, OUTPUT);
pinMode(PD_4,OUTPUT);
pinMode(PD_0, INPUT);
pinMode(PD_1, OUTPUT);
pinMode(PD_2,OUTPUT);

  //Serial.begin(115200);
  //Serial.println(F("RF24/examples/GettingStarted"));
  //Serial.println(F("*** PRESS 'T' to begin transmitting to the other node"));
  
  radio.begin();

  // Set the PA Level low to prevent power supply related issues since this is a
 // getting_started sketch, and the likelihood of close proximity of the devices. RF24_PA_MAX is default.
  radio.setPALevel(RF24_PA_LOW);
  
  // Open a writing and reading pipe on each radio, with opposite addresses
  if(radioNumber){
    radio.openWritingPipe(addresses[1]);
    radio.openReadingPipe(1,addresses[0]);
  }else{
    radio.openWritingPipe(addresses[0]);
    radio.openReadingPipe(1,addresses[1]);
  }
  
  // Start the radio listening for data
  radio.startListening();
}

void loop() {
  
  
/****************** Ping Out Role ***************************/  
if (role == 1)  {
    
    radio.stopListening();                                    // First, stop listening so we can talk.
    
    
    //Serial.println(F("Now sending"));

    unsigned long start_time = micros();                             // Take the time, and send it.  This will block until complete
     if (!radio.write( &start_time, sizeof(unsigned long) )){
       ;//Serial.println(F("failed"));
     }
        
    radio.startListening();                                    // Now, continue listening
    
    unsigned long started_waiting_at = micros();               // Set up a timeout period, get the current microseconds
    boolean timeout = false;                                   // Set up a variable to indicate if a response was received or not
    
    while ( ! radio.available() ){                             // While nothing is received
      if (micros() - started_waiting_at > 200000 ){            // If waited longer than 200ms, indicate timeout and exit while loop
          timeout = true;
          break;
      }      
    }
        
    if ( timeout ){                                             // Describe the results
        ;//Serial.println(F("Failed, response timed out."));
    }else{
        unsigned long got_time;                                 // Grab the response, compare, and send to debugging spew
        radio.read( &got_time, sizeof(unsigned long) );
        unsigned long end_time = micros();
        
    }

    // Try again 1s later
    delay(1000);
  }



/****************** Pong Back Role ***************************/

  if ( role == 0 )
  {
    radio.startListening();
    unsigned long got_time = 0;
    
    if( radio.available()){
                                                                    // Variable for the received timestamp
      while (radio.available()) {                                   // While there is data ready
        radio.read( &got_time, sizeof(unsigned long) );             // Get the payload
       // OrangutanMotors::setSpeeds(got_time,0);

      }
     //OrangutanMotors::setSpeeds(got_time,0);
      //radio.stopListening();                                        // First, stop listening so we can talk   
      //radio.write( &got_time, sizeof(unsigned long) );              // Send the final one back.      
      //radio.startListening();                                       // Now, resume listening so we catch the next packets.     
      //Serial.print(F("Sent response "));
      //Serial.println(got_time);  
   }
 }



} // Loop

Hello.

I am not familiar with the nRF24L01+ or with the Arduino libraries you are using. I looked at your code and the only problem I noticed is that the IRQ pin is an output from the nRF24L01+ device, but you are setting it as an output on the 3pi. Also, did you remove the 3pi’s LCD? You should probably do that since you are using LCD pins to control the radio.

It looks like you took the GettingStarted example from the RF24 library and used that as the starting point for your code, but you made some major modifications to the radio code. I suggest that you go back to that example and only make modifications that are absolutely necessary. Your goal should be to get some evidence of radio communication between the 3pis without modifying the example program very much.

–David

Yes I removed the LCD on 3pi. I made IRQ pin as input but i am not able to make it work till now. I am using Getting started example of NRF24 library

I am not sure why your code is not working. I still suggest that you try to make your code as close as possible to the GettingStarted example.

–David