Why is there a Massive Difference?

I am attempting to set up a mesh network with some NRF24L01 transceivers. I have the following libraries from TMRh20’s github: RF24-master, RF24Mesh-master, RF24Network-master. I was trying to get them to send messages through the network, and I kept getting blank on the serial monitor. After accidentally forgetting to close out the serial monitor after another fail attempt, I noticed it now had values (not sent from one to another).

The logical conclusion was that something made it wait so long for this. I put in some extra commands to read where in the code it takes so long, and it turns out it was in the mesh.begin().

The only thing is this only happened with the one code, so now I am confused.

This is the code where it takes a full minute on the begin mesh()

#include <SPI.h>  
#include "RF24.h"
#include "RF24Mesh.h"
#include "RF24Network.h"

RF24 radio (7, 8);
RF24Network network(radio);
RF24Mesh mesh(radio,network);

int data;


void setup()
{
  Serial.begin(9600);
  delay(1000);
  radio.begin();
  mesh.setNodeID(23);
  Serial.println(millis());
 //takes 60 seconds to begin mesh
  mesh.begin();
  Serial.println(millis());
  delay(1000);
}

void loop()
{
  data = analogRead(A0);
  mesh.update();
  uint16_t recipient_address = 00;
  RF24NetworkHeader moisture;
  network.write(moisture,&data,sizeof(data));
  Serial.println(data);
  
}

the first value is around 1000 and the second is about 61500

Here is the other code

#include <SPI.h>  
#include "RF24.h" 
#include "RF24Network.h"
#include "RF24Mesh.h"
RF24 radio (7, 8); 

RF24Network network(radio);
RF24Mesh mesh(radio,network);
RF24NetworkHeader moisture;
void setup() 
{
  Serial.begin(9600);
  delay(1000);
  mesh.setNodeID(0);
  Serial.println(mesh.getNodeID());
  Serial.println(millis());
  //takes about a second to begin mesh
  mesh.begin();
  Serial.println(millis());
  mesh.setStaticAddress(23, 02);
  mesh.setStaticAddress(24, 03);
  mesh.setStaticAddress(0, 00);
  radio.begin();  
}


void loop()  
{
  mesh.update();
  mesh.DHCP();
  if (network.available())
  {network.peek(moisture);
  uint32_t data;
  network.read(moisture, &data, sizeof(data));
     Serial.println(data);}
     else {Serial.println("fail");}
     //Serial.println(data.moisture);
 // Serial.println((-10.32 * (log(data.moisture) / log(2.718)) + 72.66));
  delay(1000);
  }

In this one, both values are very near each other, both around 1000.

It seems like they would do the exact same thing, but for some reason the one code takes so much longer. I tried both codes with multiple Arduinos and multiple transceivers, but the first code always took 60 seconds and the second code always was instant.

Any clue as to why this happens? Also if you are good with this code, it would be great if you could point out where the code itself is wrong (as in why it doesn’t send properly).

You appear to be writing a 16 bit value (data is an int) and reading a 32 bit value (uint32_t).
Make them both the same data type.

Since you are trying to join a mesh I'm guessing the mesh.begin() is looking for other members of the mesh. Maybe that takes a long time if there are no members in reach? Perhaps NodeID 0 is special and doesn't need other members to start.