Hello,i am using two rf modules cc1101 and i am having a problem on the receiving end.
This is my code for transmitting.
#include <ELECHOUSE_CC1101.h>
void setup()
{
Serial.begin(9600);
ELECHOUSE_cc1101.Init();
}
void loop()
{
delay(500);
String locat = "+03 Electrical Engineers";
int locat_length = locat.length();
byte locat_byte[locat_length];
locat.getBytes(locat_byte, locat_length + 1);
Serial.println((char *)locat_byte);
ELECHOUSE_cc1101.SendData(locat_byte, locat_length);
}
This is my code for receiving.
#include <ELECHOUSE_CC1101.h>
String locat;
int StDir=0;
byte buffer[100] = {0};
void setup()
{
Serial.begin(9600); // the Serial port of Arduino baud rate.
ELECHOUSE_cc1101.Init();
ELECHOUSE_cc1101.SetReceive();
}
void loop()
{
if (StDir == 0)
{
if (ELECHOUSE_cc1101.CheckReceiveFlag())
{
ELECHOUSE_cc1101.ReceiveData(buffer);
String str((char*) buffer);
Serial.println(str); //Μηνυμα πομπου
locat=str.substring(4);
Serial.println(locat); //Ονομα περιοχης
StDir=str.substring(0,3).toInt();
Serial.println(StDir); //Κατευθυνση οχηματος
String Entry = locat; //Διευθυνση εισοδου
//Αποθηκευση του Entry στην SD
}
Serial.println("Waiting to enter the Highway");
delay(5000);
}
else
{
GPS();
}
}
The problem is that in serial monitor i don't get the message from the tranmitter and it only shows
Waiting to enter the Highway
But when i delete this lines of code
Serial.println("Waiting to enter the Highway");
delay(5000);
i get the message from the transmitter and it gets shown in the serial monitor.
I cannot figure out why this lines of code block my messages.
Thanks in advance