UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

UltraSonic Class

Module: ultrasonic

This Grove Ultrasonic sensor is a non-contact distance measurement module which is compatible with the Grove system. It is designed for easy modular project usage with industrial performance. Detection ranges from 3 cm (1.2") to 4 m (13'1.5") and works best when the object is within a 30 degree angle relative to the sensor.
ultrasonic.jpg

Item Index

Methods

UltraSonic

(
  • pin
)
Number

Instantiates a UltraSonic object

Parameters:

  • pin Number

    pin for triggering the sensor for distance and for receiving pulse response

Returns:

Number:

getDistance

() Number

Returns the echo's pulse width from the sensor in microseconds. Divide by 58 to convert distance to centimetres. Divide by 148 to convert distance to inches.

Returns:

Number:

name

() String

Return name of the component

Returns:

String:

working

() Boolean

Returns true while the sensor is busy waiting for the echo pulse

Returns:

Boolean: