I would like to use a GPS module with the ESP32 it uses two pins, one for RX and one for TX.
What pins on the ESP32 can I use for this?
The GPS examples I have use the SoftwareSerial.h library but this gives an error compiling "SoftwareSerial.h: No such file or directory"
How can I use this on the ESP32?
Thanks
GPS with ESP32 SoftwareSerial
Re: GPS with ESP32 SoftwareSerial
This is actually from code i used to test GPS:
Code: Select all
void setup() {
Serial.begin(115200);
Serial1.begin(9600, SERIAL_8N1, 13, 14); // any 2 pins
}
void loop() {
if (Serial1.available()) {
Serial.write(Serial1.read()); // read it and send it out Serial (USB)
}
}
Re: GPS with ESP32 SoftwareSerial
This is GREAT. Thank you
Are there restrictions so there there are PINS that I should not use?
Are there restrictions so there there are PINS that I should not use?
-
- Posts: 828
- Joined: Mon Jul 22, 2019 3:20 pm
Re: GPS with ESP32 SoftwareSerial (Heltec WiFi V2)
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
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);
}
Re: GPS with ESP32 SoftwareSerial
I've found something interesting when I was acessing instructables. Have you ever considered using the ESP32 and the GPS with an OLED Display? I just saw it there want wanted to show it to you, you could acess here: https://www.instructables.com/id/ESP32- ... D-Display/
If you got interested, you could acess my blog from here: https://flaviobabos.com.br/arduino/. I'll publish lots of iot articles, so, keep up informed.
NOTE: You'll have to use the translator extension to read it in english. Thanks!
If you got interested, you could acess my blog from here: https://flaviobabos.com.br/arduino/. I'll publish lots of iot articles, so, keep up informed.
NOTE: You'll have to use the translator extension to read it in english. Thanks!
Re: GPS with ESP32 SoftwareSerial
You must have been reading my mind.
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.
I am happy to share when I have it completed, o your blog if you like.
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.
I am happy to share when I have it completed, o your blog if you like.
Who is online
Users browsing this forum: No registered users and 93 guests