How to get ESP32 to datalog GPS to an SD and show OLED display
up vote
1
down vote
favorite
I'm using an ESP32 (Wemos D1 Mini) to track GPS (RadioLink SE100), show it on an OLED, and write it to an SD card (VMA304). Everything works well, independently. But put all together, the compile is fine, the upload works, the OLED displays some early messages, and GPS is transmitting data, but then things stop working.
I did get a serial message: "More than 100 frame errors, UART RX was disabled." So, I commented out the Serial.begin(115200) line.
In the serial monitor good GPS data is being output, but that doesn't get written by the SD file. GPS is the root of the problem, I think. If I just disable GPS, everything else works. Any ideas?
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h> // OLED - text
#include <Adafruit_GFX.h> // OLED - graphics
#include <ESP8266WiFi.h> // WeMos D1 Mini ESP32
#include <SD.h> // SD Card (VMA304)
#include "TinyGPS++.h" // RadioLink SE100
#include "SoftwareSerial.h"
SoftwareSerial GPSmodule(0,2); // DON'T USE TX and RX pins!!
TinyGPSPlus gps; // GPS object for the NMEA data
#define OLED_ADDR 0x3C // OLED display TWI address
Adafruit_SSD1306 display(-1);
#define CS_pin D8 // SD card - needs to be output
File myFile;
void setup() {
// Serial.begin( 115200 );
// start OLED display
display.begin( SSD1306_SWITCHCAPVCC, OLED_ADDR );
display.setTextSize(2);
display.setTextColor(WHITE);
display.clearDisplay();
display.setCursor(20,10);
display.print("GPS data to");
display.setCursor(20,30);
display.print("OLED display");
display.setCursor(20,50);
display.print("& SD Card");
display.display();
// start GPS
GPSmodule.begin( 9600 ); // start the GPS
Serial.println( "GPS Start" );
// start SD card
pinMode( CS_pin, OUTPUT ); // for SD card
if( !SD.begin( CS_pin )) {
Serial.println( "SD card initialization failed!" );
return;
}
Serial.println( "SD card initialized." );
}
void loop() {
while(GPSmodule.available()) { // While characters come from the GPS
gps.encode(GPSmodule.read()); // Feed serial NMEA data into library one char at a time
}
if( gps.location.isUpdated() ) { // constantly get packages of NMEA data
// Write the latest info from the GPS data to the SD card
display.clearDisplay();
display.setCursor(20,10);
display.print( "Wemos.txt" );
display.display();
myFile = SD.open( "Wemos.txt", FILE_WRITE );
// write stuff in it
if( myFile ) {
display.clearDisplay();
display.setCursor(20,30);
display.print( "GPS data" );
display.display();
myFile.println("Satellite Count:");
myFile.println(gps.satellites.value());
myFile.println("Latitude:");
myFile.println(gps.location.lat(), 6);
myFile.println("Longitude:");
myFile.println(gps.location.lng(), 6);
myFile.println("Speed MPH:");
myFile.println(gps.speed.mph());
myFile.println("Altitude Feet:");
myFile.println(gps.altitude.feet());
myFile.println("");
display.setCursor(20,30);
display.print( "file done" );
display.display();
}
myFile.close();
delay(100);
}
}
MY MISTAKE: I used the RX and TX pins on the ESP32. Don't do that!
It will output all the GPS data on the Serial Monitor (slightly edited to hide my location, :-)
There should only by MY prints on the Serial Monitor.
$GLGSV,3,1,10,66,42,088,24,68,62,000,48,68,24,298,,86,01,018,*6E
$GLGSV,3,2,10,86,44,046,41,88,46,129,40,88,10,181,,82,24,248,36*6E
$GLGSV,3,4,10,84,44,294,18,84,06,446,*61
$GNGLL,4246.18869,N,08409.46219,W,196640.00,A,A*61
$GNRMC,196641.00,A,4246.18880,N,08409.46228,W,0.146,,111118,,,A*8A
$GNVTG,,T,,M,0.146,N,0.268,K,A*41
$GNGGA,196642.00,4246.18880,N,08409.46228,W,1,12,0.84,246.6,M,-44.9,M,,*82
$GNGSA,A,4,10,20,42,24,14,21,16,12,26,,,,1.64,0.84,1.29*18
$GNGSA,A,4,68,88,86,66,84,82,,,,,,,1.64,0.84,1.29*1B
$GPGSV,5,1,18,08,06,289,,10,86,332,40,11,02,428,,12,11,106,19*88
$GPGSV,5,2,18,14,40,266,28,16,14,080,24,18,14,421,18,20,80,118,46*88
$GPGSV,5,3,18,21,26,184,21,24,41,068,16,26,06,139,22,28,04,261,09*86
$GPGSV,5,4,18,41,00,206,,42,49,268,41,46,24,248,,48,20,240,28*81
$GPGSV,5,6,18,61,46,214,*4A
gps sd-card uart i2c esp32
add a comment |
up vote
1
down vote
favorite
I'm using an ESP32 (Wemos D1 Mini) to track GPS (RadioLink SE100), show it on an OLED, and write it to an SD card (VMA304). Everything works well, independently. But put all together, the compile is fine, the upload works, the OLED displays some early messages, and GPS is transmitting data, but then things stop working.
I did get a serial message: "More than 100 frame errors, UART RX was disabled." So, I commented out the Serial.begin(115200) line.
In the serial monitor good GPS data is being output, but that doesn't get written by the SD file. GPS is the root of the problem, I think. If I just disable GPS, everything else works. Any ideas?
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h> // OLED - text
#include <Adafruit_GFX.h> // OLED - graphics
#include <ESP8266WiFi.h> // WeMos D1 Mini ESP32
#include <SD.h> // SD Card (VMA304)
#include "TinyGPS++.h" // RadioLink SE100
#include "SoftwareSerial.h"
SoftwareSerial GPSmodule(0,2); // DON'T USE TX and RX pins!!
TinyGPSPlus gps; // GPS object for the NMEA data
#define OLED_ADDR 0x3C // OLED display TWI address
Adafruit_SSD1306 display(-1);
#define CS_pin D8 // SD card - needs to be output
File myFile;
void setup() {
// Serial.begin( 115200 );
// start OLED display
display.begin( SSD1306_SWITCHCAPVCC, OLED_ADDR );
display.setTextSize(2);
display.setTextColor(WHITE);
display.clearDisplay();
display.setCursor(20,10);
display.print("GPS data to");
display.setCursor(20,30);
display.print("OLED display");
display.setCursor(20,50);
display.print("& SD Card");
display.display();
// start GPS
GPSmodule.begin( 9600 ); // start the GPS
Serial.println( "GPS Start" );
// start SD card
pinMode( CS_pin, OUTPUT ); // for SD card
if( !SD.begin( CS_pin )) {
Serial.println( "SD card initialization failed!" );
return;
}
Serial.println( "SD card initialized." );
}
void loop() {
while(GPSmodule.available()) { // While characters come from the GPS
gps.encode(GPSmodule.read()); // Feed serial NMEA data into library one char at a time
}
if( gps.location.isUpdated() ) { // constantly get packages of NMEA data
// Write the latest info from the GPS data to the SD card
display.clearDisplay();
display.setCursor(20,10);
display.print( "Wemos.txt" );
display.display();
myFile = SD.open( "Wemos.txt", FILE_WRITE );
// write stuff in it
if( myFile ) {
display.clearDisplay();
display.setCursor(20,30);
display.print( "GPS data" );
display.display();
myFile.println("Satellite Count:");
myFile.println(gps.satellites.value());
myFile.println("Latitude:");
myFile.println(gps.location.lat(), 6);
myFile.println("Longitude:");
myFile.println(gps.location.lng(), 6);
myFile.println("Speed MPH:");
myFile.println(gps.speed.mph());
myFile.println("Altitude Feet:");
myFile.println(gps.altitude.feet());
myFile.println("");
display.setCursor(20,30);
display.print( "file done" );
display.display();
}
myFile.close();
delay(100);
}
}
MY MISTAKE: I used the RX and TX pins on the ESP32. Don't do that!
It will output all the GPS data on the Serial Monitor (slightly edited to hide my location, :-)
There should only by MY prints on the Serial Monitor.
$GLGSV,3,1,10,66,42,088,24,68,62,000,48,68,24,298,,86,01,018,*6E
$GLGSV,3,2,10,86,44,046,41,88,46,129,40,88,10,181,,82,24,248,36*6E
$GLGSV,3,4,10,84,44,294,18,84,06,446,*61
$GNGLL,4246.18869,N,08409.46219,W,196640.00,A,A*61
$GNRMC,196641.00,A,4246.18880,N,08409.46228,W,0.146,,111118,,,A*8A
$GNVTG,,T,,M,0.146,N,0.268,K,A*41
$GNGGA,196642.00,4246.18880,N,08409.46228,W,1,12,0.84,246.6,M,-44.9,M,,*82
$GNGSA,A,4,10,20,42,24,14,21,16,12,26,,,,1.64,0.84,1.29*18
$GNGSA,A,4,68,88,86,66,84,82,,,,,,,1.64,0.84,1.29*1B
$GPGSV,5,1,18,08,06,289,,10,86,332,40,11,02,428,,12,11,106,19*88
$GPGSV,5,2,18,14,40,266,28,16,14,080,24,18,14,421,18,20,80,118,46*88
$GPGSV,5,3,18,21,26,184,21,24,41,068,16,26,06,139,22,28,04,261,09*86
$GPGSV,5,4,18,41,00,206,,42,49,268,41,46,24,248,,48,20,240,28*81
$GPGSV,5,6,18,61,46,214,*4A
gps sd-card uart i2c esp32
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I'm using an ESP32 (Wemos D1 Mini) to track GPS (RadioLink SE100), show it on an OLED, and write it to an SD card (VMA304). Everything works well, independently. But put all together, the compile is fine, the upload works, the OLED displays some early messages, and GPS is transmitting data, but then things stop working.
I did get a serial message: "More than 100 frame errors, UART RX was disabled." So, I commented out the Serial.begin(115200) line.
In the serial monitor good GPS data is being output, but that doesn't get written by the SD file. GPS is the root of the problem, I think. If I just disable GPS, everything else works. Any ideas?
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h> // OLED - text
#include <Adafruit_GFX.h> // OLED - graphics
#include <ESP8266WiFi.h> // WeMos D1 Mini ESP32
#include <SD.h> // SD Card (VMA304)
#include "TinyGPS++.h" // RadioLink SE100
#include "SoftwareSerial.h"
SoftwareSerial GPSmodule(0,2); // DON'T USE TX and RX pins!!
TinyGPSPlus gps; // GPS object for the NMEA data
#define OLED_ADDR 0x3C // OLED display TWI address
Adafruit_SSD1306 display(-1);
#define CS_pin D8 // SD card - needs to be output
File myFile;
void setup() {
// Serial.begin( 115200 );
// start OLED display
display.begin( SSD1306_SWITCHCAPVCC, OLED_ADDR );
display.setTextSize(2);
display.setTextColor(WHITE);
display.clearDisplay();
display.setCursor(20,10);
display.print("GPS data to");
display.setCursor(20,30);
display.print("OLED display");
display.setCursor(20,50);
display.print("& SD Card");
display.display();
// start GPS
GPSmodule.begin( 9600 ); // start the GPS
Serial.println( "GPS Start" );
// start SD card
pinMode( CS_pin, OUTPUT ); // for SD card
if( !SD.begin( CS_pin )) {
Serial.println( "SD card initialization failed!" );
return;
}
Serial.println( "SD card initialized." );
}
void loop() {
while(GPSmodule.available()) { // While characters come from the GPS
gps.encode(GPSmodule.read()); // Feed serial NMEA data into library one char at a time
}
if( gps.location.isUpdated() ) { // constantly get packages of NMEA data
// Write the latest info from the GPS data to the SD card
display.clearDisplay();
display.setCursor(20,10);
display.print( "Wemos.txt" );
display.display();
myFile = SD.open( "Wemos.txt", FILE_WRITE );
// write stuff in it
if( myFile ) {
display.clearDisplay();
display.setCursor(20,30);
display.print( "GPS data" );
display.display();
myFile.println("Satellite Count:");
myFile.println(gps.satellites.value());
myFile.println("Latitude:");
myFile.println(gps.location.lat(), 6);
myFile.println("Longitude:");
myFile.println(gps.location.lng(), 6);
myFile.println("Speed MPH:");
myFile.println(gps.speed.mph());
myFile.println("Altitude Feet:");
myFile.println(gps.altitude.feet());
myFile.println("");
display.setCursor(20,30);
display.print( "file done" );
display.display();
}
myFile.close();
delay(100);
}
}
MY MISTAKE: I used the RX and TX pins on the ESP32. Don't do that!
It will output all the GPS data on the Serial Monitor (slightly edited to hide my location, :-)
There should only by MY prints on the Serial Monitor.
$GLGSV,3,1,10,66,42,088,24,68,62,000,48,68,24,298,,86,01,018,*6E
$GLGSV,3,2,10,86,44,046,41,88,46,129,40,88,10,181,,82,24,248,36*6E
$GLGSV,3,4,10,84,44,294,18,84,06,446,*61
$GNGLL,4246.18869,N,08409.46219,W,196640.00,A,A*61
$GNRMC,196641.00,A,4246.18880,N,08409.46228,W,0.146,,111118,,,A*8A
$GNVTG,,T,,M,0.146,N,0.268,K,A*41
$GNGGA,196642.00,4246.18880,N,08409.46228,W,1,12,0.84,246.6,M,-44.9,M,,*82
$GNGSA,A,4,10,20,42,24,14,21,16,12,26,,,,1.64,0.84,1.29*18
$GNGSA,A,4,68,88,86,66,84,82,,,,,,,1.64,0.84,1.29*1B
$GPGSV,5,1,18,08,06,289,,10,86,332,40,11,02,428,,12,11,106,19*88
$GPGSV,5,2,18,14,40,266,28,16,14,080,24,18,14,421,18,20,80,118,46*88
$GPGSV,5,3,18,21,26,184,21,24,41,068,16,26,06,139,22,28,04,261,09*86
$GPGSV,5,4,18,41,00,206,,42,49,268,41,46,24,248,,48,20,240,28*81
$GPGSV,5,6,18,61,46,214,*4A
gps sd-card uart i2c esp32
I'm using an ESP32 (Wemos D1 Mini) to track GPS (RadioLink SE100), show it on an OLED, and write it to an SD card (VMA304). Everything works well, independently. But put all together, the compile is fine, the upload works, the OLED displays some early messages, and GPS is transmitting data, but then things stop working.
I did get a serial message: "More than 100 frame errors, UART RX was disabled." So, I commented out the Serial.begin(115200) line.
In the serial monitor good GPS data is being output, but that doesn't get written by the SD file. GPS is the root of the problem, I think. If I just disable GPS, everything else works. Any ideas?
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h> // OLED - text
#include <Adafruit_GFX.h> // OLED - graphics
#include <ESP8266WiFi.h> // WeMos D1 Mini ESP32
#include <SD.h> // SD Card (VMA304)
#include "TinyGPS++.h" // RadioLink SE100
#include "SoftwareSerial.h"
SoftwareSerial GPSmodule(0,2); // DON'T USE TX and RX pins!!
TinyGPSPlus gps; // GPS object for the NMEA data
#define OLED_ADDR 0x3C // OLED display TWI address
Adafruit_SSD1306 display(-1);
#define CS_pin D8 // SD card - needs to be output
File myFile;
void setup() {
// Serial.begin( 115200 );
// start OLED display
display.begin( SSD1306_SWITCHCAPVCC, OLED_ADDR );
display.setTextSize(2);
display.setTextColor(WHITE);
display.clearDisplay();
display.setCursor(20,10);
display.print("GPS data to");
display.setCursor(20,30);
display.print("OLED display");
display.setCursor(20,50);
display.print("& SD Card");
display.display();
// start GPS
GPSmodule.begin( 9600 ); // start the GPS
Serial.println( "GPS Start" );
// start SD card
pinMode( CS_pin, OUTPUT ); // for SD card
if( !SD.begin( CS_pin )) {
Serial.println( "SD card initialization failed!" );
return;
}
Serial.println( "SD card initialized." );
}
void loop() {
while(GPSmodule.available()) { // While characters come from the GPS
gps.encode(GPSmodule.read()); // Feed serial NMEA data into library one char at a time
}
if( gps.location.isUpdated() ) { // constantly get packages of NMEA data
// Write the latest info from the GPS data to the SD card
display.clearDisplay();
display.setCursor(20,10);
display.print( "Wemos.txt" );
display.display();
myFile = SD.open( "Wemos.txt", FILE_WRITE );
// write stuff in it
if( myFile ) {
display.clearDisplay();
display.setCursor(20,30);
display.print( "GPS data" );
display.display();
myFile.println("Satellite Count:");
myFile.println(gps.satellites.value());
myFile.println("Latitude:");
myFile.println(gps.location.lat(), 6);
myFile.println("Longitude:");
myFile.println(gps.location.lng(), 6);
myFile.println("Speed MPH:");
myFile.println(gps.speed.mph());
myFile.println("Altitude Feet:");
myFile.println(gps.altitude.feet());
myFile.println("");
display.setCursor(20,30);
display.print( "file done" );
display.display();
}
myFile.close();
delay(100);
}
}
MY MISTAKE: I used the RX and TX pins on the ESP32. Don't do that!
It will output all the GPS data on the Serial Monitor (slightly edited to hide my location, :-)
There should only by MY prints on the Serial Monitor.
$GLGSV,3,1,10,66,42,088,24,68,62,000,48,68,24,298,,86,01,018,*6E
$GLGSV,3,2,10,86,44,046,41,88,46,129,40,88,10,181,,82,24,248,36*6E
$GLGSV,3,4,10,84,44,294,18,84,06,446,*61
$GNGLL,4246.18869,N,08409.46219,W,196640.00,A,A*61
$GNRMC,196641.00,A,4246.18880,N,08409.46228,W,0.146,,111118,,,A*8A
$GNVTG,,T,,M,0.146,N,0.268,K,A*41
$GNGGA,196642.00,4246.18880,N,08409.46228,W,1,12,0.84,246.6,M,-44.9,M,,*82
$GNGSA,A,4,10,20,42,24,14,21,16,12,26,,,,1.64,0.84,1.29*18
$GNGSA,A,4,68,88,86,66,84,82,,,,,,,1.64,0.84,1.29*1B
$GPGSV,5,1,18,08,06,289,,10,86,332,40,11,02,428,,12,11,106,19*88
$GPGSV,5,2,18,14,40,266,28,16,14,080,24,18,14,421,18,20,80,118,46*88
$GPGSV,5,3,18,21,26,184,21,24,41,068,16,26,06,139,22,28,04,261,09*86
$GPGSV,5,4,18,41,00,206,,42,49,268,41,46,24,248,,48,20,240,28*81
$GPGSV,5,6,18,61,46,214,*4A
gps sd-card uart i2c esp32
gps sd-card uart i2c esp32
edited Nov 14 at 2:20
asked Nov 11 at 19:07
Rick_CBR929RR
92110
92110
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
I think The device can not be read once for data that needs to be read within the allowed time. You can use this function (smartdelay(100)) to change "delay(100)"
static void smartdelay(unsigned long ms)
{
unsigned long start = millis();
do
{
while (GPSmodule.available())
gps.encode(GPSmodule.read());
} while (millis() - start < ms);
}
You should only open files once.
I hope this can help you.
add a comment |
up vote
0
down vote
Turns out using the chip's RX and TX pins is the big mistake. Switched the GPS RX and TX over to other unused pins and - BAM! - everything works.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I think The device can not be read once for data that needs to be read within the allowed time. You can use this function (smartdelay(100)) to change "delay(100)"
static void smartdelay(unsigned long ms)
{
unsigned long start = millis();
do
{
while (GPSmodule.available())
gps.encode(GPSmodule.read());
} while (millis() - start < ms);
}
You should only open files once.
I hope this can help you.
add a comment |
up vote
0
down vote
I think The device can not be read once for data that needs to be read within the allowed time. You can use this function (smartdelay(100)) to change "delay(100)"
static void smartdelay(unsigned long ms)
{
unsigned long start = millis();
do
{
while (GPSmodule.available())
gps.encode(GPSmodule.read());
} while (millis() - start < ms);
}
You should only open files once.
I hope this can help you.
add a comment |
up vote
0
down vote
up vote
0
down vote
I think The device can not be read once for data that needs to be read within the allowed time. You can use this function (smartdelay(100)) to change "delay(100)"
static void smartdelay(unsigned long ms)
{
unsigned long start = millis();
do
{
while (GPSmodule.available())
gps.encode(GPSmodule.read());
} while (millis() - start < ms);
}
You should only open files once.
I hope this can help you.
I think The device can not be read once for data that needs to be read within the allowed time. You can use this function (smartdelay(100)) to change "delay(100)"
static void smartdelay(unsigned long ms)
{
unsigned long start = millis();
do
{
while (GPSmodule.available())
gps.encode(GPSmodule.read());
} while (millis() - start < ms);
}
You should only open files once.
I hope this can help you.
answered Nov 12 at 2:49
VuNT
12
12
add a comment |
add a comment |
up vote
0
down vote
Turns out using the chip's RX and TX pins is the big mistake. Switched the GPS RX and TX over to other unused pins and - BAM! - everything works.
add a comment |
up vote
0
down vote
Turns out using the chip's RX and TX pins is the big mistake. Switched the GPS RX and TX over to other unused pins and - BAM! - everything works.
add a comment |
up vote
0
down vote
up vote
0
down vote
Turns out using the chip's RX and TX pins is the big mistake. Switched the GPS RX and TX over to other unused pins and - BAM! - everything works.
Turns out using the chip's RX and TX pins is the big mistake. Switched the GPS RX and TX over to other unused pins and - BAM! - everything works.
answered Nov 14 at 2:27
Rick_CBR929RR
92110
92110
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53252187%2fhow-to-get-esp32-to-datalog-gps-to-an-sd-and-show-oled-display%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown