My first issue is using the Xbee wifi module with the Mega 2560 board. I can connect when I use software serial . However, using the same methods, it can't connect when i try the Serial1 or Serial2 of the arduino. No idea what the issue is.
Next problem is even though I use software serial, I am having serious issue reading a string from it. My php server is sending a "Hello World" and in the receving end the data seems to be missing bytes/characters. I sense its a problem with the software serial but I am stuck. here is the code for reading out :
void loop()
{
if (millis() > (lastUpdate + UPDATE_RATE))
{
xB.flush();
delay(10);
lastUpdate=millis();
Serial.print("\nNew :...... \n\n");
}
if(xB.available()>0)
{
c=char(xB.read());
Serial.print(c);
}
}
I can't even add a line to store the characters in a string. the data gets even more crazy.
. I am new in arduino world. but this is making me nuts ! Please help.