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.

URM37 Class

Module: urm37

This library was tested with the DFRobot URM37 Ultrasonic Ranger, V4. It has a range of between 5 and 500 centimeters (cm). It supports both analog distance measurement, and UART based temperature and distance measurements. This driver does not support PWM measurement mode.
For UART operation, the only supported baud rate is 9600. In addition, you must ensure that the UART TX/RX pins are configured for TTL operation (the factory default) rather than RS232 operation, or permanent damage to your URM37 and/or MCU will result. On power up, the LED indicator will blink one long pulse, followed by one short pulse to indicate TTL operation. See the DFRobot wiki for more information:
( https://www.dfrobot.com/wiki/index.php?title=URM37_V4.0_Ultrasonic_Sensor_%28SKU:SEN0001%29 )
urm37.jpg An example using analog mode An example using UART mode

Methods

URM37

(
  • aPin
  • resetPin
  • triggerPin
  • aref
)
Number

URM37 object constructor (Analog mode)

Parameters:

  • aPin Number

    Analog pin to use

  • resetPin Number

    GPIO pin to use for reset

  • triggerPin Number

    GPIO pin to use for triggering a distance measurement

  • aref Number

    The analog reference voltage, default 5.0

Returns:

Number:

URM37

(
  • uart
  • resetPin
)
Number

URM37 object constructor (UART mode)

Parameters:

  • uart Number

    Default UART to use (0 or 1).

  • resetPin Number

    GPIO pin to use for reset

Returns:

Number:

reset

()

Reset the device. This will take approximately 3 seconds to complete.

getDistance

(
  • degrees
)
Number

Get the distance measurement. A return value of 65535.0 in UART mode indicates an invalid measurement.

Parameters:

  • degrees Number

    in UART mode, this specifies the degrees to turn an attached PWM servo connected to the MOTO output on the URM37 . Default is 0. Valid values are 0-270. This option is ignored in analog mode.

Returns:

Number:

The measured distance in cm

getTemperature

() Number

Get the temperature measurement. This is only valid in UART mode.

Returns:

Number:

The measured temperature in degrees C

readEEPROM

(
  • addr
)
Number

In UART mode only, read a value from the EEPROM and return it.

Parameters:

  • addr Number

    The address in the EEPROM to read. Valid values are between 0x00-0x04.

Returns:

Number:

The EEPROM value at addr

writeEEPROM

(
  • addr
  • value
)

In UART mode only, write a value into an address on the EEPROM.

Parameters:

  • addr Number

    The address in the EEPROM to write. Valid values are between 0x00-0x04.

  • value Number

    The value to write