Search

Talking boat - Part 5 - Where am I?

The boat needs to know where it is so it needs access to location information.  Our yacht has a chartplotter and autopilot which produce NMEA data so when installed, the Raspberry Pi can read NMEA data via a serial port.  However, for development and for other projects we need our own GPS data source.

I chose the GlobalSat BU-353   which uses the SiRF Star III e/LP GPS chipset and produces a limited number of NMEA sentences

Paul Mount''s blog was helpful in getting started but for my purposes, the gpsd suite, whilst a wonderful piece of work, is both overkill and trouble-making.   gpsd is very smart and finds the most efficient way of communication with the receiver and so it switches to the SIRF binary mode. For simple position reading in Python, it is simple enough to use Python's serial module and decode the required sentences, but It is tricky to switch back to the factory setting of NMEA if gpsd has been run first.

I also got distracted by the BU-353 installation manual  In fact, the receiver appears as a serial device for which the Raspberry PI already has a driver. So all that was necessary was to

  • plug the recieverinto a USB socket.  The spec says it draws 80mA
  • check on the list of usb devices sudo lsusb  . The device appears as a Prolific PL3203 Serial Port
  • check on the device it has been assigned to  tail  /var/log/syslog . Most likely it has been assigned to /dev/ttyUSB0
  • check the serial characteristics of the device:  stty < /dev/ttyUSB0
  • if the rate is not 4800, change it sudo stty ispeed 4800 </dev/ttyUSB0
  • check the output from the device  cat /dev/ttyUSB0 . You should see NMEA sentences prefixed with a sentence identifier $GPXXX and a comma-separated list of values, terminating in a binary checksum.

For this receiver, the sentences are:

  • GGA - Time, position nand fix type data
  • GSA - GPS operating mode, satellites and DOP
  • GSV - postion of all satellites in view
  • RMC - Time,date, positoon, course and speed

To use the position in the talking boat, I need to have a GPS object which contains the latest position (date/time, latitude, longitude and altitude) and velocity (course,speed) data.  Almost all data is in the RMC sentence except altitude (which although not generally useful in a yacht is needed in other other applications, for example for correcting observed barometric pressure) and the number of satellites and HDOP (Horizontal Dilution of Precision)  for accuracy so GGA sentences are needed as well.

You may have to install the python serial module if it hasn't been already installed sudo apt-get install python-serial

This basic script updates a Position object with a frequency of 1 Hz.  In this test environment, the postion is printed but in the yacht application, the Position object is pickled so it is available to any process which needs location data.

Watching the ouput here in my study, the latitude and longitude accuracy is quite good but altitude varies considerably despite seeing at least 8 satellites.