Particle Electron with GP-20U7 GPS Receiver

I’ve done a one or two projects with the electron in the past, but I can say I’m fairly new to the board. Now I have a GP-20U7 GPS Receiver sensor from sparkfun which I’m trying to get working. We chose this sensor due to some budget constraints, I know the asset-Tracker is superior.

I’ve tried a few tutorials here and there, including this one : here

Does anyone know optimal code or wiring to get the GP-20U7 GPS Receiver to work with the electron? or direct me to some tutorials i might have missed.

Can you clarify what’s missing from the article that you want us to fill in?
The wiring seems documented quite clearly there and the software seems to work :confused:
For completeness I’d just add the GPS-RX → Electron-TX connection too (provided it’s exposed by the module), in order to talk to the module from the Electron when needed.

I’d give the TinyGPS++ library a try.
Just remove all references of SoftwareSerial from the examples and use Serial1 instead.

Alternatively you could try AssetTrackerRK which uses TinyGPS++ but is focused at the Particle ecosystem.

I’ve tried the code, it doesn’t work. The wiring does seem normal, also the module only has a TX

In what way does that code not work?

Basically the serial output is always zero. I’ve checked my connections, all seems fine. Tried the GPS on an arduino and it worked just fine also.

I amended the code, adding serial Prints to maybe see where the problem is, here it is;

String inWord;
char inByte;
String data;
int LockLED = D1;  


void setup() {
    // cloud variable
    Particle.variable("STU", data);
    // GPS Serial
    Serial.begin(9600);
    pinMode(LockLED, OUTPUT);
    digitalWrite(LockLED, HIGH);
    delay(2000);
    digitalWrite(LockLED, LOW);
}



void loop() {
    Serial.print("data: ");
    Serial.println(Serial.available());
    
    while (Serial.available() > 0) {
        inByte = Serial.read();
        
        if (inByte == '\n') {
            // END OF LINE
            Serial.print("inByte: ");
            Serial.print(inByte);
            
            // check is data we want
            // you can change this to get any data line values
            if (inWord.startsWith("$GPRMC")) {
                // put data string in variable
                data = inWord;
                Serial.print("data: ");
                Serial.print(data);
                
                // clear the inword variable
                inWord = "";
                
                // does the GPS Receiver have lock?
                // get the char at pos 17 and test to see if it is an A i.e VALID V = INVALID
                char lock = data.charAt(17);
                Serial.print("lock: ");
                Serial.print(lock);
                if (lock == 'A') {
                    // YES Switch on Lock LED
                    digitalWrite(LockLED, HIGH);
                } else {
                    // NO turn off lock led
                    digitalWrite(LockLED, LOW);  
                }
                
                
            } else {
                // clear the inword variable as not the data we want
                inWord = "";
            }
            
        } else {
            // build data string
            inWord += inByte;   
        }
        
    } // end if serial
} // end loop

my output on the serial monitor is always “data: 0”
See the picture below :

I’m wondering if you should change your concatenation from inWord += inByte" to inWord = String(inWord + String(inByte))

As per: Device OS API - Boron | Reference Documentation | Particle

It looks like you’re reading from Serial which is the USB serial port. Since you are using TX and RX, you want to use Serial1 for the GPS. This includes Serial1.begin(9600) as well as Serial1.available() and Serial1.read().

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.