NRF24 and arduino 2560

Hello,
Hope you can help me solve a mystery around an NRF24 module.
I never had a big problem using this chip with µc nano 328P, but using 2560s it doesn’t work properly.

I am using the Mirf library with the ping_client ping_server example.
My pins are mounted like this:
MOSI - ICSP-4
MISO - ICSP-1
SCK - ICSP-3
CSN- D42
CE -D44
V- 3v3
G-gnd

I have

When I don’t touch the board, nothing works. if I put a finger close to the ISPs, the system operates with a very long latency. IF I simply touch the ISP1 pin of the board (MISO) with my fingertip, the system works with a latency of 20ms

Here is what I get from the serial port:

00: 49: 29.208 → Pingback: 257060
00: 49: 30.238 → Finished sending
00: 49: 30.238 → Ping: 258080
00: 49: 31.223 → Finished sending
00: 49: 31.223 → Pingback: 259100
00: 49: 32.255 → Finished sending
00: 49: 32.255 → Pingback: 260119
00: 49: 33.286 → Finished sending
00: 49: 33.286 → Pingback: 20
00: 49: 34.275 → Finished sending
00: 49: 34.322 → Pingback: 23
00: 49: 35.304 → Finished sending
00: 49: 35.304 → Pingback: 24
00: 49: 36.343 → Finished sending
00: 49: 36.343 → Pingback: 20

Has anyone ever encountered this kind of weirdness with an NRF24 on 2560?

Here is the sample code:

   A Mirf example to test the latency between two Ardunio.

   Pins:
   Hardware SPI:
   MISO -> 12
   MOSI -> 11
   SCK -> 13

   Configurable:
   CE -> 8
   CSN -> 7

   Note: To see best case latency comment out all Serial.println
   statements not displaying the result and load
   'ping_server_interupt' on the server.
*/

#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>

void setup() {
  Serial.begin(115200);
  Mirf.csnPin = 42;
  Mirf.cePin = 44;
  /*
     Setup pins / SPI.
  */

  /* To change CE / CSN Pins:

     Mirf.csnPin = 9;
     Mirf.cePin = 7;
  */
  /*
    Mirf.cePin = 7;
    Mirf.csnPin = 8;
  */
  Mirf.spi = &MirfHardwareSpi;
  Mirf.init();

  /*
     Configure reciving address.
  */

  Mirf.setRADDR((byte *)"clie1");

  /*
     Set the payload length to sizeof(unsigned long) the
     return type of millis().

     NB: payload on client and server must be the same.
  */

  Mirf.payload = sizeof(unsigned long);

  /*
     Write channel and payload config then power up reciver.
  */

  /*
     To change channel:

     Mirf.channel = 10;

     NB: Make sure channel is legal in your area.
  */

  Mirf.config();

  Serial.println("Beginning ... ");
}

void loop() {
  unsigned long time = millis();

  Mirf.setTADDR((byte *)"serv1");

  Mirf.send((byte *)&time);

  while (Mirf.isSending()) {
  }
  Serial.println("Finished sending");
  delay(10);
  while (!Mirf.dataReady()) {
    //Serial.println("Waiting");
    if ( ( millis() - time ) > 1000 ) {
      Serial.println("Timeout on response from server!");
      return;
    }
  }

  Mirf.getData((byte *) &time);

  Serial.print("Ping: ");
  Serial.println((millis() - time));

  delay(1000);
}`

Thank you in advance for your help :slight_smile:

The easier you make it to read and copy the code the more likely it is that you will get help

Please follow the advice given in the link below when posting code

thank you for your answer, the formatting of the post is corrected