Chirp SonicLib is a set of API functions and sensor driver routines designed to easily control Chirp ultrasonic sensors from an embedded C language application. It allows an application developer to obtain ultrasonic range data from one or more devices, without needing to develop special low-level code to interact with the sensors directly.
Chirp sensors measure distance (range) by emitting an ultrasonic pulse and measuring the time-of-flight (ToF) for that pulse to travel through the air, either reflected back to the transmitting sensor or received by a second sensor.
The SonicLib API functions provide a consistent interface for an application to use Chirp sensors in various situations. This is especially important, because all Chirp sensors are completely software-defined. Except for certain low-level programming interfaces, the I2C “registers” are simply memory locations determined by the specific sensor firmware being used. They are subject to change between firmware revisions, and often vary significantly between firmware images with different feature sets.
The SonicLib API allows your application to use different Chirp sensor firmware images without requiring code changes. Only a single initialization parameter must be modified, and one #include line added to a header file, to use a new sensor firmware version.
This guide explains how to use SonicLib to create your embedded sensing application. Key API functions and sequences are highlighted, with an emphasis on typical use cases. Some options and parameters, and many additional API functions, are not discussed in detail.