GPS on Raspberry Pi

Background

This article related to GPS, that is how to use GPS on Raspberry Pi. with the GPS Raspberry Pi is able to know the location coordinates on the map. the usual project using GPS is the tracker, by putting the Tracker Tool on a moving object, then we can monitor the movement on map from a distance. one example of a moving object that is Drone, by placing a tracker on Drone then Drone movement can be known through the view in the map.

This article only focuses on how Raspberry Pi can get GPS coordinates via GPS Nelo 6M Neo. for its development how to send GPS coordinate data to the server and how its server program is not described in this article.

Required device

1. GPS Ublox Neo 6M

is a GPS device that consists of 4 Pin: Vcc, GND, TXD, RXD. which sends data in serial form raw data in the form of standard language GPS, NMEA.

2. Raspberry Pi Model 3 B with Raspbian OS Stretch


Neo 6M Ublox GPS Connection to Raspberry Pi

GPS Ublox Neo 6M    --->   Raspberry Pi 3

VCC                            --->            VCC
RXD                            --->            TXD
TXD                            --->            RXD
GND                            --->            GND

Reference GPIO pin, you may be required find at picture below :



Software needed to install on Raspberry Pi

Gpsd, gpsd-clients, python-gpsd

is a GPS Handling Daemon tool, which can parse NMEA string data sent by GPS Ublox Neo 6M so that it can be read based on its size. for example we want to get the quantity of latitude and longitude.

with the gpsd library allows us to easily access the GPS position coordinates obtained by Ubunto Neo 6M device, without having to manually parse RAW NMEA data sent by GPS Ublox Neo 6M via serial.

to install on Raspberry Pi. can type the following command in terminal with Raspberry Pi condition has internet access.

sudo apt-get update
sudo apt-get install gpsd gpsd-clients python-gps

on Raspbian Jessie or later  you  need to disable as systemd service that gpsd install. this is for turn off automate connect gpsd to socket local so we can run gpsd manually. you can turn off with command below.

sudo systemctl stop gpsd.socket
sudo systemctl disable gpsd.socket

after you disable service you need run gpsd every you boot first login to Raspberry Pi to run command cgps -s or gpsmon.

Configuration on Raspberry Pi

1. Serial Port Configuration

by default serial on GPIO Raspberry Pi is used as serial console. so we can use serial on GPIO we have to disable serial console. for it can be done as follows:

a. backing up cmdline.txt settings 

with commands like the following

sudo cp /boot/cmdline.txt /boot/cmdline_backup.txt

backing up the cmdline.txt file is required so that if we want to restore the settings to the beginning with the old delete cmdline.txt and rename cmdline_backup.txt to cmdline.txt

b. edit cmdline.txt

 by removing the word console = ttyS0, to open cmdline.txt file in-terminal can be done by using nano program with command as follows:
sudo nano /boot/cmdline.txt
after the opened cmdline.txt file is terminated, search console = ttyS0 and delete it. then exit and save by pressing CTRL + X then Y

after cmdline.txt is edited then it is necessary to reboot Raspberry Pi. to reboot can be used command
sudo reboot

c. connect serial port ttyS0 to socket gpsd 

before you continue to connect ttyS0 to socket gpsd, you can check wheter GPS send data to serial ttyS0 you can check via command below :

cat /dev/ttyS0
if there is a stream of NMEA data on the terminal, then it can be sure that RAW data from GPS Neo 6M can be used. if any so mean GPS work well.

so continue to connect socket gpsd to serial ttyS0 with command below :

sudo gpsd /dev/ttyS0 -F /var/run/gpsd.sock

2. gpsd default configuration

in order to use the cgps -s command to display NMEA data it is necessary to set up gpsd file in path / etc / default / gpsd adjust the device with ttyS0 as follows:
START_DAEMON="true"
GPSD_OPTIONS="-n"
DEVICES="/dev/ttyS0"
USBAUTO="false"
GPSD_SOCKET="/var/run/gpsd.sock"

after editing as above then saved.

How to access Ublox neo 6M

1. gpsmon

by typing commands like the following:

gpsmon

then it will appear data from GPS Ublox Neo 6M is readable in the form of easy to read.




2. with the command cgps -s

besides with gpsmon can also with command cgps -s note that this command setting is in file / etc / default / gpsd as before in configure display command cgps -s that like as follows:

cgps -s
output like picture below :



so tutorial using GPS Ublox Neo 6M on Raspberry Pi 3 model B with OS Raspbian Strecth.

thank you ..... having fun with your experiment ...
GPS on Raspberry Pi GPS on Raspberry Pi Reviewed by rayakyfa on May 26, 2018 Rating: 5

No comments:

Powered by Blogger.