Hello, everyone!
I’m a new programmer and I just bought a Wireless Tracker. I’m using Arduino IDE to build my code to test the GPS, with the examples of the library TinyGPSPlus (simples code to print latitude and longitude). However, it seems that the GPS is not being initialized correctly, since no coordinates are shown on the serial.
I’m using Pins 34 for RX and 33 for TX. I’m not sure if I need to conect anything physically on the board on those pins, the only thing I connected was the antenna on the GNSS pin on the back of the board. Is there anything else I should define on the code? Is there any configuration I should do on the board? Do you have any example code for me to test it? I just need to read the latitude and longitude from the GPS.
I really don’t know what I’m doing wrong!!
CODE:
#include <HardwareSerial.h>
#include <TinyGPS++.h>
HardwareSerial Serialgps(2);
TinyGPSPlus gps;
void setup() {
pinMode(46,OUTPUT);
pinMode(3,OUTPUT);
digitalWrite(3,HIGH);
Serial.begin(115200);
Serialgps.begin(9600, SERIAL_8N1, 33, 34); // Pins 34 (RX) 33 (TX)do GPS
}
void loop() {
if (Serialgps.available()) {
int c = Serialgps.read();
if (gps.encode(c)) {
if (gps.location.isUpdated()) {
float gpslatitude = gps.location.lat();
float gpslongitude = gps.location.lng();
Serial.print("Latitude: ");
Serial.println(gpslatitude, 6);
Serial.print("Longitude: ");
Serial.println(gpslongitude, 6);
}
}
}
}