This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF24L01 leaves out certain characters during transmission

Hi, I am using nRF24L01 as a part of a larger project that involves communication between two such transceivers sending and receiving data. I am trying to get a similar but simpler code working with the module. So far, I have established communication between them. Characters are sent and received using arrays. The problem is that the receiver's serial monitor does not print all the characters. Sometimes the last character is not printed, and sometimes the last two characters are not printed. When I do a second transmission, the missing characters from the first transmission get printed. I have been trying to solve this for days now. Any help is greatly appreciated.  I am using an arduino nano and another arduino uno with the 2 transceivers. They also have a 100μF decoupling capacitor between 3.3V and GND. 

Master's code(Transmitter) and the Slave's code(Receiver) are attached with this thread.

NRF24L01_Slave_EbyE.inoNRF24L01_Master_EbyE.ino

Parents
  • Hi,

     

    You will set the flag even if no chars are available here:

    void read() {
      p = &text[0];
      for (i = 0; Serial.available(); p++, i++) {
        *p = Serial.read();
      }
      text[i + 1] = '\0';
      flag = 1;
    }
    

    I would recommend that you re-write this function to something like

    if (Serial.available()) {

      /* insert for loop for Read out data and set last byte \0 */ 

      flag = 1;

    }

     

    Could you try this and see if it works better?

     

    Kind regards,

    Håkon

Reply
  • Hi,

     

    You will set the flag even if no chars are available here:

    void read() {
      p = &text[0];
      for (i = 0; Serial.available(); p++, i++) {
        *p = Serial.read();
      }
      text[i + 1] = '\0';
      flag = 1;
    }
    

    I would recommend that you re-write this function to something like

    if (Serial.available()) {

      /* insert for loop for Read out data and set last byte \0 */ 

      flag = 1;

    }

     

    Could you try this and see if it works better?

     

    Kind regards,

    Håkon

Children
Related