0

I'm trying to read the data of a GPS BN-180 with a Heltec ESP32 board.

The code I'm using is shown next:

#include "types.h"
#include "TinyGPS++.h";
#include "HardwareSerial.h";

TinyGPSPlus gps;
HardwareSerial SerialGPS(1);

void setup() {
        Serial.begin(115200); //Serial port of USB
        SerialGPS.begin(9600, SERIAL_8N1, 16, 17);
}

void loop() {
    while (SerialGPS.available() >0) {
       gps.encode(SerialGPS.read());
    }

    Serial.print("LAT=");  Serial.println(gps.location.lat(), 6);
    Serial.print("LONG="); Serial.println(gps.location.lng(), 6);
    Serial.print("ALT=");  Serial.println(gps.altitude.meters());
}

I'm using Rx as 17 and Tx as 16 pins. However,in serial monitor I get strange output. Does anyone which is the problem?Serial monitor printscreen

6
  • Your program sends with 115200 baud, The Terminal/Console/Serial Monitor is configured with 9600. Set the serial moniotr to 115200 Baud and it might work. – Peter Paul Kiefer Jan 16 at 10:13
  • I'm a newbie, and don't know how to change it. I wrote the line with SerialGPS.begin(115200, SERIAL_8N1, 16, 17); and still see the same strange symbols in Serial Monitor – galtor Jan 16 at 10:45
  • I did not told you to change the program. Also I mentioned the Serial not the SerialGPS port. You can change the Baud rate on the serial monitor window (your picture), Just select 115200 baudio in the combo box where you actually see 9600 baudio. – Peter Paul Kiefer Jan 16 at 10:49
  • ok, thanks, now I got it. – galtor Jan 16 at 10:51
  • Your welcome. The SerialGPS baud rate should also match the baud rate of the GPS module in case you encouter issues with that. The SerialGPS is for the communication with the GPS module and the Serial is for the communication with the Arduino Serial Monitor over the USB To Serial connection. – Peter Paul Kiefer Jan 16 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.