Python scripts and examples for the Ping sonar.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples global: use #!/usr/bin/env python Jan 29, 2019
.gitignore gitignore: Remove unnecessary parts Nov 13, 2018
LICENSE readme: link support to gitter discussion Feb 8, 2019 setup: version to 0.0.7 Feb 8, 2019


Travis Build Status Gitter

Python library for the Ping sonar. Ping is the simple, affordable, and compact ultrasonic altimeter for any aquatic project.

This library exposes all functionality of the device, such as getting profiles, controlling parameters, switching modes, or just simply reading in the distance measurement.

Available here




$ pip install --user bluerobotics-ping

From source

$ git clone
$ cd ping-python
$ python install --user

The library is ready to use: import brping. If you would like to use the command line examples or tools provided by this package, follow the notes in python's installing to user site directions (eg export PATH=$PATH:~/.local/bin).

Quick Start

The bluerobotics-ping package installs a script to get started. Place your device's file descriptor (eg. /dev/ttyUSB0, COM1) after the --device option.

$ --device <your-device>


The Ping1D class provides an easy interface to configure a Ping device and retrieve data.

A Ping1D object must be initialized with the serial device path and the baudrate.

from brping import Ping1D
myPing = Ping1D("/dev/ttyUSB0", 115200)

Call initialize() to establish communications with the device.

if myPing.initialize() is False:
    print("Failed to initialize Ping!")

Use get_<message_name> to request data from the device. The data is returned as a dictionary with keys matching the names of the message payload fields. The messages you may request are documented in the ping-protocol.

    data = myPing.get_distance()
    if data:
        print("Distance: %s\tConfidence: %s%%" % (data["distance"], data["confidence"]))
        print("Failed to get distance data")

Use the set_* messages (eg. set_speed_of_sound()) to change settings on the Ping device.

    # set the speed of sound to use for distance calculations to
    # 1450000 mm/s (1450 m/s)

See the doxygen documentation for complete API documentation.