Strange behaviour with H/W Serial + S/W Serial ports

Hello Arduino community !

I am new to Arduino world, and I am trying to learn new things.
I got already some success, but I am stuck in a strange behaviour that I don't understand.

The H/W :

  • I have salvaged an old GPS (Magellan RoadMate), to use the GPS chip. This is a Cirocomm 576 chip, on a GC333 board. I didn't find any documentation on the internet. By comparing with the EM406 datasheet, i made a reasonable guess on the pins assignment. GPS data pin is connected to the pin 3 (so not on the H/W serial).
  • A LCD screen, connected on the I2C.

The S/W :
I want to display the output of the GPS on the Serial console, as well as on a LCD screen.
I use the following code :

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>

#include <SoftwareSerial.h>
 
#define I2C_ADDR    0x27 // LCD
#define BACKLIGHT_PIN     3
#define En_pin  2
#define Rw_pin  1
#define Rs_pin  0
#define D4_pin  4
#define D5_pin  5
#define D6_pin  6
#define D7_pin  7

// SoftwareSerial
#define RXPIN 3
#define TXPIN 2


  LiquidCrystal_I2C	lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);

  int ledPin = 13;                  // LED test pin
  int byteGPS=-1;
 
  int cursorPos=0;
 
  SoftwareSerial nss(RXPIN, TXPIN);
 
 
  void setup()
  {
    Serial.begin(115200);
    Serial.print ("test GPS");
    
    lcd.begin (16,2); //  <<----- My LCD is 16x2
  
    
    // Switch on the backlight
    lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
    lcd.setBacklight(HIGH);
    lcd.home (); // go home
  
    lcd.print("SainSmartI2C16x2");  
    
    Serial.print ("> nss.begin");
    nss.begin(4800);
    Serial.print ("< nss.begin");
    lcd.setCursor(0,1);
  }

  void loop()
  {
    byteGPS=nss.read();         // Read a byte of the serial port
     
    lcd.setCursor(cursorPos, 1);
    lcd.print((char)byteGPS);
//    Serial.print((char)(byteGPS));
    cursorPos++;
    if (cursorPos >=16) cursorPos=0;
  
    delay(10);
  }

The LCD library is fmalpartida.

Expected behaviour :
NMEA string displayed both on Serial monitor and LCD screen.

Actual behaviour :
With the // Serial.print((char)(byteGPS)); commented out :

  • the Console displays only "test GPS >n", and then nothing happen. Even if I disconnect the data pin.
    With the Serial.print((char)(byteGPS)); not commented out :
  • the Console displays only "test GPS >n", and then nothing happen.
  • if I disconnect the data pin, then some data are flushed out on the console and on the LCD. But these data does not correspond at all to a NMEA string :
test GPS> nss.begin< nss.begin220 160 102 108 109 130 142 117 130 62 205 177 42 52 97 26 236 4 156 51 213 135 177 33 98 51 212 62 9 204 187 189 0 151 105 154 11 101 56 28 166 90 26 107 149 25 72 127 123 203 48 238 156 193 119 85 33 14 227 78 255 165 225 243 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 210 120 36 57 60 223 3 177 65 249 19 228 81 0 149 5 22 40 17 174 181 253 173 95 114 127 120 114 171 188 208 220 97 63 167 24 81 239 63 255 107 46 242 181 154 80 139 141 1 161 150 184 181 215 112 0 133 231 95 225 99 161 106 178 170 190 50 172 239 106 188 250 212 180 64 18 112 25 95 117 111 109 7 125 245 57 30 50 63 199 102 162 234 41 149 73 123 33 154 76 68 243 125 200 79 182 74 48 110 78 34 32 128 50 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 5 37 97 20 5 235 40 241 168 92 31 21 179 34 109 95 153 202 11 252 19 75 51 250 99 133 199 53 85 121 129 110 146 7 224 150 67 43 137 202 73 84 118 127 56 185 133 34 158 58 130 36 180 84 209 30 151 38 246 213 131 244 209 81 194 109 42 163 29 149 223 46 9 92 26 114 83 147 22 29 173 198 234 124 13 162 83 200 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1

(I changed string to decimal numbers because the special characters are not accepted by the forum post).
Each time I reconnect and then disconnect the data pin, a new bunch of data is displayed (this is identified by the sequence of -1).

Note that the good news is that it seems I didn't burn the GPS chip ! 8)

But I'm stuck on these 2 blocking points :
Why, if there is no Serial.print((char)(byteGPS));, then there is no output ?
Why the outputted data is not NMEA string ?

Thanks for reading my post, and I would be glad if you could find some useful hint to solve this out.

Philemon

Why, if there is no Serial.print((char)(byteGPS));, then there is no output ?

Why, if I don't send anything to the Serial Monitor, does nothing show up there? Is that obvious?

Why the outputted data is not NMEA string ?

Most likely, because the GPS is not talking to the Arduino. Or, not talking at the speed it is expecting.

I didn't find any documentation on the internet.

So, you guessed, and somehow it's an Arduino problem because you guessed wrong.

    byteGPS=nss.read();         // Read a byte of the serial port

Whether there is any data to read, or not.

Why, if there is no Serial.print((char)(byteGPS));, then there is no output ?
Why, if I don't send anything to the Serial Monitor, does nothing show up there? Is that obvious?

Sorry, I was not clear enough. The question was :
Why, if there is no Serial.print((char)(byteGPS));, then there is no output on the LCD ?
But I find that sometimes when i put a new sketch to the Arduino, the LCD is not refreshed. I have to power off/power on the Arduino to restart the display. So, even if it is not clear, I think it is not related to my issue.

Why the outputted data is not NMEA string ?

Most likely, because the GPS is not talking to the Arduino. Or, not talking at the speed it is expecting.

Before posting, I had already tested each of the 11 possible baud rates. Same results.

I didn't find any documentation on the internet.

So, you guessed, and somehow it's an Arduino problem because you guessed wrong.

.
Maybe. But playing with the pin3 (GPS data pin) displays a lot of bytes. Where do they come from if not from the GPS ?

    byteGPS=nss.read();         // Read a byte of the serial port

Whether there is any data to read, or not.

Yes, that's why there is a lot of "-1".