ESP-32 Flight Datalogger – Underground GPS

ESP-32 Flight Datalogger – Underground GPS

When the GPS module used for the ESP32-Cam project failed to get a reliable lock while bench testing, it became clear that a mockup was the best option. Development has its challenges, but not having reliable sensor data needn’t be one. Some digital and analog sensor data can be generated either by counters, timers, or a combination of the two. Other sensor data might follow a protocol like SPI, I2C, or UART data streams. For all of these sensor types, the Arduino can mimic them with little hardware costs or development time.

The ESP32-Cam project made use of an Arduino Pro Mini as the GPS mockup. The Pro Mini printed raw serial streams on one of its serial transmit pins. The raw serial stream was captured from the GPS module while it had a lock and was repurposed for the mockup. There were several lines of GPS sentences, but only the GPGGA sentences were needed for the project. This saved memory space on the Pro Mini and allowed for a larger sampling of GPS data to be used for the mockup.

/** 

ProMini_GPS-Mockup_Ver8.ino
GGA - Global Positioning System Fixed Data Strings Only
Sketch uses 10164 bytes (33%) of program storage space. Maximum is 30720 bytes.
ProMini Memory Limits - Maximum is 30720 bytes.
Fill in the blanks, not valid GPS fix is included in this example

**/

int inPin = 2;          // Use a toggle switch, not a pushbutton
int outPin = 13;        // Pin 13 is the onboard LED (ON = GPS Lock)
int state = 0;          // The current reading from the input PIN
int myBlock = 18;       // GPS Sentence Block

void setup()
{
  pinMode(inPin, INPUT); // Button input on digital PIN 2
  pinMode(outPin, OUTPUT); // LED output on onboard LED, digital pin 13
  Serial.begin(9600);
}

void loop()
{
  unsigned long myDelay = millis();
  while (millis() - myDelay <= 1000) { 
     state = digitalRead(inPin); // Read state of PIN 2 } 
     if (state == HIGH) GPSLock(); 
        if (state == LOW) GPSNoLock(); 
        myBlock = myBlock + 1; 
           if (myBlock >= 100)
           myBlock = 1;
    
}

void GPSLock()
{
  switch (myBlock)
  {

    case 1:
Serial.println(F("$GPGGA,..."));
      break; 

    case 2:
Serial.println(F("$GPGGA,..."));
      break; 
...
    case 99:
Serial.println(F("$GPGGA,..."));
      break; 
      
          
  }
  return;
}

void GPSNoLock()
{
    digitalWrite(outPin, state);
    Serial.println(F("$GPGGA,,,,,,0,00,99.99,,,,,,*48"));
    return;
}

Some other behavior of the GPS sensor could also be replicated with the Pro Mini, mainly when it had a lock or no lock state. This provided the bench environment with a life like condition from which to develop the firmware. However, not every condition could be replicated. This was going to come to light when the final code validation was field tested.

The next section will cover an anomaly that remained hidden until well into field testing and with a looming deadline.

Comments are closed.