balab
April 15, 2024, 8:04am
#1
Hi Team,
I am trying to read GPS coordinates from Neo-6M gps module. Tried executing multiple examples from Arduino libraries like FuGPS, TinyGPS++, NeoGPS, Neo6MGPS, NMEA Parsers etc. Program compiles and flashes successfully but serial monitor shows nothing.
Any suggestions please…!
Is the GPS outdoors with a good view of the sky ?
The simple program below will copy the GPS output to the serial monitor.
It assumes the GPS is on hardware serial port Serial1, adjust as necessary for your setup;
void loop()
{
while (Serial1.available())
{
Serial.write(Serial1.read());
}
}
void setup()
{
Serial1.begin(9600);
Serial.begin(115200);
Serial.println();
Serial.println("GPS_Echo_Hardware_Serial Starting");
}
its been a while, but i know there is something to o with hardware and software serial… the ESP32 uses the opposite of the other boards
I have a demo on here of the GPS with AIR530 and Xiao ESP32C3
here is the code from that thread.
#include <Arduino.h>
#include <U8x8lib.h>
#include <Wire.h>
#include <TinyGPSPlus.h>
static const int RXPin = 6, TXPin = 7; // 6, 7
static const uint32_t GPSBaud = 9600;
//TinyGPSPlus object
TinyGPSPlus gps;
//Display object
U8X8_SSD1306_128X64_NONAME_HW_I2C u8x8(/* clock=*/ PIN_WIRE_SCL, /* data=*/ PIN_WIRE_SDA, /* reset=*/ U8X8_PIN_NONE); // OLEDs without Reset of the Display
const int pinLed = LED_BUILTIN;
float __longitude = 0;
float __latitude = 0;
const int ledPin = LED_BUILTIN;
int BuzzerPin = A3; //A3 , P0.29 PIN 4
int buzzer = BuzzerPin;
void setup(void) {
u8x8.begin();
u8x8.setFlipMode(1); // set number from 1 to 3, the screen word will rotary 180
Serial1.begin(GPSBaud);
Serial.begin(9600);
delay(2000); //relax...Get Ready for serial port
Serial.println("Test program" __FILE__ " compiled on " __DATE__ " at " __TIME__);
Serial.println();
Serial.println("Processor came out of reset.");
initdisplay();
setupblink();
}
void loop(void) {
dispGPS();
while (Serial1.available() > 0)
if (gps.encode(Serial1.read()))
{
__latitude = gps.location.lat();
__longitude = gps.location.lng();
}
}
void dispGPS()
{
//Serial.println("getting gps");
u8x8.setCursor(0, 0);
u8x8.print("GPS LOCATION ");
u8x8.setCursor(0, 3);
u8x8.print(__latitude, 6);
u8x8.setCursor(0, 5);
u8x8.print(__longitude, 6);
}
void setupblink(){
setLedRGB(false, false, true); // set Blue LED
delay(1000);
setLedRGB(false, true, false); // Red
delay(1000);
setLedRGB(true, false, false); // Green
delay(1000);
setLedRGB(false, false, false); // OFF
}
void initdisplay() {
pinMode(LEDR, OUTPUT); // initialize the LED pin as an output:
pinMode(LEDG, OUTPUT); // initialize the LED pin as an output:
pinMode(LEDB, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT); // initialize the LED pin as an output:
u8x8.begin();
u8x8.setFlipMode(1); // set number from 1 to 3, the screen word will rotary 180
u8x8.setFont(u8x8_font_8x13B_1x2_r);
u8x8.clearDisplay();
u8x8.setCursor(0, 0);
u8x8.print("Power ON ");
}
void startsound() {
tone (buzzer, 890);
delay (220);
noTone(buzzer);
delay (20);
tone (buzzer, 800);
delay (220);
noTone(buzzer);
delay (20);
tone (buzzer, 800);
delay (220);
noTone(buzzer);
delay (20);
tone (buzzer, 990);
delay (420);
noTone(buzzer);
delay (20);
}
void setLedRGB(bool red, bool green, bool blue) {
if (!red) { digitalWrite(LEDR, HIGH); } else { digitalWrite(LEDR, LOW); }
if (!green) { digitalWrite(LEDG, HIGH); } else { digitalWrite(LEDG, LOW); }
if (!blue) { digitalWrite(LEDB, HIGH); } else { digitalWrite(LEDB, LOW); }
}
// END
HTH
GL PJ
Got the AIr530 connected to the expansion board with Xiao Sense on board.
GPS library TinyGPS, basic example works well, Co-ordinates are Very accurate AFAIK less than a meter for sure. You get a Green Yellow flip of the LED’s when Connected to Sats, Green when powered on.
Here’s the basic code and pictures.
The last one is the connected to U-center from Ublox with a free Google maps API key inserted.
HTH
GL PJ
Scary how accurate this is even indoors , one of those Ukrainian…
2 Likes
There are issues with software serial for sure.
Avoid doing other stuff such as Serial prints, writing to displays or using other devices if software serial is running.
Best to avoid using software serial if you can.