nRF24L01+ Message Latency

Hi all,

I am using an nRF24L01+ for wireless communication, I have it working but I seem to have quite a lag between my TX and RX, and it also seems to update every second or so. Is there a way to increase how often the messages are being sent? Looking for lower latency. I am assuming it is a change needed within my void loop. Appreciate any help.

TX side

// SimpleTx - the master or the transmitter

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


#define CE_PIN   7
#define CSN_PIN 8

const byte slaveAddress[5] = {'R','x','A','A','A'};


RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

char dataToSend[10] = "Message 0";
char txNum = '0';

int joyStick[32];


unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second


void setup() {

    Serial.begin(9600);

    Serial.println("SimpleTx Starting");

    radio.begin();
    radio.setRetries(1,5); // delay, count
    radio.openWritingPipe(slaveAddress);
    radio.stopListening();
}

//====================

void loop() {

  joyStick[0] = analogRead(A0);
             currentMillis = millis();
            if (currentMillis - prevMillis >= txIntervalMillis) {
            send();
     prevMillis = millis();
 }
}

//====================

void send() {

    bool rslt;
    rslt = radio.write( &joyStick, sizeof(joyStick) );
        // Always use sizeof() as it gives the size as the number of bytes.
        // For example if dataToSend was an int sizeof() would correctly return 2

    Serial.print("Data Sent ");
    Serial.print(joyStick[0]);
    if (rslt) {
        Serial.println("  Acknowledge received");
        updateMessage();
    }
    else {
        Serial.println("  Tx failed");
    }
}

//================

void updateMessage() {
        // so you can see that new data is being sent
    txNum += 1;
    if (txNum > '9') {
        txNum = '0';
    }
    dataToSend[8] = txNum;
}

Thanks,

The transmitter only sends once per second (or once every 1000 millis), it should be obvious how to modify that. Why the reception is slow is impossible to give any advice on since that part of the code is missing.

jbarth200:
Is there a way to increase how often the messages are being sent?

Just change the value of txIntervalMillis

...R
Simple nRF24L01+ Tutorial