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.

HMTRP Class

Module: hmtrp

UPM support for the HM-TRP Serial RF Pro transceiver. This was tested specifically with the Grove Serial RF Pro transceiver. In theory, this class should work with the following devices:
HM-TRP-433: 414000000-454000000Hz HM-TRP-470: 450000000-490000000Hz HM-TRP-868: 849000000-889000000Hz HM-TRP-915: 895000000-935000000Hz
The only difference is the transmit and receive frequencies supported.
By default, the device simply sends and receives any data presented on its UART interface. It can be put into a configuration mode by grounding the CONFIG pin on the transceiver.
hmtrp.jpg

Methods

HMTRP

(
  • uart
)
Number

HMTRP Serial RF Pro transceiver constructor

Parameters:

  • uart Number

    Default UART to use (0 or 1)

Returns:

Number:

dataAvailable

(
  • millis
)
Boolean

Checks to see if there is data available for reading

Parameters:

  • millis Number

    Number of milliseconds to wait; 0 means no waiting (default).

Returns:

Boolean:

True if there is data available for reading

readData

(
  • buffer
  • len
  • millis
)
Number

Reads any available data in a user-supplied buffer

Parameters:

  • buffer String

    Buffer to hold the data read

  • len Number

    Length of the buffer

  • millis Number

    Maximum time in milliseconds to wait for input. -1 means waiting forever (default).

Returns:

Number:

Number of bytes read; 0 if timed out and millis is >= 0

writeData

(
  • buffer
  • len
)
Number

Writes the data in the buffer to the device

Parameters:

  • buffer String

    Buffer to hold the data read

  • len Number

    Length of the buffer

Returns:

Number:

Number of bytes written

setupTty

(
  • baud
)
Boolean

Sets up proper tty I/O modes and the baud rate. The default baud rate is 9,600 (B9600).

Parameters:

  • baud Speed_t

    Desired baud rate.

Returns:

Boolean:

True if successful

checkOK

() Boolean

Looks for and verifies an OK response. This looks like "OK\r\n"

Returns:

Boolean:

True if OK received

reset

() Boolean

Resets the device to default parameters, except for the UART baud rate

Returns:

Boolean:

True if successful

getConfig

(
  • freq
  • dataRate
  • rxBandwidth
  • modulation
  • txPower
  • uartBaud
)
Boolean

Queries the radio to determine its configuration

Parameters:

  • freq Uint32_t *

    Operating frequency

  • dataRate Uint32_t *

    TX/RX bit rate

  • rxBandwidth Uint16_t *

    Receiving bandwidth in Khz

  • modulation Uint8_t *

    Modulation frequency in Khz

  • txPower Uint8_t *

    Transmission power (1-7)

  • uartBaud Uint32_t *

    UART baud rate

Returns:

Boolean:

True if successful

setFrequency

(
  • freq
)
Boolean

Sets the frequency. Note: this is limited depending on which HM-TRP device you are using. Consult the datasheet.

Parameters:

  • freq Number

    Operating frequency

Returns:

Boolean:

True if successful

setRFDataRate

(
  • rate
)
Boolean

Sets the RF data transmission rate. Valid values are between 1,200 and 115,200.

Parameters:

  • rate Number

    Radio transmission rate in baud (1,200-115,200)

Returns:

Boolean:

True if successful

setRXBandwidth

(
  • rxBand
)
Boolean

Sets the RX bandwidth. Valid values are between 30 and 620 (in Khz)

Parameters:

  • rxBand Number

    RX bandwidth in Khz (30-620)

Returns:

Boolean:

True if successful

setFrequencyModulation

(
  • modulation
)
Boolean

Sets the frequency modulation. Valid values are between 10 and 160 (in Khz)

Parameters:

  • modulation Number

    Frequency modulation to use, in Khz (10-160)

Returns:

Boolean:

True if successful

setTransmitPower

(
  • power
)
Boolean

Sets the transmit power level. Valid values are between 0 and 7, 7 being the maximum power.

Parameters:

  • power Number

    Power level to use during transmission. Valid values are between 0 and 7.

Returns:

Boolean:

True if successful

setUARTSpeed

(
  • speed
)
Boolean

Sets the configured baud rate of the UART. It is strongly recommended you do not change this, or you may lose the ability to communicate with the transceiver. Valid values are 1,200-115,200.

Parameters:

  • speed Number

    Desired baud rate to configure the device to use Valid values are between 1,200 and 115,200.

Returns:

Boolean:

True if successful

getRFSignalStrength

(
  • strength
)
Boolean

Gets the RF signal strength

Parameters:

  • strength Uint8_t *

    Returned strength

Returns:

Boolean:

True if successful

getRFSignalStrength

() Number

Gets the RF signal strength

Returns:

Number:

Signal strength

getModSignalStrength

(
  • strength
)
Boolean

Gets the modulation signal strength.

Parameters:

  • strength Uint8_t *

    Returned strength

Returns:

Boolean:

True if successful

getModSignalStrength

() Number

Gets the modulation signal strength.

Returns:

Number:

Signal strength

Properties

RESET

Enum HMTRP_OPCODE_T

GET_CONFIG

Enum HMTRP_OPCODE_T

SET_FREQUENCY

Enum HMTRP_OPCODE_T

SET_RF_DATARATE

Enum HMTRP_OPCODE_T

SET_RX_BW

Enum HMTRP_OPCODE_T

SET_FREQ_MODULATION

Enum HMTRP_OPCODE_T

SET_TX_POWER

Enum HMTRP_OPCODE_T

SET_UART_SPEED

Enum HMTRP_OPCODE_T

GET_RF_SIGNAL_STR

Enum HMTRP_OPCODE_T

GET_MOD_SIGNAL_STR

Enum HMTRP_OPCODE_T