RF24: NRFLite Transmission problem

Hello guys,
I’m trying this NRFLite library with 2 RF24 modules but i having some problem.

NRFLite Issue #34

The program is very simple: TX send every second a packet with all data included PIN nr. 4 status (1 or 0)

My problem
Randomly the system loses packets. If i try with a second TX, the system loses some times packet from TX1 e some times packet from TX2.
I can’t understand the reason. The RX and TX are really close (1 meter). If I try to move the TX in another room the situation doesn’t change.

The problem is the library? the devices (RF24)? the arduinos? the wires?
Please give me support!

My configuration
Transmitter: Arduino Nano

/*

Demonstrates simple RX and TX operation.
Any of the Basic_TX examples can be used as a transmitter.
Please read through ‘NRFLite.h’ for a description of all the methods available in the library.

Radio Arduino
CE → 9
CSN → 10 (Hardware SPI SS)
MOSI → 11 (Hardware SPI MOSI)
MISO → 12 (Hardware SPI MISO)
SCK → 13 (Hardware SPI SCK)
IRQ → No connection
VCC → No more than 3.6 volts
GND → GND

*/

#include <SPI.h>
#include <NRFLite.h>

const static uint8_t RADIO_ID = 0; // Our radio’s id. The transmitter will send to this id.
const static uint8_t PIN_RADIO_CE = 9;
const static uint8_t PIN_RADIO_CSN = 10;

struct RadioPacket // Any packet up to 32 bytes can be sent.
{
uint8_t FromRadioId;
uint32_t OnTimeMillis;
uint32_t FailedTxCount;
uint32_t Data;
};

NRFLite _radio;
RadioPacket _radioData;

void setup()
{
Serial.begin(115200);

// By default, ‘init’ configures the radio to use a 2MBPS bitrate on channel 100 (channels 0-125 are valid).
// Both the RX and TX radios must have the same bitrate and channel to communicate with each other.
// You can run the ‘ChannelScanner’ example to help select the best channel for your environment.
// You can assign a different bitrate and channel as shown below.
// _radio.init(RADIO_ID, PIN_RADIO_CE, PIN_RADIO_CSN, NRFLite::BITRATE2MBPS, 100) // THE DEFAULT
// _radio.init(RADIO_ID, PIN_RADIO_CE, PIN_RADIO_CSN, NRFLite::BITRATE1MBPS, 75)
// _radio.init(RADIO_ID, PIN_RADIO_CE, PIN_RADIO_CSN, NRFLite::BITRATE250KBPS, 0)
Serial.println(“Setup…”);
if (!_radio.init(RADIO_ID, PIN_RADIO_CE, PIN_RADIO_CSN, NRFLite::BITRATE2MBPS, 50))
{
Serial.println(“Cannot communicate with radio”);
while (1); // Wait here forever.
}
Serial.println(“Setup done!”);
}

void loop()
{
while (_radio.hasData())
{
_radio.readData(&_radioData); // Note how ‘&’ must be placed in front of the variable name.

String msg = "Radio ";
msg += _radioData.FromRadioId;
msg += ", Data: ";
msg += _radioData.Data;
msg += ", ";
msg += _radioData.OnTimeMillis;
msg += " ms, “;
msg += _radioData.FailedTxCount;
msg += " Failed TX”;

Serial.println(msg);
}
}

Receiver: Arduino Uno

/*
Demonstrates simple TX operation with an ATtiny85. Note in this example the same pin is used for CE and CSN.
This slows the communication between the microcontroller and radio, but it frees up one pin.
Any of the Basic_RX examples can be used as a receiver.
Radio Arduino
CE → 9
CSN → 10 (Hardware SPI SS)
MOSI → 11 (Hardware SPI MOSI)
MISO → 12 (Hardware SPI MISO)
SCK → 13 (Hardware SPI SCK)
IRQ → No connection
VCC → No more than 3.6 volts
GND → GND
*/

#include <NRFLite.h>

const static uint8_t RADIO_ID = 100;
const static uint8_t DESTINATION_RADIO_ID = 0;
const static uint8_t PIN_RADIO_CE = 9;
const static uint8_t PIN_RADIO_CSN = 10;
const static uint8_t PIN_INPUT = 4;

struct RadioPacket
{
uint8_t FromRadioId;
uint32_t OnTimeMillis;
uint32_t FailedTxCount;
uint32_t Data;
};
uint32_t val = 0;
NRFLite _radio;
RadioPacket _radioData;

void setup()
{
Serial.begin(115200);
if (!_radio.init(RADIO_ID, PIN_RADIO_CE, PIN_RADIO_CSN, NRFLite::BITRATE2MBPS, 50))
{
Serial.println(“Cannot communicate with radio.”);
while (1); // Cannot communicate with radio.
}
Serial.println(“Init radio done!”);
_radioData.FromRadioId = RADIO_ID;

pinMode(PIN_INPUT, INPUT);
}

void loop()
{
_radioData.OnTimeMillis = millis();
val = digitalRead(PIN_INPUT);
_radioData.Data = val;

if (!_radio.send(DESTINATION_RADIO_ID, &_radioData, sizeof(_radioData)))
{
_radioData.FailedTxCount++;
Serial.print("Error sending: FailedTxCount => ");
Serial.println(_radioData.FailedTxCount++);

}

delay(1000);
}

I am not familiar with the NRFLIte library. The examples in this Simple nRF24L01+ Tutorial use the TMRh20 version of the RF24 library

The examples are as simple as I could make them and they have worked for other Forum members. If you get stuck it will be easier to help with code that I am familiar with. Start by getting the first example to work

There is also a connection test program to check that the Arduino can talk to the nRF24 it is connected to.

...R