In this hands-on tutorial we will hook up a GPS module to Arduino prototyping platform, and write complete Arduino code, step by step, with brief explanations. GPS modules are unlikely to work inside buildings, so we will show you few possibilities with powering your Arduino with batteries.
For this tutorial, we will be using PMB-648 GPS (SirfStarIII chipset) module:
Don’t worry if you have other GPS modules, almost all of them use the same communications standard, TTL or RS-232 asynchronous serial at 4800 bps. Do not worry about this right now, we will explain it into details later. Beautiful thing about this GPS module is that it has built-in antenna, do you do not have to worry about connecting one.
First of all, let’s take look at our PMB-648 specifications sheet:
On first page, bottom-right section of the page, we can see the pinout of this module. As we can see, this module supports two standards for communications, RS-232, and TTL. We will use TTL standard, because Arduino is compatible with it.
WARNING: you should not, at any circumstances, connect RS-232 pins to Arduino! RS-232 voltage range is much higher than Arduino voltages, you will destroy onboard microcontroller!
If you want to learn more about RS-232 or TTL, you can read about it here:
What we are trying to accomplish is to connect Arduino to GPS module, read from it, and then send read data from Arduino to our computer (GPS -> Arduino -> Computer).
In this purpose, Arduino will talk to GPS using SoftwareSerial communication, and Arduino will report to us using his Hardware Serial. Do not worry if you do not fully understand this concept at this time, we will be demonstrating it soon.
Now, let’s connect complete circuit!
First, connect 5v power supply from Arduino to GPS Vcc and GND pins.
Second, connect GPS TTL TX pin to Arduino digital pin 2.
And, that is all of wiring we need. Whole process is illustrated below:
PMB-648 GPS module has LED on his board. This LED will start blinking when you apply 5v to module. This LED can indicate if GPS is locked on satelites:
- Blinking: searching for satelites;
- Constantly on: locked on satelites.
There is no need to connect GPS TTL RX pin to Arduino, because we will only read from it. We do not have need to transmit data to GPS.
Notice: there are some configurations on GPS module that can be accessed through it’s TTL RX pin. For most of the time, default configurations are what we need.
Now, our task is to write some code to bring our masterpiece to life.
What we need to to is very, very simple. We want to set Software Serial communication on digital pins 2 and 3 (notice on schematics that we connected GPS TTL TX on pin 2), and we want arduino to print exactly the same data to us, on Arduino Serial monitor. Here is the complete code:
SoftwareSerial GpsMod = SoftwareSerial(2,3);
In setup function, we initiated software serial communication with GPS module at 4800bps, as it is required on specifications page. We also initiated hardware serial communication with our computer.
In loop function, we are simply bridging data from GPS module, to computer.
After you upload your sketch and open serial monitor, you will see that your GPS module is sending data every one second. Data you are looking at is called NMEA codes.
NMEA reference manual briefly explains this codes, and can be found here:
Also, a nice guide on how to decode NMEA codes is available here:
It is very straightforward and intuitive.
If you want to play with your GPS Module, you will probably want to go outside. Arduino has internal voltage stabilizer, so you can apply any voltage between 5V and 20V to DC Jack. Recommended voltages are in range between 7 and 12 volts. If you would like to read more about this, you can visit: