Modified 10/30/06

This GPS-related schematic and source code
are intended for demonstration purposes only.
They are offered "as-is". Use at your own risk.
Nothing precludes good seamanship.

Code and circuits (and more) are here.


This circuit is a repeater for GPS data. It is intended to connect to Garmin-38 (and similar) hand held GPS receivers that don't have external antennas. The purpose for the repeater is to allow the GPS to be outside, exposed to the satellite view, and allow the user to see the data below decks at the navigation station.


Within the code there is opportunity to easily configure for a 16x4 display or a 20x4 display, as well as configure it for crystal speeds from 4 to 20MHz, and for nautical, metric, or statute speed display. Although the description below is for the 16x4 version, the 20x4 is quite similar.

Herb Young in Australia built a very nice boxed version of the repeater.

Click on photo to display full size version.

Click on photo to display full size version.


The repeater displays several pages of data pertaining to both the GPS and the boat electrical system. A DB-9 jack is on the front panel for the purposes of connection of a laptop to upload and download GPS waypoint data, etc. This code is a good example of how to process serial data using the PIC16F87x hardware UART and the serial interrupt.


  • Power: 10-16VDC at ~150mA including GPS
  • Analog: three inputs, 14.99VDC maximum displayed value
  • Data: NMEA-0183 2.0 format (4800 baud, TTL level, RMB & RMC data sentences)


Apply power to the repeater. The following screen is displayed.

GPS Repeater
v15 02/02/03
c Jon Fick

  • The three buttons cycle through the three pages, which are:
    1. Position (Latitude - Longitude - Speed - Heading)
    2. Waypoint (Waypoint name - Steering - Distance - Bearing)
    3. Battery voltages
  • Pressing and holding the Position button for between one and three seconds toggles the background illumination on and off.
  • Pressing and holding the Position button for four or more seconds resets the microprocessor (like power-on-reset.)
  • Pressing and holding the Position button during power-up will display the Setup Page, described below.

Position page

The position page displays position, speed (in knots), and magnetic heading.

LAT  44° 12.734 N
LON 71° 43.125 W
SPD 4.6 kt
HDG 177°

Waypoint page

This page displays items pertinent to waypoints and routes.

  • The first line displays the waypoint name currently in use.
  • The second line displays cross-track-error steering information. If on course, the words "On track" appear. Otherwise, an "L" or "R" and a distance is displayed after the word "STEER". This is an indication of whether to steer left or right to get back on the calculated track. If less than 1.0 nautical mile, the distance is expressed in feet ("ft") instead of nautical miles ("nm").
  • The third line displays the distance to the waypoint in nautical miles. If this distance is decreasing, the word "TO" preceeds the distance; if increasing, the word "FM" (from) preceeds the distance. If the GPS sends the arrival flag, the word "ARRIVED" appears to the right of the waypoint name on the top line. ("ARRIVED" doesn't disappear until you acknowledge the arrival and clear it at the GPS.)
  • The fourth line displays the magnetic compass bearing to the waypoint. If for some reason the magnetic variation has not been received from the GPS yet, the displayed bearing is True rather than Magnetic, and is followed by "T". The magnetic variation is queried and updated once every ten minutes.

STEER R 124ft
DIST TO 2.1nm

If a waypoint is not currently selected in the GPS, the following is displayed.

- none -        

Battery page

Three batteries can be monitored. This is intended for 12 volt batteries. Although the analog inputs can withstand higher voltages, the maximum displayed value is 14.99 volts.

BATT#1 12.1 V
BATT#2 13.4 V

Setup page

The Setup page allows the user to select a startup page (POSITION, WAYPOINT, or BATTERY.)

  1. Press and hold the button during power up.
  2. A screen is displayed that allows display contrast to be set.
  3. Release after "SETUP MODE" is displayed.
  4. Release the button when the words "initial page" is displayed.
  5. Press and hold the button when the desired page name is displayed. (For instance, select "WAYPOINT" if you want the Waypoint page to be displayed first every time power is applied.

       SETUP MODE   
    Press on correct
    initial page

If a page name is not selected by pressing the button, the previously selected page name continues to be used. The value is stored in EEPROM and may be changed at any time.

Operational notes

  • When the unit is first powered on, and any time the Position page is displayed, the current magnetic variation is saved and used to convert all heading and bearing information to magnetic degrees. The repeater checks the $GPRMC data sentence once every 10 minutes to update the magnetic variation.
  • A slowly flashing symbol in the lower right corner of the page indicates processor loop activity.
  • If the GPS is off or the data connection is broken, the following message is displayed...

    No data from GPS

  • If the GPS sends a "satellite warning flag", the following message is displayed. This would occur if satellites aren't being received (GPS indoors?) or if the satellites are broadcasting some sort of warning.

    GPS warning

  • If the baud rate received from the GPS is other than 4800, the following message is displayed. This would occur, for instance, if NMEA-0182 protocol (1200 baud) is selected or during Garmin protocol (9600 baud) uploads/downloads.

    Baud error

On beyond...

The panel-mounted version on my own sailboat has lengthy code that goes well beyond what I describe above. Features:
  • interfaces for my Garmin GPSMAP 172C (both Garmin and NMEA protocols)
  • USB interface to connect my laptop to either Garmin or NMEA bus
  • Seatalk® interface for my Raytheon instruments (speed, depth, autopilot) and my my tank level monitors
  • battery voltage interface
  • diesel tachometer interface
A PIC18F252 is used. If interested, code and schematic are here.

Click on photo to display full size version.

A rather nice piece of Windows software provides the ability to create several virtual COM ports from one incoming GPS, and provides a simulated NMEA-0183 data stream for demo or testing, and has a number of other intesting features. There are other GPS and Serial tools as well. Refer to GpsGate at Franson Technology AB

Technical Reference


  • The PIC is configured for power-on delay and brownout reset to guarantee proper resetting of the PIC.
  • Pots R1, R2, R3 are adjusted to display correct battery voltages. To calibrate, apply 13.98 volts and adjust the pot to display correctly. 14.99 volts and higher simply displays as "14.99".
  • Contrast is adjusted by software control of the PWM output.
  • The DB-9 jack may be omitted if laptop PC connection is not needed.
  • The diode on the 12V power supply input provides reverse current protection. More importantly, it isolates the repeater from 12V collapse (during engine starting, for instance.)
  • Any suitable 5V regulator may be used.
  • If it is not desired to power the GPS from the repeater, you may omit the 7808.
  • Any LCD display that has an industry-standard HD44780 compatible controller may be used. "Supertwist" displays have wider viewing angles than others. Two examples of LED backlight supertwist displays are:
    • LCM-S01604DSF from Lumex available as part number 67-1761-ND for $28 from DigiKey.
    • CFAH1604A-YYB-JP from Crystalfontz. It is approximately $25.


  • Basic sequence: The main loop code selects the NMEA-0183 data sentence, such as $GPRMC... that will be looked for in the data stream from the GPS. The serial stream is received by the hardware UART and serviced by the RDA serial interrupt. After the beginning of the sentence is identified, the remainder of the sentence is saved in RAM. When the end of the sentence is received, the main loop calls the parsing routine to extract certain data fields for display. The display is updated at the rate at which the GPS sends it's data streams out (every two seconds in the case of the GARMIN-38.) I identify the data sentence by the following in my code:
    1. I predefine the data sentence I'm looking for (GPRMC) and set it equal to 75.
      #define GPRMC_CODE      75
    2. I then call the InitRxBuffer subroutine by :
      InitRxBuffer( GPRMC_CODE );
    3. In that subroutine the variable cRxMsgTypeDesired is set to 75 (what "GPRMC" was defined as)
      cRxMsgTypeDesired = cCode;
    4. During this time the serial interrupt has been interrupting anytime a character is received from the GPS. The serial interrupt is near the top of my code (I usually put interrupt code first.) It's called:
        void SerialInterrupt ( void )
    5. In that interrupt I use a switch-case statement that first looks for a "$" (case 0), then reads in the next five characters (cases 1-5) and after each of those characters exclusive ORs the character into the previous ones, and then makes a decision whether it's the data sentence I want (GPRMC). When you exclusive OR the five characters in "GPRMC" together, you get 75. So, if after the fifth character I have 75, then I know it's a GPRMC sentence, and I keep going, saving the characters. Otherwise I go back to state 0, which is to again search for the "$".
  • The code doesn't capture and check the checksum characters at the end of the data sentences.
  • The calls to the DisplayScaledVoltage function in the code allows you to scale the ADC voltage reading (0-5V = 0-1023 counts) to any desired voltage.
  • The code may be recompiled for any clock frequency between 4 and 20MHz. The crystal frequency is defined at the top of the code. Note that two of the time constants are automatically changed in code to accommodate changes in frequency.
  • Below is the data sentence stream that is transmitted from my Garmin 38 every two seconds at 4800 baud. The RMC and RMB sentences are the only ones the repeater uses. This is similar to what you should see from your GPS if you look at the data stream with HyperTerm or Procomm or similar terminal emulators. At the very least, there should be RMC and RMB sentences for full utilization of the repeaters functions.
    $PGRMM,WGS 84*06
  • Could the repeater be designed to use other than the RMC and RMB sentences above? Yes...simply use my code as a base, modify accordingly for the sentence you want and map it to the page you desire.
  • If you find that you are seeing constant "GPS warning" messages on the screen, it could be that you have the GPS receiver sitting on your bench inside a structure and therefore not able to receive satellites. In that case your GPS deliberately puts out the warning ("V" character instead of the "A" character you see in those sentences above.) My Garmin 38 has a simulation mode that enables me to avoid these errors.
  • The top line of the welcome screen is blank and could contain your boat name or whatever.