Hello all,
Your help in the problem below is wellcome.
I need to use 2 Tx outputs, one to setup the GPS and other one to send the Lat., Long., etc to another system (two way radio control receiver). I made several attempts but without success, I can't get any signal at the TX pin3 with the code below (it has a lot of patches just for test the input, because, I wasn't also able to read the inputs sentence. I had to setup the Baudrate to 4800 in order to get the sentence without errors):
#include <NewSoftSerial.h>
NewSoftSerial gps1(2, 3);
NewSoftSerial gps(0, 1);
String chkStr = String(5);
String dataStr = String(65);
String returnStr = String(12);
char chkByte;
char inByte;
int i = 10;
int page = 1;
void setup() {
pinMode(0, INPUT);
pinMode(1, OUTPUT);
pinMode(2, INPUT);
pinMode(3, OUTPUT);
lcd.begin(DOG_LCD_M163,0x28);
lcd.setCursor(0, 0);
lcd.print("--Arduino GPS--");
lcd.setCursor(0, 1);
lcd.print("------v2.1------");
delay(2000);
gps1.begin(38400);
Serial.begin(38400);
gps1.read();
Serial.print("$PMTK251,4800*14\r\n");
gps.begin(4800);
Serial.begin(115200);
delay(200);
gps.read();
}
void loop() {
chkStr = '\0';
// if (gps.available() > 0) {
// chkByte = gps.read();
//while (chkByte > 0) {
if (i > 0) {
if (gps.available() > 0) {
inByte = gps.read();
//chkStr.concat(inByte);
Serial.print(inByte);
i--;
}
else {
waitForByte();
}
}
else {
i = 10;
// break;
}
while (chkStr.equals("GPRMC")) {
if (gps.available() > 0) {
inByte = gps.read();
dataStr.concat(inByte);
//Serial.print(inByte);
}
else {
waitForByte();
}
}
}
// }
//}
void waitForByte() {
while (true) {
if (gps.available() > 0) {
break;
}
else {
continue;
}
}
}
Considering that I didn't get any result with the sketch (Kind of) above, I tried the example below, but I didn't get any output also at the TX pin3 and TX pin5. I always get the output at the TX pin1, in both cases . Your help is appreciated.
thanks and regards,
Manuel
#include <NewSoftSerial.h>
NewSoftSerial nss(2, 3);
NewSoftSerial nss2(4, 5);
void setup()
{
nss2.begin(19200);
nss.begin(19200);
Serial.begin(115200);
}
void loop()
{
// Every 10 seconds switch from
// one serial GPS device to the other
if ((millis() / 10000) % 2 == 0)
{
if (nss.available())
{
Serial.print(nss.read(), BYTE);
}
}
else
{
if (nss2.available())
{
Serial.print(nss2.read(), BYTE);
}
}
}