Configure an NTRIP-based RTK GPS with a Serial Connection

A global positioning system (GPS) receives signals from satellites in the earth’s orbit to determine where it is and how fast it is going. All supported GPS models provide data for the Position, CompassHeading and LinearVelocity methods. You can obtain fix and correction data by using the sensor GetReadings method, which is available because GPSes wrap the sensor component.

The gps-nmea-rtk-serial and gps-nmea-rtk-pmtk movement sensor models support NTRIP-based real time kinematic positioning (RTK) GPS units (such as these).

The chip requires a correction source to get to the required positional accuracy. The gps-nmea-rtk-serial model uses an over-the-internet correction source and sends the data over a serial connection to the board.

Navigate to the Config tab of your robot’s page in the Viam app. Click on the Components subtab and click Create component. Select the movement-sensor type, then select the gps-nmea-rtk-serial model. Enter a name for your movement sensor and click Create.

Creation of a `gps-nmea-rtk-serial` movement sensor in the Viam app config builder.

Edit and fill in the attributes as applicable.

{
  "components": [
    {
      "name": "<your-sensor-name>",
      "type": "movement_sensor",
      "model": "gps-nmea-rtk-serial",
      "attributes": {
        "serial_path": "<path_to_serial_port>",
        "serial_baud_rate": <int>,
        "ntrip_connect_attempts": <int>,
        "ntrip_mountpoint": "<identifier>",
        "ntrip_password": "<password for NTRIP server>",
        "ntrip_url": "<URL of NTRIP server>",
        "ntrip_username": "<username for NTRIP server>"
      },
      "depends_on": [],
    }
  ]
}
{
  "components": [
    {
      "name": "my_GPS",
      "type": "movement_sensor",
      "model": "gps-nmea-rtk-serial",
      "attributes": {
        "board": "local",
        "serial_path": "/dev/serial/by-path/ttyS0",
        "serial_baud_rate": 115200,
        "ntrip_connect_attempts": 12,
        "ntrip_mountpoint": "MNTPT",
        "ntrip_password": "pass",
        "ntrip_url": "http://ntrip/url",
        "ntrip_username": "usr"
      },
      "depends_on": []
    }
  ]
}

The following attributes are available for a gps-nmea-rtk-pmtk movement sensor:

NameTypeInclusionDescription
serial_pathstringRequiredThe full filesystem path to the serial device, starting with /dev/. With your serial device connected, you can run sudo dmesg | grep tty to show relevant device connection log messages, and then match the returned device name, such as ttyS0, to its device file, such as /dev/ttyS0. If you omit this attribute, Viam will attempt to automatically detect the path.
serial_baud_rateintOptionalThe rate at which data is sent from the sensor.
Default: 38400
ntrip_urlstringRequiredThe URL of the NTRIP server from which you get correction data. Connects to a base station (maintained by a third party) for RTK corrections.
ntrip_usernamestringOptionalUsername for the NTRIP server.
ntrip_passwordstringOptionalPassword for the NTRIP server.
ntrip_connect_attemptsintOptionalHow many times to attempt connection before timing out.
Default: 10
ntrip_mountpointstringOptionalIf you know of an RTK mountpoint near you, write its identifier here. It will be appended to NTRIP address string (for example, “nysnet.gov/rtcm/NJMTPT1”) and that mountpoint’s data will be used for corrections.

Test the movement sensor

After you configure your movement sensor, navigate to the Control tab and select the dedicated movement sensor dropdown panel. This panel presents the data collected by the movement sensor. The sections in the panel include the position, orientation, angular velocity, linear velocity, and linear acceleration.

The movement sensor component in the control tab


Have questions, or want to meet other people working on robots? Join our Community Discord.