Why is there a Massive Difference?


i attempting set mesh network nrf24l01 transceivers. have following libraries tmrh20's github: rf24-master, rf24mesh-master, rf24network-master. trying them send messages through network, , kept getting blank on serial monitor. after accidentally forgetting close out serial monitor after fail attempt, noticed had values (not sent 1 another).

the logical conclusion made wait long this. put in commands read in code takes long, , turns out in mesh.begin().

the thing happened 1 code, confused.

this code takes full minute on begin mesh()
code: [select]
#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 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 around 1000 , second 61500

here other code
code: [select]
#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 second 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 one, both values near each other, both around 1000.

it seems exact same thing, reason 1 code takes longer. tried both codes multiple arduinos , multiple transceivers, first code took 60 seconds , second code instant.

any clue why happens? if code, great if point out code wrong (as in why doesn't send properly).

you appear writing 16 bit value (data int) , reading 32 bit value (uint32_t).
make them both same data type.


Arduino Forum > Using Arduino > Programming Questions > Why is there a Massive Difference?


arduino

Comments

Popular posts from this blog

Error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode - Raspberry Pi Forums

class MPU6050 has no member named begin

missing filename after '-o'