Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



GPS Data logger on ...
 
Share:
Notifications
Clear all

[Solved] GPS Data logger on Heltec ESP32 WiFi Board

12 Posts
5 Users
0 Likes
4,080 Views
 tvr4
(@tvr4)
Estimable Member
Joined: 4 years ago
Posts: 122
Topic starter  

I was able to get the GPS data logger working. I was using PIN 16 for GPS TX and PIN 17 for GPS RX but I could not get readable data from the GPS,

I then moved the GPS TX to PIN 23 and I immediately started receiving quality data from the GPS module.

Everything seems to be working but there is an issue.
When powering on the ESP32 there is no display. If I press the RST button the display appears and the code seems to be working
Any idea why this is happening?

Wiring is as follows (VCC on all modules to 5V, GND to Ground)
GPS module (ublox 6M)
RX - ESP32 PIN 23
TX - ESP32 PIN 17

SD Card Module
CS - ESP32 PIN 26
SCK - ESP32 PIN 27
MOSI - ESP32 PIN 14
MISO - ESP32 PIN 13

Code is attached
Any help is greatly appreciated

#include <Wire.h>
#include "SSD1306AsciiWire.h"
#include "SSD1306Ascii.h"

#include <TinyGPS++.h>
#include <mySD.h>

const int cs_sd=26;

TinyGPSPlus gps;

int maxspeed = 0, speed1 = 0;
int maxhigh = 0, high1 = 0;
int maxsatelite = 0, satelite1 = 0;

SSD1306AsciiWire oled;
#define I2C_ADDRESS 0x3C
#define RST_PIN 16


void setup() {
   Serial.begin(115200);

    Serial1.begin(9600, SERIAL_8N1, 23, 17);

  Wire.begin(4, 15);
  Wire.setClock(400000L);
  #if RST_PIN >= 0
    oled.begin(&Adafruit128x64, I2C_ADDRESS, RST_PIN);
  #else // RST_PIN >= 0
    oled.begin(&Adafruit128x64, I2C_ADDRESS);
  #endif // RST_PIN >= 0

  oled.setCursor(20,2); 
  oled.setFont(utf8font10x16);
  oled.print("GPS DATA LOGGER");
  oled.setCursor(50,4); 
  oled.print("BY ME");
  delay(4000);
  oled.clear();

    if (!SD.begin(26, 14, 13, 27))
  {
   oled.clear();
   oled.print("    NO SD Card");
   delay(2000);
   oled.clear();
   return;
  } 
   oled.print("  SD Card OK");
   delay(2000);
   oled.clear();
    
   File data = SD.open("GPS-data.txt",FILE_WRITE);        //Open the file "GPS-data.txt"
   data.println(""); data.println("Start Recording");    // Write to file
   data.close(); 
}


void loop() {   

    satelite1 = (abs(gps.satellites.value()));

    oled.setFont(Verdana12_bold); 
    oled.setCursor(0,0);
    oled.print("Vmax     ");
    oled.print("Hmax   ");
    oled.print("SAT  ");
    
   speed1 = (gps.speed.mph());
  if ( speed1 > maxspeed) {
    maxspeed = speed1;
  }

  oled.setFont(Arial_bold_14);
  oled.setCursor(10 , 2); 
  oled.clearToEOL();
  oled.print(maxspeed);
  
  high1 = (gps.altitude.feet());
  if ( high1 > maxhigh) {
    maxhigh = high1;
  }
  
  oled.setCursor(50 , 2);  //prev 50,1
  oled.print(maxhigh);

  oled.setCursor(100 , 2);  //prev 100,1
  oled.print(satelite1);

  oled.println(" ");
  oled.println(" ");

  oled.setFont(Verdana12_bold);

  oled.setCursor(0 , 4.5);
  oled.print("LAT    ");
  oled.println(gps.location.lat(),6);
  oled.print("LNG  ");
  oled.println(gps.location.lng(),6);
  
//-4 is eastern time offset
  String Temps=String(gps.time.hour()-4)+(":")+(gps.time.minute())+(":")+(gps.time.second());
  String Date=String(gps.date.month())+("/")+(gps.date.day())+("/")+(gps.date.year());

  if (satelite1 > 1)  {
    File data=SD.open("GPS-data.txt",FILE_WRITE);
    data.println(Date + " " + Temps + " " + String(gps.location.lat(), 6)+" "+String(gps.location.lng(), 6)+(" ")+String(gps.altitude.feet(),0)+(" ")+String(gps.speed.mph(),0)+(" ")+String(satelite1)); 
    data.close();  
   }
    DelayGPS(100);
  }


  static void DelayGPS(unsigned long ms)
{
  unsigned long start = millis();
  do
  {
    while (Serial1.available())
      gps.encode(Serial1.read());
  } while (millis() - start < ms);
}

   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2675
 

Having seen this with one of my projects: give the ESP a slight delay in it's startup.
By lack of really knowing what is going on, I think the ESP at times may be too fast.

Something like the change below.
This may not be the best location, so you may have to try a different location and/or time amount - I've also noticed with one of my LED projects that "delay(0);" sometimes already seem to do the trick.

 void setup() {
  Serial.begin(115200);

  Serial1.begin(9600, SERIAL_8N1, 23, 17);

  Wire.begin(4, 15);
  Wire.setClock(400000L);
delay(100); #if RST_PIN >= 0 oled.begin(&Adafruit128x64, I2C_ADDRESS, RST_PIN); #else // RST_PIN >= 0 oled.begin(&Adafruit128x64, I2C_ADDRESS); #endif // RST_PIN >= 0 oled.setCursor(20,2); oled.setFont(utf8font10x16); oled.print("GPS DATA LOGGER"); oled.setCursor(50,4); oled.print("BY ME"); delay(4000); oled.clear(); if (!SD.begin(26, 14, 13, 27)) { oled.clear(); oled.print(" NO SD Card"); delay(2000); oled.clear(); return; } oled.print(" SD Card OK"); delay(2000); oled.clear(); File data = SD.open("GPS-data.txt",FILE_WRITE); //Open the file "GPS-data.txt" data.println(""); data.println("Start Recording"); // Write to file data.close(); }

 

 


   
ReplyQuote
 tvr4
(@tvr4)
Estimable Member
Joined: 4 years ago
Posts: 122
Topic starter  

I have tried delay up to 1000 and still can't get it to work.  It appears to be a display issue of some kind

I inserted a line within setup to write "setup" on the serial monitor and another line in the main loop to send "loop" to the serial montor.

1) If I power up the ESP32 I see nothing on the serial monitor and nothing on the display. 
2) If I press the reset button the display works and the sketch starts operating properly.  But nothing appears on the serial monitor
I have to close and reopen the serial monitor for it to operate

3) At this point the serial monitor shows "main loop"

So the code is running but the display is not showing anything

 


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2675
 

Could it be a conflict between serial port for the serial monitor and the pin's you have used for you GPS/SD ?
It "feels" like the serial port (for the serial monitor and/or GPS) is somehow conflicting.

From what you wrote, I'd say "no", but it may be worth inspecting.

From this article I see that these pins should be avoided:

  • GPIO 6 (SCK/CLK)
  • GPIO 7 (SDO/SD0)
  • GPIO 8 (SDI/SD1)
  • GPIO 9 (SHD/SD2)
  • GPIO 10 (SWP/SD3)
  • GPIO 11 (CSC/CMD)

None of them you seem to be using ... 🤔 


   
ReplyQuote
 tvr4
(@tvr4)
Estimable Member
Joined: 4 years ago
Posts: 122
Topic starter  

I found the problem with the display not working.  I looked at some of the examples that were included in Heltec.h library, which the manufacturer listed to install for the board.  There was one line that all the OLED examples started with:

#include "heltec.h"

Heltec.begin(true /*DisplayEnable Enable*/, false /*LoRa Enable*/, true /*Serial Enable*/);

 

This second line is what fixed the display.  No delay or other modification needed.
When you plug the board in to the USB for power (I don't have an external power source yet) the program quickly displays that start screen

 


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2675
 

Nice find! Just a little sad that it is needed haha.
But I'm glad to hear that you found a fix. 👍 


   
ReplyQuote
 tvr4
(@tvr4)
Estimable Member
Joined: 4 years ago
Posts: 122
Topic starter  

@hansI agree.  Seems to be a waste to include the heltec library for one statement.  That lib also does sisplay control but it is poorly implemented and comfusing.  Plus it only works on that board.

At least the SSD1306Ascii will work on the Uno, Nano and the ESP32


   
ReplyQuote
(@asagong)
New Member
Joined: 3 years ago
Posts: 0
 

Hi....I was able to port the GPS Data Logger to the Heltec ESP32 with built-in OLED

I am still working on a 3.3V configuration and battery power. The microSD module I bought was supposed to work on 3.3V and 5V but it turns out that it is 5V only. But I have another SD board coming to resolve that.


   
ReplyQuote
(@enricop)
New Member
Joined: 3 years ago
Posts: 0
 

@tvr4 Hi!

I am having a hard time trying to get data from an Ublox 6M GPS module with the Heltec ESP32 Lora V2. I read that you powered the module with 5V, correct? I see from the tech specs that it works with 3V3. Should I power it with the 5V?

Thank you.


   
ReplyQuote
(@michaelzen)
Active Member
Joined: 3 years ago
Posts: 10
 

Hello gents, what a coincidence :)

 

Is this the follow up from the last Heltec v.s. GPS topic? I do hope so as I'm restarting that project too 😬

But already I'm lost as the code here seems incomplete, and my Heltec doesn't show any sign of receiving it's upload...

I do have an ESP 32 board with camera but no OLED which I could use to test with, any ideas if that would give very different results?


   
ReplyQuote
 tvr4
(@tvr4)
Estimable Member
Joined: 4 years ago
Posts: 122
Topic starter  

I believe this is part of the thread I started on the ESP32 Heltec board.  It has been a while since I have been able to work on the project.

The ESP32 board should be similar.  The Heltec board has a specific statement to tall the heltec library.  All it does is enable the OLED and I2C bus.  Your board may do that without the statement.

I put this project aside because the MPU6050 would freeze after a short random period and stop sending data.  
While looking for a solution I found another accemerometer/gyro module that seems to work.  
It uses the same I2C bus and does not freeze.  The only problem is I need to find out how to calibrate the module.

The readings never settle to zero 


   
ReplyQuote
(@michaelzen)
Active Member
Joined: 3 years ago
Posts: 10
 

Thanks again for the input but I've decided to leave this project, almost everything a little more complicated then blink doesn't seem to work and needs correction of the Arduino community and as they are overwhelmingly hostile on the official forums I'll stick to the simple projects I can work out myself and stay away from the complicated setups I can't work out, this goes not for you as I enjoyed thinking along with this project, but even getting a reading from the GPS module or MPU stand alone seems impossible. 😐 


   
ReplyQuote
Share: