Tuesday, June 18, 2013

RTKLIB on the Raspberry Pi

I've got a workmate. He wants to build an autonomous, electric, rotary hoe. Anyway, he needs to locate  the hoe to within a few centimetres.

I'd been contemplating DGPS for a while as I've found GPS tracks are a bit wandery when logging tracks for OpenStreetMap. I thought it'd be a good capability to have, so I've stepped up to the task of tracking Robohoe.

Background Information

This is basically a link dump of what I've found so far:

RTKLIB : DGPS software
  This is the bees knees for cheap arse DGPS. It can take raw GPS input from 5 or 6 different types of GPS, as well as most variants of the RTCM GPS correction stream. It can combine two data streams, from a reference station and a rover, to produce a high-precision position for the rover, or it can take a single stream from a reference station and produce an RTCM output for other stations.

  It's also got a number of other super handy programs, that do things like convert RTKLIB output into a Google Earth KML file, serve serial input out to multiple processes via Unix sockets etc.

The RTKLIB manual is here.

LEA-4T : GPS hardware
  The U-Blox 'T' series of modules (the LEA-4T, LEA-5T, and NEO-6T) produce data suitable for input to RTKLIB. The link above is the cheapest source I've found for these. I've bought 5 so far, and they've all been OK. Interestingly, this guy sells them on EBay for about three times the price.

 The pinout for this module is (from here):
antenna - SMB male connector
2 4 6 8
1 3 5 7

1 antenna vcc
2 vcc
3 tx
5 rx
6 timepulse
8 gnd

Note that Antenna Vcc and Vcc are both 5V, and aren't connected on board, so 5V is needed on both pins. Tx and Rx are both serial at 3.3V levels.

EBay : GPS antenna
  Generic powered GPS antenna with SMB plug, ~$7.00. Works.

EBay : USB serial unit
  Generic FTDI USB serial dongle. Used for GPS configuration on a Windows machine. In final use, the module will send data to the Pi via the 3.3V serial port on the GPIO.

u-center : GPS configuration software
  This is a whizzy Windows application which can be used to configure the modules to output the correct messages for RTKLIB. It can also be used to have a peek at the contents of all the mysterious binary packets that come out of the module.

Geosciences Australia : DGPS correction data
   GA runs a network of reference stations around Australia, and you can get non real-time correction data from their FTP site. This will be handy for post-processing data from my static installation to derive a precise location. I can then use the static station for real-time DGPS.

RNXCMP : file conversion software
  The GA data is in an odd format called the Hatanaka format. This program converts it into a more usable form.

Up To Now

What I've done so far is:

  • By default, Raspbian on the Pi runs a debug console on the GPIO serial port. I've modified the install to not do this and leave the serial port free.
  • Made up an adaptor to power the module from the GPIO, and send and receive data to the GPIO serial port.
  • Installed and (mostly) compiled RTKLIB.
  • Configured the module using u-center on a Windows machine.
  • Installed the module on the Pi, and used str2str (part of the RTKLIB suite) to send the module's serial data over the network.
  • Used the Windows version of RTKLIB to receive the data stream, and convert the raw stream to a position.

Current Status

The current status is:
  • My static antenna is fixed to point under the Laserlite in the porch.
  • Raw data is being collected from the module using the static antenna (~48 hours so far)

The Future

Future plans include:
  • Work out conversion of the GA correction files.
  • Work out how to produce a precise position from the logged static antenna data, and the GA correction data.
  • Work out how to produce real time correction data from the static station and RTKLIB.


  1. I'm really interested in this - please keep up the good work of documenting your progress to date! Neil.

  2. I'm really interested in this too.

  3. Very encouraging progress for those interested in a similar kind of project, would be really interested to see any progress update.

  4. I'm trying to do the same thing, and I just ordered the hardware. What RPi distribution do you run?

  5. Hello, I'm trying to do some similar things as you, but i'm having some issue regarding the syntax of str2str, when trying to stream the serial data from the gps. The gps is connected to ttyACM0 and the format is UBX, this is what i try:

    ./str2str -in serial://ttyACM0[:9600[:8[:off[:1[:off]]]]][#ubx] -out tcpcli://[:5000][#ubx]

    however the output i get is:
    stream server start
    stream server start error

    and nothing more detailed then that. Any thoughts?

    1. Are you sure you want tcpclient? If you want to connect rtknavi to the gps via tcp I think you should run a server. Try this

      ./str2str -in serial://ttyACM0:9600 -out tcpsvr://:128

      Then you connect rtknavi as client at port 128.

  6. To clarify, I want to send the gps information from my small pandaboard with gps connected to a windows pc with the RTKnavi software

  7. Hey, this is really exciting, and seeing your progress would be awesome.

    There aren't any beginning-to-end documented RTKLIB successes, and this would be awesome to see before plunging in on my own.

  8. Hello,

    could you give us more detail how you connect the ublox to the raspberry ?

    1. Hi Vincent,
      I'll try to add some more detail in a post quite soon.

  9. hello,
    I'm using the Lea-4T Ublox in UCenter and will not let me put it to 57600 baud UBX. In UBX only works to 9600 baud. Why?


    1. You can configure you to 57600 with u-center does not usually save the settings the first time you do it, but by insisting you get it.
      If you can not manage to do, I help you. Greetings from Spain.

  10. Hi Angel,
    I couldn't tell you why 9600 is the highest baud rate. At a wild guess I'd suggest trying everything on another PC. That said, 9600 will be sufficient. There are only two kinds of UBX packets which need to be enabled in the software (I can't remember which at the moment as I'm away from my notes, sorry). I found that sending data once per second produces ~550bytes/second of data, which is doable at 9600 baud.

  11. Hello.
    We are working on a draft agricultural GPS guidance. We use a TALLYSMAN 2400 a Lea-4t and RTKLIB antenna to achieve an accuracy of centimeters. We have a forum where we put all the progress we are making, as well as all the steps, configure Read-4t ...


    Worth Just learn or contribute something to our invention. I leave the address of the Post. Currently we have very accurately but only where we have internet. We want to design a base radio station, but do not know how. Same with Raspberry, a 12v battery and little could be done. A greeting.

  12. Hi,
    Any more news for this topic? - I have some module in the mail system :)

    I think about the run/compile RTK lib for raspberry pi, that i am interestead in - also if someone have managet to let raspberry pi do all the math?


  13. RTKRCV in RTKLIB is the command line version of RTKNAVI which does all the maths. You can compile and run RTKRCV on Raspberry Pi. I've successfully tried it. See http://gnss.co/?p=52

  14. Where's everyone at with this? Does anyone have a finished / working solution?

  15. Interesting and useful information that you have provided here on your post.Thanks.

    gps antenna manufacturers & cell phone booster antenna