Good afternoon everyone,
yesterday I noticed that if I try to send an array (a string written through Serial Port) from Arduino1 to an Arduino2 using the nRF24L01 module and print the data received through Serial Monitor everything works fine. But if I want to print the received data to the serial monitor and to a LCD_I2C I can't get it work. Actually, if I only include the LiquidCrystal_I2C Library, I can't print received data through Serial!
I have really no idea of what is going on here, I need your help!
Arduino1 TX
//Library Inclusions
#include <RF24.h>
//MACROS
#define RF_CE_PIN 7 // Radio Frequency Receiver Chip Enable Pin
#define RF_CS_PIN 8 // Radio Frequency Receiver Chip Select Pin
//Global types
RF24 radio(RF_CE_PIN, RF_CS_PIN);
//Global variables
bool yetToSend = false;
unsigned char gotArray[20]={0};
const byte pipe = "ABCDE"; //pipe for RF Communication
void setup() {
Serial.begin(115200);
//outputs
pinMode(RF_CE_PIN, OUTPUT);
pinMode(RF_CS_PIN, OUTPUT);
//starts Radio Frequency Receiver
radio.begin();
radio.setPALevel(RF24_PA_MIN);
radio.stopListening();
radio.openWritingPipe(pipe);
}
void loop() {
if(Serial.available()>0){
uint8_t i=0;
while(Serial.available()>0){
gotArray[i++]=Serial.read();
delay(5);
}
for(int i=0; i<20; i++)
Serial.print((char)gotArray[i]);
Serial.println();
yetToSend=true;
}
if(yetToSend == true){
radio.stopListening();
radio.write( &(gotArray[0]), sizeof(gotArray) );
yetToSend=false;
}
}
Arduino2 RX
//Library Inclusions
#include <LiquidCrystal_I2C.h> // CAUSES PROBLEMS
#include <RF24.h>
//MACROS
#define RF_CE_PIN 7 // Radio Frequency Receiver Chip Enable Pin
#define RF_CS_PIN 8 // Radio Frequency Receiver Chip Select Pin
//Global types
//LiquidCrystal_I2C lcd(0x27, 16, 2);
RF24 radio(RF_CE_PIN, RF_CS_PIN);
//Global variables
unsigned char gotArray[20]={0};
const byte pipe = "ABCDE"; //pipe for RF Communication
//Setup
void setup(){
pinMode(RF_CE_PIN, OUTPUT);
pinMode(RF_CS_PIN, OUTPUT);
Serial.begin(115200);
//starts Radio Frequency Receiver
radio.begin();
radio.setPALevel(RF24_PA_MIN);
radio.openReadingPipe(0, pipe);
radio.startListening();
}
void loop() {
getFromRF();
}
bool getFromRF(){
if(radio.available()){
radio.read(&(gotArray[0]), sizeof(gotArray));
for(int i=0; i<20; i++)
Serial.print((char)gotArray[i]);
Serial.println();
return true;
}
else
return false;
}