0

I've bought a Heltec Wireless Tracker Arduino.

I want to get the GPS position. I've taken the original example "GPSDisplayOnTFT" from the IDE (I've made a few changes because the original code wasn't working for me).

Example from IDE

My screen always shows:

peek: 0
LAT: 0.00
valid: 0

I've put a comment on the code to show the line.

This is my code:

#include "Arduino.h"
#include "HT_st7735.h"
#include "HT_TinyGPS++.h"
TinyGPSPlus GPS;
HT_st7735 st7735;
#define VGNSS_CTRL 3
void GPS_test(void)
{
 Serial.println("GPS 1");
 Serial1.begin(9600,SERIAL_8N1,33,34); 
 Serial.println("GPS_test");
 delay(1000);
 while(1)
 {
 st7735.st7735_fill_screen(ST7735_BLACK);
 if(Serial1.available()>0)
 {
 if(Serial1.peek()!='\n')
 {
 GPS.encode(Serial1.read());
 String peek = "peek: " + (String)GPS.encode(Serial1.read());
 Serial.println(peek);
 st7735.st7735_write_str(0, 0, peek);
 
 }
 else
 {
 Serial1.read();
 if(GPS.time.second()==0)
 {
 Serial.println("second==0");
 continue;
 }
 st7735.st7735_fill_screen(ST7735_BLACK);
 st7735.st7735_write_str(0, 0, (String)"GPS_test");
 String time_str = (String)GPS.time.hour() + ":" + (String)GPS.time.minute() + ":" + (String)GPS.time.second()+ ":"+(String)GPS.time.centisecond();
 st7735.st7735_write_str(0, 20, time_str);
 Serial.println(time_str);
 String latitude = "LAT: " + (String)GPS.location.lat();
 st7735.st7735_write_str(0, 40, latitude);
 Serial.println(latitude);
 String longitude = "LON: "+ (String)GPS.location.lng();
 st7735.st7735_write_str(0, 60, longitude);
 Serial.println(longitude);
 
 delay(5000);
 while(Serial1.read()>0);
 }
 Serial.println("***************************");
 Serial.println(Serial1.peek());
 Serial.println(Serial1.read());
 Serial.println(GPS.location.lat());
 st7735.st7735_write_str(0, 20, "LAT: " + (String)GPS.location.lat());
 //NOTE: it always shows '0'
 st7735.st7735_write_str(0, 40, "valid: " + (String)GPS.satellites.isValid());
 Serial.println("*********** fin ***********");
 }
 else{
 Serial.println("Serial 1 no available"); 
 st7735.st7735_fill_screen(ST7735_BLACK);
 st7735.st7735_write_str(10, 50, (String)"Unavailable");
 delay(5000);
 }
 Serial.println("while 1");
 delay(5000);
 }
}
void setup(){
 delay(100);
 Serial.begin(115200);
 Serial.println("setup 1");
 pinMode(VGNSS_CTRL,OUTPUT);
 digitalWrite(VGNSS_CTRL,LOW);
 
 st7735.st7735_init();
 st7735.st7735_fill_screen(ST7735_BLACK);
 st7735.st7735_write_str(20, 10, (String)"Loading ...");
 st7735.st7735_write_str(20, 50, (String)"GPS_test");
 Serial.println("setup 2");
 GPS_test();
 Serial.println("setup 3");
}
void loop(){
 Serial.println("loop 1");
 delay(3000);
 Serial.println("loop 2");
}

I'm not sure if I have to connect the antenna to the GNSS module.

Is there something I can print in thelogs to bring more info?

========= EDITED =========

This is the serial monitor output:

01:13:43.526 -> GPS_test started
01:18:12.693 -> setup 1
01:18:12.871 -> setup 2
01:18:12.871 -> GPS 1
01:18:12.904 -> GPS_test
01:18:14.201 -> peek: 0
01:18:14.232 -> ***************************
01:18:14.232 -> 106
01:18:14.232 -> 106
01:18:14.232 -> 0.00
01:18:14.329 -> *********** fin ***********
01:18:14.329 -> while 1
01:18:19.610 -> peek: 0
01:18:19.685 -> ***************************
01:18:19.685 -> 79
01:18:19.685 -> 79
01:18:19.685 -> 0.00
01:18:19.738 -> *********** fin ***********
01:18:19.738 -> while 1
01:18:25.036 -> peek: 0
dda
1,5951 gold badge12 silver badges17 bronze badges
asked Jun 16, 2024 at 4:21
3
  • what does this mean? ... original code wasn't working for me Commented Jun 16, 2024 at 5:03
  • @jsotola, it means that serial monitor and screen were showing nothing. Commented Jun 16, 2024 at 5:15
  • "I'm not sure if I have to connect the antenna to the GNSS module." Without an antenna, how is the module supposed to receive signals from space? Commented Jun 23, 2024 at 3:01

2 Answers 2

1

#define VGNSS_CTRL 3

Based on the example code from Heltec Github page. The pin for VGNSS_Ctrl is pin 37 instead of pin 3 as shown in your code.

Further checking the schematic diagram for Heltec Wireless Tracker V1.0, it confirmed that VGNSS_Ctrl is indeed on pin 37 which is used to activate the VDD_GNSS (i.e. to enable the power supply for GPS module).

enter image description here

answered Jun 17, 2024 at 12:55
2
  • Hcheung solution is nearly correct, but the pin according schematic is not 37 but 36. Commented Jul 16, 2024 at 22:13
  • @PetrNovak No I think 37 is correct for VGNSS_CTRL on v1.0 which is the schematic shown here. They removed VGNSS_CTRL in v1.1 and replaced it with VEXT which is now pin 7. Commented May 22 at 13:14
1

Many COTS GNSS modules, when not in lock, send NMEA message with just commas where latitude and longitude are expected.

The UC6580, used on the Heltec Wireless Tracker, appears to use the NMEA 0183 data format.

As the NMEA messages do not appear in the posted code, it is assumed some or all are in the TinyGPSPlus library used in the above code.

If we go to the TinyGPSPlus github.com account we see there are example Arduino INO file. This example tracks multiple satellites and reports "Satellite numbers, elevation, azimuth, and signal-to-noise ratio". This data is usually available even before the GNSS module is in lock (producing latitude and longitude values). So it's useful during problem investigation.

Modify the question when more information is available. For now it sounds like a bad GNSS module, bad GNSS antenna, bad antenna connection or you are indoors where you can not see GNSS satellites.

dda
1,5951 gold badge12 silver badges17 bronze badges
answered Jun 16, 2024 at 13:23

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.