Hello Folks,
I have following challenge:
2 Input Streams (of 2 GPS Receiver) both with 9600 Baud should be collected in a microprocessor, both position data (NMEA, ASCII) have to compared and the resulting data should be printed out with Serial.print();
The Processor ist an ESP8266 (on an NodeMCU Board), Development IDE ist the Arduino IDE
The Issue:
If I connect serial input stream 1 only, then i receive perfect data.
If I connect serial input stream 2 only, then i receive perfect data.
When i connect both, there is a data jam, of ascii an non-ascii data, mixed up with some real data in NMEA form.
Example:
$GN⸮媱⸮ʦ⸮⸮r⸮⸮d&K⸮⸮⸮⸮⸮⸮⸮)00bbL⸮,N*⸮R⸮iHeE⸮u⸮U⸮bbbbbbr⸮⸮⸮JSC⸮⸮T%GXN⸮⸮5.r0,,,,,0,00,99.99,,,,,,74
⸮⸮⸮Mb⸮⸮()⸮L⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮S⸮9N⸮99rb.99,99.992E
HՈ9⸮⸮Ŋ⸮()⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮)⸮⸮9rbN⸮9.99,99.992E
⸮⸮⸮MbԊb&b&⸮$&K6K⸮2,X⸮6,,,16,R7,X⸮⸮R⸮⸮⸮⸮⸮K,1,K⸮,⸮0ljDʪj":⸮9S1b⸮⸮⸮⸮ ⸮⸮,VM⸮,X,T⸮N*58 $G⸮⸮MCjɪ ⸮⸮M⸮0,V,,,,,,&⸮L⸮1⸮b⸮,*⸮JR!:e⸮I⸮G,,,,,,,,%Q⸮,T*⸮⸮G⸮⸮⸮⸮(LN⸮⸮M⸮0,,,&L⸮,⸮b.9Xb⸮)Kb⸮⸮K⸮S!6⸮G⸮G⸮
(P⸮,⸮⸮,X⸮⸮⸮⸮⸮⸮⸮⸮⸮S⸮⸮ʔN⸮)N⸮)N⸮)N⸮ITN⸮!E⸮G⸮G⸮
(P⸮,⸮⸮,X⸮⸮⸮⸮⸮⸮⸮⸮⸮S⸮⸮ʔN⸮)N⸮N⸮)N)N⸮⸮$T!EG⸮G&L⸮Vb⸮,2⸮ ,,b⸮⸮⸮ILbK⸮⸮K⸮3db4b8
R
⸮H⸮MYK⸮⸮ ⸮,SS!5⸮GGLL,,,⸮,⸮⸮M⸮⸮r0,V,Nj⸮R5⸮⸮⸮$GNRMC,09275C.00,V,,,,,,,,00717,,0N6D
$GNVTG,,,,,,,,,N,E
$GNGGA,092757.00,,,,.0,00,99.99,,,,,,76
$GNGSA,A,1,,,,,,,,,,,,,99.99,99.99,99.992E
$GNGSA,AG1,,,,,,,,,,,,,99.99,99.99,99.992E
$GPGSV,1,1,S3,23,,,12,26,,,12,27,,,117A
$GLGSV,$,1,006,
$GNGLL,,,N,092757.00,V5N5A
,N*55
The Code is a Subset auf the Example Code to SoftwareSerial().
#include <SoftwareSerial.h>
// software serial #1: RX = digital pin 10, TX = digital pin 11
SoftwareSerial portOne(12, 13, false, 128);
// software serial #2: RX = digital pin 8, TX = digital pin 9
SoftwareSerial portTwo(5, 4,false, 128);
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
// Start each software serial port
portOne.begin(9600);
portTwo.begin(9600);
}
void loop() {
// By default, the last intialized port is listening.
// when you want to listen on a port, explicitly select it:
portOne.listen();
// while there is data coming in, read it
// and send to the hardware serial port:
while (portOne.available() > 0) {
char inByte = portOne.read();
Serial.write(inByte);
}
// Now listen on the second port
portTwo.listen();
// while there is data coming in, read it
// and send to the hardware serial port:
while (portTwo.available() > 0) {
char inByte = portTwo.read();
Serial.write(inByte);
}
}
My assumption for the unexpected behaviour is:
from Documentation to SoftwareSerial():
SoftwareSerial: listen()
Description
Enables the selected software serial port to listen. Only one software serial port can listen at a time; data that arrives for other ports will be discarded. Any data already received is discarded during the call to listen() (unless the given instance is already listening).
Questions:
(1) Do you have other assumption?
(2) Did you have other experiences with SoftwareSerial()?
(3) When my assumption is correct, how can i read data from 2 source via serial with 9600 baud at the same time?
Thanks for your feedback, simplemind