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
Code: Select all
//
#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);
}