Relay

Mechanical Relay

Description

Mechanical relays are present on OI-RelayHP module.

Characteristics

Relay specifications

Requirements

Value

Remark

Maximum voltage (AC)

400V (RMS)

Maximum voltage (DC)

30V

Maximum current

6A

Internal fuse protection

6.3A

on ‘COM’ input

Isolation

1500VDC

Static Relay

Description

Static relays are present on OI-RelayLP module. You can use them to switch alternative voltage.

Characteristics

Static Relay specifications

Requirements

Value

Remark

Maximum voltage (AC)

400V (RMS)

Maximum current

1A

Internal fuse protection

1A

Isolation

5000VDC

Code examples

The example code above demonstrates how to set the relay on an OI-RelayHP module.

Note

To use this example with an OI-RelayLP module, simply replace OIRelayHP with OIRelayLP in the class declaration.

#include "OpenIndus.h"
#include "Arduino.h"
#include "RelayHP.h"

OIRelayHP relay;

void setup(void)
{
    /* Nothing to do in setup */
}

void loop(void)
{
    /* Activate all */
    relay.digitalWrite(RELAY_1, HIGH);
    delay(200);
    relay.digitalWrite(RELAY_2, HIGH);
    delay(200);
    relay.digitalWrite(RELAY_3, HIGH);
    delay(200);
    relay.digitalWrite(RELAY_4, HIGH);
    delay(1000);

    /* Deactivate all */
    relay.digitalWrite(RELAY_1, LOW);
    delay(200);
    relay.digitalWrite(RELAY_2, LOW);
    delay(200);
    relay.digitalWrite(RELAY_3, LOW);
    delay(200);
    relay.digitalWrite(RELAY_4, LOW);
    delay(5000);

}

Software API

Both relay types can be controlled using the Relays class.

class Relays

Public Static Functions

static int digitalWrite(Relay_Num_t num, uint8_t level)

Set the output state of a relay.

Parameters:
  • num – Relay number (RELAY_1 to RELAY_MAX)

  • level – Output level (0 for LOW/OFF, 1 for HIGH/ON)

Returns:

0 on success, -1 on error

static int digitalRead(Relay_Num_t num)

Read the current state of a relay.

Parameters:

num – Relay number (RELAY_1 to RELAY_MAX)

Returns:

Current relay state (0 for LOW/OFF, 1 for HIGH/ON), -1 on error

static int toggleOutput(Relay_Num_t num)

Toggle the output state of a relay.

Parameters:

num – Relay number (RELAY_1 to RELAY_MAX)

Returns:

0 on success, -1 on error