Skip to main content
Skip table of contents

Ultrasonic Range Finder (SRF02)

This script measures the distance to a large, flat object up to 255 inches away (21 feet) using the I2C bus. The SRF02 Sensor uses ultrasonic pings to bounce off of large objects and detect the distance.

A register on the SRF02 must be written with the value 0x50 to initiate the ping. After  a short delay, the corresponding registers can be read to obtain distance in inches or centimeters. A variety of documentation can be found online regarding the SRF02.

The data obtained from the sensor is published to USER_RAM registers, which can be accessed by any other programs connected to the T-Series device. This allows a program to be doing one task while the device simultaneously obtains the range sensor data.

In the image above, a battery pack is used to supply power to the T7-Pro, and data is acquired over WiFi, allowing the assembly to be moved anywhere within a building while operating. 

This example can be found in our Kipling git repository:

https://github.com/labjack/labjack_kipling/tree/master/ljswitchboard-module_manager/lib/switchboard_modules/lua_script_debugger/premade_scripts/i2c/ranging-srf02.lua

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.