Communication NRF24L01 with keypad and LCD I2C

Hi!
Using NRF24l01, I want to display on a LCD I2C what I pressed on a keypad 4*4.
Here is the code without the communication NRF24l01:


#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>

#define Length 7

char Data[Length];
byte data_count = 0;
char customKey;

const byte ROWS = 4;
const byte COLS = 4;

char hexaKeys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};

byte rowPins[ROWS] = {7, 6, 5, 4};
byte colPins[COLS] = {3, 2, 1, 0};

Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup(){
lcd.init();
lcd.backlight();
}

void loop(){

lcd.setCursor(0,0);
lcd.print("Entrer Ref:");
customKey = customKeypad.getKey();
if (customKey){
Data[data_count] = customKey;
lcd.setCursor(data_count,1);
lcd.print(Data[data_count]);
data_count++;
}
}

void clearData(){
while(data_count !=0){
Data[data_count--] = 0;
}
return;
}

This code is working well.
But when I add the sentences of the communication NRF24l01, it doesn't work.
I am beginner in NRF, If someone could help me, I'll be grateful.

when I add the sentences of the communication NRF24l01, it doesn't work.

It would be more helpful to see the code that "doesn't work" (Tx and Rx) and to have more details of the problem

Also, there's a bug in your code

void clearData(){
  while(data_count !=0){
    Data[data_count--] = 0; 
  }
  return;
}/code]

Have a look at this Simple nRF24L01+ Tutorial.

Wireless problems can be very difficult to debug so get the wireless part working on its own before you start adding any other features.

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

...R

Thank you all for responding me.

@arduino_new Should I delete this part of the code?

@UKHeliBob here is Tx code:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>

#define Length 7

char Data[Length]; 
byte data_count = 0;
char customKey;
const byte ROWS = 4;
const byte COLS = 4;
char hexaKeys[ROWS][COLS] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {7, 6, 5, 4};
byte colPins[COLS] = {3, 2, 1, 0};

RF24 radio(8, 9); // CE, CSN
Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
LiquidCrystal_I2C lcd(0x27, 16, 2); 
const byte addresses[][6] = {"00001", "00002"};  

const uint64_t pipe = 0xE8E8F0F0E1LL;
void setup(void) {
  lcd.init(); 
  lcd.backlight();
  radio.begin();
  radio.openWritingPipe(addresses[0]); // 00001
  radio.openReadingPipe(1, addresses[1]); // 00002
  radio.setPALevel(RF24_PA_MIN);
}

void loop() {
  delay(5);
  radio.startListening();
  if (radio.available()) {
    delay(5);
    radio.stopListening();
    customKey = customKeypad.getKey();
    radio.write(customKey, Length);
  }
}

Rx code :

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>

#define Length 7

char Data[Length]; 
byte data_count = 0;
char customKey;

RF24 radio(8, 9); // CE, CSN
LiquidCrystal_I2C lcd(0x27, 16, 2); 
const byte addresses[][6] = {"00001", "00002"};

void setup() {

  radio.begin();
  radio.openWritingPipe(addresses[1]); // 00002
  radio.openReadingPipe(1, addresses[0]); // 00001
  radio.setPALevel(RF24_PA_MIN);
  lcd.init(); 
  lcd.backlight();
}

void loop() {
  delay(5);
  radio.stopListening();
  
  delay(5);
  radio.startListening();
  while (!radio.available());
  radio.read(customKey, Length);
  if (customKey){
    Data[data_count] = customKey; 
    lcd.setCursor(data_count,1); 
    lcd.print(Data[data_count]); 
    data_count++; 
    }
}

This is the loop() function from your Tx code

void loop()
{
  delay(5);
  radio.startListening();
  if (radio.available())
  {
    delay(5);
    radio.stopListening();
    customKey = customKeypad.getKey();
    radio.write(customKey, Length);
  }
}

Why does sending the keypress value depend on the transmitter receiving something ?

@UKHeliBob The transmitter won't receive nothing. It should work like that: when I press a key in the keypad, receiver displays it in the LCD.
Please help me, i'm begginner in this communication.

The transmitter won't receive nothing.

That sounds quite reasonable but look at the code for the Tx. It looks to me like nothing will happen in the loop() function unless something is available to read from the radio object. If that is not the case then please explain what each line of the Tx code loop() function does, in particular

  radio.startListening();
  if (radio.available())
  {
//do other stuff

ulearner:
Please help me, i'm begginner in this communication.

Have you tried my examples?

...R