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.

Relay Class

Module: relaylib
  • ID: relay
  • Name: Relay
  • Other Names: Grove Relay
  • Category: relay
  • Manufacturer: seeed
  • Connection: gpio
  • Kit: gsk eak hak

UPM module for the relay switch. The relay is a digital normally-open switch that uses low voltage or current to control a higher voltage and/or higher current. When closed, the indicator LED (if present) lights up and current is allowed to flow.
relay.jpg

Item Index

Methods

Relay

(
  • pin
)
Number

relay constructor

Parameters:

  • pin Number

    Pin to use

Returns:

Number:

on

() Mraa_result_t

Sets the relay switch to on (closed). This allows current to flow and lights up the indicator LED.

Returns:

Mraa_result_t:

0 if successful, non-zero otherwise

off

() Mraa_result_t

Sets the relay switch to off (open). This stops current from flowing and the indicator LED is not lit.

Returns:

Mraa_result_t:

0 if successful, non-zero otherwise

isOn

() Boolean

Defines whether the relay switch is closed.

Returns:

Boolean:

True if the switch is on (closed), false otherwise

isOff

() Boolean

Defines whether the relay switch is open.

Returns:

Boolean:

True if the switch is off (open), false otherwise

name

() String

Returns:

String: