Print Shortlink

Testing the GPS Module

I’ve been playing around with the GPS module today (Ublox NEO-M6) and thought i’d post some information on it. I’ve started with the standard Rasbian Wheezy image and got everything booted up. Now the Ublox GPS connects via a UART serial interface, by default the OS uses this to allow the Raspberry Pi to talk to a PC. So first thing we need to do is disable this. With in the terminal type the following.

sudo vi /boot/cmdline.txt

This will open up the text file in Vim, now Vim can take a bit of getting used to so it might be worth while having a Google for it and read up on the commands. Within this text file we need to delete the “ttyAMA0” reference (simply use the del key) to leave us with the following;

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait

It’s possible yours may look a little different. Next we need to save this file, to do this in Vim hit the “Esc” , colon, and then type “wq”. This will write the file and then quit. Next is to edit¬†/etc/inittab, so lets firstly open the file up in Vim again by the following code;

sudo vi /etc/inittab

We need to comment out a line, we do this by entering a # at the beginning of the line. So find the following line and enter a # before it. To enter text in Vim, press the “insert” key, once you’ve finished entering text press the esc key.

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

Once again, kit the colon button and then type wq and hit enter, this will now save the file.

Now restart the OS so the changes can be applied. To do this from the terminal you can type the following;

sudo reboot

Next we’ll install GPSd, a GPS service deamon. To do this enter the following command into the terminal;

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

Now on to testing to see if we have any data. First we need to make sure there are no gpsd instances running by issuing the following command;

sudo killall gpsd

Now we need to set the baud rate to match the spec of our GPS module, in this case it comes setup at 9600. You’ll notice we reference /dev/ttyAMA0, this is the location of where we can talk tot he GPS module.

stty -F /dev/ttyAMA0 9600

Now we can start the gpsd daemon by issuing the following command.

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

Now we should be able to display the gps data by using the following;

cgps -s

 

You should now get a screen similar (click to enlarge) to this showing the incoming data (i have blanked out the lat/lon details). I’ll start work on writing a Python script in order to grab the data from gpsd. That way the main navigation script can ask to get a GPS position when needed.

cgps