arielnh56 / SonarI2C

Arduino library supports many HC-SR04 sensors via I2C bus and hardware interrupt
MIT License
26 stars 3 forks source link

SonarI2C library for Arduino

Version: 1.1.1
Release date: 2017 March 13
redhunter.com hackaday.io tindie.com

Summary

This is a library for the Arduino IDE that allows the polling of multiple ultrasonic distance sensors using the I2C bus and a single hardware interrupt pin. It assumes a PCF8574(A) type port expander to trigger the sensors, and external logic circuitry to multiplex the echo signals.

It has been tested with the HC-SR04 sensor - the cheapest and most widely available at this time. Up to 12 units have been tested on a breadboard, using two of my Octosonar modules in a daisy-chain configuration.

Supported Platforms

This library is designed to work with the Arduino IDE versions 1.6.x or later; it is not tested it with earlier versions. It should work with any Arduino compatible board with an available hardware interrupt pin. Note that other interrupt activity may interfere with the accuracy and reliability of this code.

Getting Started

Hardware

The minimum setup to breadboard this requires

basic breadboard test

For pracitcal use you can replicate my prototype design at redhunter.com or purchase my Octosonar boards at tindie.com

Software

If you are using version 1.6.2 or later of the Arduino software (IDE), you can use the Library Manager to install this library:

  1. In the Arduino IDE, open the "Sketch" menu, select "Include Library", then "Manage Libraries...".
  2. Search for "SonarI2C".
  3. Click the SonarI2C entry in the list.
  4. Click "Install".

If this does not work, you can manually install the library:

  1. Download the latest release archive from GitHub and decompress it.
  2. Rename the folder "SonarI2C-master" to "SonarI2C".
  3. Move the "SonarI2C" folder into the "libraries" directory inside your Arduino sketchbook directory. You can view your sketchbook location by opening the "File" menu and selecting "Preferences" in the Arduino IDE. If there is not already a "libraries" folder in that location, you should make the folder yourself.
  4. After installing the library, restart the Arduino IDE.

(note - the above instructions adapted from a Pololu readme)

Examples

Two examples are included showing the use of two and ten sensors. Aother example will display 8 outputs on an LCD.

Library reference

Version history