sagar saini
Published © GPL3+

ESP8266 and GNSS Interfacing

Getting the GPS co-ordinates reading on screen with the small setup of ESP8266 and RYS8830 module.

IntermediateFull instructions provided2 hours188
ESP8266 and GNSS Interfacing

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1

Software apps and online services

Arduino IDE
Arduino IDE
EasyEDA
JLCPCB EasyEDA

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Custom parts and enclosures

Gerber files

Schematics

Circuit and schematics

EVB circuit

Code

Arduino Code For GNSS

Arduino
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
static const int RXPin = D5, TXPin = D6;
static const uint32_t GPSBaud = 115200;
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
void setup()
{
  Serial.begin(115200);
  ss.begin(GPSBaud);
ss.print("@GSTP\r\n");//positioning stop
  delay(500);  
  ss.print("@GNS 47\r\n");// Positioning-use satellite use GPS + GLONASS + SBAS + QZSS L1-CA + QZSS L1-S
  delay(500); 
 //ss.print("@GPPS 1\r\n");// enable 1PPS function
// delay(500); 
  ss.print("@GSR\r\n");// hot start
  delay(2000);

  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  delay(2000);
  
}

void loop()
{
  // This sketch displays information every time a new sentence is correctly encoded.
  while (ss.available() > 0)
    if (gps.encode(ss.read()))
      displayInfo();

  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    Serial.println(F("No GPS detected: check wiring."));
    while(true);
  }
}

void displayInfo()
{
  Serial.print(F("Location: ")); 
  if (gps.location.isValid())
  {
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(","));
    Serial.print(gps.location.lng(), 6);
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  Serial.print(F("  Date/Time: "));
  if (gps.date.isValid())
  {
    Serial.print(gps.date.month());
    Serial.print(F("/"));
    Serial.print(gps.date.day());
    Serial.print(F("/"));
    Serial.print(gps.date.year());
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  Serial.print(F(" "));
  if (gps.time.isValid())
  {
    if (gps.time.hour() < 10) Serial.print(F("0"));
    Serial.print(gps.time.hour());
    Serial.print(F(":"));
    if (gps.time.minute() < 10) Serial.print(F("0"));
    Serial.print(gps.time.minute());
    Serial.print(F(":"));
    if (gps.time.second() < 10) Serial.print(F("0"));
    Serial.print(gps.time.second());
    Serial.print(F("."));
    if (gps.time.centisecond() < 10) Serial.print(F("0"));
    Serial.print(gps.time.centisecond());
  }
  else
  {
    Serial.print(F("INVALID"));
  }

  Serial.println();
  display.setTextSize(1);
  display.setTextColor(WHITE);

  display.setCursor(0,10);
  display.print("Latitude:");
  display.print(gps.location.lat(), 6);
  display.setCursor(0,30);
  display.print("Longitude:");
  display.print(gps.location.lng(), 6);
  
  display.display(); 
  delay(1000);
  display.clearDisplay();
}

Credits

sagar saini

sagar saini

78 projects • 80 followers
I am Sagar Saini an electronic hardware enthusiast

Comments