Robin2:
If you are using my code to receive data over SoftwareSerial then wherever my code uses Serial to RECEIVE data you should use whatever name you have given to your SoftwareSerial instance. However where my code uses Serial to show the results you will probably want to continue using Serial so that the output can be seen on the Serial Monitor.
If you are having trouble it is easier to help if you post your latest code.
...R
I'm using 2 arduino uno's with of course 2 xbees. Both talk to each other fine. However, when I tried to send gps data, it's receiving, but in decimal form. I may be missing something, but this is what I have:
Your code sending out to xbee:
const byte numChars = 32;
char receivedChars[numChars]; // an array to store the received data
boolean newData = false;
void setup() {
Serial.begin(9600);
Serial.println("<Arduino is ready>");
}
void loop() {
recvWithEndMarker();
showNewData();
}
void recvWithEndMarker() {
static byte ndx = 0;
char endMarker = '\n';
char rc;
// if (Serial.available() > 0) {
while (Serial.available() > 0 && newData == false) {
rc = Serial.read();
if (rc != endMarker) {
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
receivedChars[ndx] = '\0'; // terminate the string
ndx = 0;
newData = true;
}
}
}
void showNewData() {
if (newData == true) {
Serial.print("This just in ... ");
Serial.println(receivedChars);
newData = false;
}
}
Data from serial monitor sending out:
This just in ... $GPRMC,170906.00,A,4105.77264,N
This just in ... $GPVTG,,T,,M,0.013,N,0.025,K,A*
This just in ... $GPGGA,170906.00,4105.77264,N,0
This just in ... $GPGSA,A,3,26,16,31,03,22,23,29
This just in ... $GPGSV,4,1,15,03,35,267,38,04,7
Receiving xbee code:
void setup()
{
Serial.begin(9600);
}
void loop()
{
if (Serial.available())
{ // If data comes in from XBee, send it out to serial monitor
Serial.print(Serial.read());
}
}
Data receiving on serial monitor:
6065114100117105110111321051153211410197100121621310606511410011710511011132105115321141019710012162131084104105115321061171151163210511032464646321061310606511410011710511011132105115321141019710012162131084104105115321061171151163210511032464646
Not sure what I'm doing wrong