GPS Sensor Trouble

Hello! I am using an Arduino Micro with a NEO-6M GPS Sensor. My goal is to use this on a rocket to get real-time telemetry about the rocket and its location. My code compiles correctly and uploads, but I do not receive any data back to the monitor. I put in a test with the code to see if the Arduino received any data from the GPS, but it did not. Any thoughts?

My code and set up are attached.

GPS_TEST.ino (527 Bytes)

For informed help, please read and follow the directions in the "How to use this forum" post.

GPS generally works only outdoors, with a clear view of the sky.

I guess only you can know exactly what 'any data' actually means; what exactly is the output on the serial monitor ?

Pictures of breadboards are very difficult to understand, far better to provide a circuit diagram of what you have connected.

Behold, the code:

/*

*/
#include <SoftwareSerial.h>
SoftwareSerial ss(4,3);

void setup() {
    Serial.begin(9600);
    ss.begin(9600);
    pinMode(LED_BUILTIN,OUTPUT);
}

void loop() {
    if (ss.available() > 0){
      byte gpsData = ss.read();
      Serial.print(gpsData);
      /* This is a test to see if the Arduino is recieving data from the GPS: 
      if the Arduino is recieving data, the light will turn on*/
      digitalWrite(LED_BUILTIN, HIGH);
    }
    else {
    digitalWrite(LED_BUILTIN, LOW);
    }
}

This might not fix things, but:

1.) Check that the serial monitor and the sketch both operate at the same baud
2.) Check that the GPS is getting a "fix" - there might be a status LED that will tell you this
3.) Change "Serial.print(gpsData);" to "Serial.write(gpsData);"

What kind of GPS is this? Is it a NEO-6M?

Also, you will get the best of luck if you point the antenna up at the sky (preferably outdoors) and provide the GPS a clean power supply.

1.) Check that the serial monitor and the sketch both operate at the same baud

The connection between the Arduino and the GPS can be at a different (slower) baud rate than the connection between the Arduino and the serial monitor.

What kind of GPS is this? Is it a NEO-6M?

He said it is but that shouldn’t matter. It would if you were trying to change some of the GPS parameters which is not happening here.

Also, you will get the best of luck if you point the antenna up at the sky (preferably outdoors) and provide the GPS a clean power supply.

True. But this program should still give you some output even if the GPS isn’t locked.

Make sure you have the GPS Tx going to the software serial Rx and vice versa.

Don

I tried using the TinyGPS code and it compiles and uploads, but all that I see on the serial monitor is "NO CHARACTERS RECEIVED FROM GPS: CHECK WIRING..."
I am stuck, any suggestions?

any suggestions?

Yes, of course, glad you asked! Follow the directions in reply #1.

Try swapping
TX and RX on the micro and ensure you have the correct board selected when uploading

floresta:
The connection between the Arduino and the GPS can be at a different (slower) baud rate than the connection between the Arduino and the serial monitor.

Exactly. I don't care what each of the bauds are, but all devices on a specific UART connection (i.e. Serial or Serial1, or whatever software serial port) should have the same bauds! Especially on the Arduino to serial monitor - if the bauds don't match on the USB serial port, the GPS portion of the code might actually work, but no output display (or even garbage).

floresta:
He said it is but that shouldn't matter. It would if you were trying to change some of the GPS parameters which is not happening here.

I was asking to verify if there was a status LED.

I was asking to verify if there was a status LED.

No you weren't, you asked that in a different statement to which I didn't reply.

Look again at reply #6. I clearly specified the statement to which my reply referred.

Don

We see a great many of these 'my gps does not work' questions, here is my summary of the main causes of the problem;

  1. GPS is indoors
  2. GPS is connected incorrectly
  3. Arduino program uses the wrong GPS baud rate
  4. Arduino program is not correct
  5. GPS is faulty
  6. Arduino is faulty

There is a write up here;

GPSTutorial

srnet:
We see a great many of these 'my gps does not work' questions, here is my summary of the main causes of the problem;

  1. GPS is indoors
  2. GPS is connected incorrectly
  3. Arduino program uses the wrong GPS baud rate
  4. Arduino program is not correct
  5. GPS is faulty
  6. Arduino is faulty

There is a write up here;

GPSTutorial

Nice job.

Don

I use a Adafruit Ultimate GPS. Using either the Adafruit Library or the TinyGPS++ library, I follow a set procedure to get data from the GPS unit.

The procedure I use is to have one routine, either interrupt driven or a freeRTOS task, running at 1ms asking the gps for a gps data read. In the main loop or another task I ask if the data read was successful and to read/parse the data.
code snippets:
In example for the non-freeRTOS procedure:

#include <Adafruit_GPS.h>
#include <SoftwareSerial.h>
#include <MsTimer2.h>

//pin3 to GPS rx - yellow wire
//pin2 to GPS tx - orange wire
SoftwareSerial mySerial(3, 2);
Adafruit_GPS GPS(&mySerial);
void GPSSIGNAL()
{
  //cause a GPS data read so that the
  //if (GPS.newNMEAreceived())
  //can do its thing
  GPS.read();
}

void setup() {

  GPS.begin(9600);

  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA); // has speed n altitude
  // Note you must send both commands below to change both the output rate (how often the position
  // is written to the serial line), and the position fix rate.
  // 1 Hz update rate
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_1HZ);
  GPS.sendCommand(PMTK_API_SET_FIX_CTL_1HZ);
  //turn off antenna data being sent
  GPS.sendCommand("$PGCMD,33,0*6D/r/n");
  //speed threshold level
  //0/0.2/0.4/0.5/0.8/1.0/1.5/2.0 m/s
  //GPS.sendCommand("$PMTK397,0.2*3F/r/n");
//  //set time on ms for overflow, each overflow causes xFunc, void w no parameters, to be called
  MsTimer2::set(1, GPSSIGNAL);
  //enable interrupt
  MsTimer2::start();
  //disable interrupt
  //MsTimer2::stop()
}

void loop() {
 //leave this code alone!!!!!!!!!!!!!!!!!!!!!
  //query GPS: has a new complete chunk of data been received?
  if (GPS.newNMEAreceived())
  {
    //if received cause parse data
    if (!GPS.parse(GPS.lastNMEA()))
      //else exit routine
      return;
  }

// other code below to read the parsed data if the above is successful
}

My freeRTOS code using TinyGPSplus

#include <TinyGPS++.h>
#include <HardwareSerial.h>
#include "esp_system.h" //This inclusion configures the peripherals in the ESP system.
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/timers.h"
#include "freertos/event_groups.h"

#define GPS_Parse                 ( 1 << 4 ) //10000 
EventGroupHandle_t eg;
HardwareSerial GPSSerial(2);
// Connect to the GPS on the hardware port
// The TinyGPS++ object
TinyGPSPlus GPS;
/* create a hardware timer */
hw_timer_t * timer = NULL;
// timer ISR callback set at 1000X a second
void IRAM_ATTR onTimer()
{
  BaseType_t xHigherPriorityTaskWoken;
  //
  if ( (xSemaphoreTakeFromISR(sema_GPS_Gate, &xHigherPriorityTaskWoken)) == pdTRUE ) // grab semaphore, no wait
  {
    xEventGroupSetBitsFromISR(eg, GPS_Parse, &xHigherPriorityTaskWoken); // trigger every 1mS, if not already processing
  }
} // void IRAM_ATTR onTimer()

void setup()
{
eg = xEventGroupCreate();
  //
  GPSSerial.begin( GPS_DataBits ); // begin GPS hardwareware serial
  //
  vTaskDelay( pdMS_TO_TICKS( OneK ) ); // delay one second
 timer = timerBegin( TIMER_FOUR, TimerDivider, true );
  timerAttachInterrupt( timer, &onTimer, true );
  timerAlarmWrite(timer, OneK, true);
  timerAlarmEnable(timer);

 xTaskCreatePinnedToCore( fGPS_Parse, "fGPS_Parse", TaskStack10K2, NULL, Priority4, NULL, TaskCore0 ); // assigned to core 0
} //void setup() // runs on core 1
///////////////////////////
void loop() {} // runs on core 1


void fGPS_Parse( void * parameter )
{
  TickType_t xDoDistanceExpireTicks;
  struct stuTime *pxTime;
  struct stuPosit pxPosit;
  struct stuDistance pxDistance;
  struct stuSpeed pxSpeed;
  float Alti;
  float Hdg;
  int Sats;
  float LatNow;
  float LonNow;
  float LatPast;
  float LonPast;
  int DoDistanceTicks = 5000;
  ////
  xDoDistanceExpireTicks = xTaskGetTickCount() + pdMS_TO_TICKS( DoDistanceTicks ); // add DoDistanceTicks mS worth of ticks to current tick count
  for (;;)
  {
    xEventGroupWaitBits (eg, GPS_Parse, pdTRUE, pdTRUE, portMAX_DELAY) ;
    //query GPS: has a new complete chunk of data been received?
    if ( GPSSerial.available() > 1 )
    {
      if ( GPS.encode(GPSSerial.read()) )
      {
      //    }

//parse code follows, exceeds the 9K character limit.
  } // for (;;)
  vTaskDelete( NULL );
} // void fGPS_Parse( void *pdata )

In either case the routine to cause a gps data read is done at a much higher rate then the code to actually parse the data.

If your gps module has a built in RTC, I’d suggest getting a battery for the RTC for faster gps acquisition.

If our gps is not running an internal rtc, place the gps near a window and wait for up to an hour for the first acquisition.