Hi guys,
I am using an Arduino UNO, em406a GPS and 2 xbee s2b modules(one connected to the Arduino and one connected on the pc).
I am trying to send the GPS string from one xbee to another, but it seems to affect the generated GPS string whenever i add the code for the xbee.
My Code:
#include <XBee.h>
#include <TinyGPS.h>
#include <SoftwareSerial.h>// Define SoftwareSerial TX/RX pins
#define xbeeRX 2
#define xbeeTX 3
#define gpsRX 4
#define gpsTX 5
//create xbee connection
SoftwareSerial xbeess = SoftwareSerial(xbeeRX, xbeeTX);
//create gps connection
SoftwareSerial gpsss = SoftwareSerial (gpsRX, gpsTX);//Create an XBee object
XBee xbee = XBee();
TinyGPS gps;//Define the Destination address of the packets
XBeeAddress64 destaddress = XBeeAddress64(0x0013A200, 0x406F1997);char Hello[] = "Hello World\n\r";
void setup()
{
Serial.begin(9600); //connect serial
xbeess.begin(9600); //connect xbee
gpsss.begin(4800); //connect gps//We hook the XBee into the Software Serial
xbee.setSerial(xbeess);Serial.println("Goodnight moon!");
}void loop() // run over and over
{
while (gpsss.available()>0){
char c = gpsss.read();
if (c == '$'){Serial.println();
ZBTxRequest zbtx = ZBTxRequest(destaddress, (uint8_t *)Hello, strlen(Hello));
xbee.send(zbtx);
}
Serial.print(c);
}
}
Output:
Goodnight moon!
$4jíZhË03f43??3eF4fË7³gÆÌ±33Ì?.f6c1fÍ?3»Æl3s3M,26.2,M,,0000*60
$4jmZhËAfË?3eÌ?fÌ?3fË,£Æ?±?.3e®3eæ?3?BaÉ£5jÓ¡f3fÌ?3.372,A,3441.7397,N,03301.3306,E,0.18,148.65,290413,,,A*6C
$4jíZhË03f43??3eF4fË7³gÆÌ±33Ì?.f7c1fÍ?3»Æl3s5M,26.2,M,,0000*62
$4jmZhËAfË?3eÌ?fÌ?3f?,cÆ?±?.3e.3eæ?3?BaÉ£µ?fÙ3Ë?,12,20,67,108,42,32,38,110,50,16,21,096,40,01,20,178,36*7C
$4jm?c6,fË13e?3ÙV,³Í?,f̬³fË53e?9±Æ ³c&fÌ7³Æ c&7Í4?²3´a?
$GPG5c3fË?3eÌ?fÌ,3f?,fÎ,3fË23Î?,fÌ?3fË13fË33Ë??,³v,²?
²4j©MC,070144.372,A,3441.7395,N,03301.3307,E,0.19,154.63,290413,,,A*62$4jíZhË03f43?v3eF4fË7³gÆÌ±33f?³fÌ9c,3Í??»Æl3s?Yc&fæL3eÓ?,0000*67
$4jmZhËAfË33eÌ?fÌ?3f?,cÆ?±?.3eæì3e.3e&)FìjÔM4e?7fÌ?3?v2c6FFæì³fÎ?,N,03301.3309,E,0.18,155.46,290413,,,A*6C
$4jíZhË03f43?v3eF4fË7³g?,±33f.³fÌ?c,3Í?3»Æl³s?M,26.2,M,,0000*64
For the time being I am trying to send a "Hello World" message and even that is not transmitted properly. But when i remove the code that transmits the data from one xbee to another, the GPS strings are displayed properly.
Any ideas would be most appreciated.
Regards,
gabys