radio.read() not reading complete message

I’m building a data acquisition system and learning Arduino at the same time. I thought I had the communications part worked out but for some reason it’s not behaving very well. I’m sure this is just a simple oversight but I don’t see it. I’d appreciate it one of you Arduino Geeks can point me in the right direction.

System setup:
2 Arduino UNOs (1 Xmit, 1 Rcv.)

Xmit Uno currelntly has:
Diymore DS3231 AT24C32 IIC RTC
2004A 4 line LCD display[/li][/list]
MakerFocus NRF24L01+PA+LNA Xceiver[/li][/list]

Rcv Uno:
MakerFocus 2pcs NRF24L01+PA+LNA Wireless Transceiver and noting else;

My development setup is a Win PC using “Windows 10”. Both modules are running from this same computer with each section in a separate instance of the IDE.

Xceiver modules are inches apart (I have also moved them a couple of feet apart in case of some sort of interference). I Set up this

it’s not behaving very well.

Have you tried talking to it, sternly?

Made it sit on the naughty step?

Did you read what it says about posts in this section of the forum?
Why not?

one of you Arduino Geeks

Nice.
Good luck with that approach.

I’m building a data acquisition system and learning Arduino at the same time. I thought I had the communications part worked out but for some reason it’s not behaving very well. I’m sure this is just a simple oversight but I don’t see it. I’d appreciate it one of you Arduino Geeks can point me in the right direction.

System setup:
2 Arduino UNOs (1 Xmit, 1 Rcv.)

Xmit Uno currelntly has:

  • 1 Diymore DS3231 AT24C32 IIC RTC
  • 1 2004A 4 line LCD display
  • 1 MakerFocus NRF24L01+PA+LNA Xceiver
    Neither the RTC or Display are being used for this test.

Rcv Uno:
MakerFocus 2pcs NRF24L01+PA+LNA Wireless Transceiver and noting else;

My development setup is a Win PC using “Windows 10”. Both modules are running from this same computer with each section in a separate instance of the IDE.

Xceiver modules are inches apart (I have also moved them a couple of feet apart in case of some sort of interference). I set up this test platform using a youtube tutorial so if the code looks familiar it’s coppied.

The code is as follows
Xmit Code:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

char *msg;
RF24 radio(9, 10); // CE, CSN 

const uint64_t pipe = 1;  // Set pipe address

void setup()
{
  Serial.begin(9600);
  radio.begin();                  //Starting the Wireless communication
  radio.setPALevel(RF24_PA_MIN);  // Set xmit level to min
  Serial.println("Started");
  radio.openWritingPipe(pipe);
  Serial.println("Opened!");
  
  msg = "Date: 2019.08.23, Time: 13:20:40, Temp: 70F, Humidity: 65%, CO2: 1200, ph: 5.9\n";
}

void loop()
{
  radio.write(msg, strlen(msg));
  Serial.println(msg);
  Serial.println("Msg Written!"); 
  delay(5000);
  Serial.println("Wait...");
}

Xmit Print monitor reads:

Msg Written!
Wait…
String Length:
79
Date: 2019.08.23, Time: 13:20:40, Temp: 70F, Humidity: 65%, CO2: 1200, ph: 5.9

Rcv Code:

#include <SPI.h>
#include <RF24.h>
// #include <nRF24L01.h>


const int maxMsgLength = 128;
char msg[maxMsgLength];

RF24 radio(9, 10); // CE, CSN 
const uint64_t pipe = 1;

void setup()
{
  Serial.begin(9600);
  radio.begin();                  // Starting the Wireless communication
  radio.setPALevel(RF24_PA_MIN);  // Set xmit level to minimun
  Serial.println("Started");
  radio.openReadingPipe(1, pipe); // Open the read channel 
  Serial.println("Opened!");
  radio.startListening();
  Serial.println("Listening...");
}

void loop()
{
  if(radio.available())
  {
    Serial.println("Available");
    radio.read(msg, maxMsgLength - 1);
    Serial.println("Read: " + String(msg));
    Serial.println();
  }
  else
  {
    Serial.println("Available");
  }
  delay(2500);
  Serial.println("Wait... ");
  Serial.println();

}

Rcv Print Monitor reads:

Wait…
Available

Wait…
Available
Read: Date: 2019.08.23, Time: 13:20:40

I’ve tried changing buffer size, sending out a string w/o comma delimiters, removing the \n even sent out a string of:
12345678901234567890123456789012345678901234567890123456789012345678901234567890
which is the length of the string actual string.

At one point at Rcv end I sent out the read msg length which was the length of the read string (no real surprise there.

Is there a way to monitor data directly from the NRF24L01 or as close to the input as possible thus taking the Arduino processing out of the equation?

I’m not sure what other information to provide.
If anyone has any suggestions I would appreciate it.

Thank you,
Bruce

Installation & Troubleshooting
For problems with Arduino itself, NOT your project

What’s the packet size for this library?

This seems rather pointless

const int maxMsgLength = 128;

when you realize that the maximum size of an nRF24 message is 32 bytes.

If you need to send more than 32 bytes then you need to send it in several separate messages and join the parts together when they are received. It would also be a good idea to include a byte that identifies the part of the message in case one part gets lost in transmission.

It's probably easiest always to send a fixed length message so the receiver knows what to expect. However it is possible for the receiver to query the length of a received message before reading it from the nRF24.

For the sort of data you seem to want to transmit it would probably make sense to save it to a struct and then send the struct. It would avoid the need to parse the data on the receiving side. It may also make the data short enough to include in a single message.

...R Simple nRF24L01+ Tutorial