Relay4Unit
4-Relay unit is an integrated 4-way relay module which can be controlled by I2C protocol. The maximum control voltage of each relay is AC-250V/DC-28V, the rated current is 10A and the instantaneous current can hold up to 16A. Each relay can be controlled independently, each on it’s own. Each relay has status (LED) indictor as well to show the state of the relay at any given time.
Support the following products:
Micropython Example:
import os, sys, io
import M5
from M5 import *
import time
from hardware import *
from unit import Relay4Unit
i2c = I2C(1, scl=33, sda=32)
relay = Relay4Unit(i2c)
for i in range(1, 5):
relay.set_relay_state(i, 1)
relay.set_led_state(i, 1)
time.sleep(1)
relay.set_relay_state(i, 0)
relay.set_led_state(i, 0)
time.sleep(1)
class Relay4Unit
Constructors
Methods
- Relay4Unit.set_mode(mode: int)
Set the mode of the relay.
- 参数:
mode (int) –
The mode of the relay
Options: -
Relay4Unit.ASYNC_MODE: async -Relay4Unit.SYNC_MODE: sync
UIFLOW2:
- Relay4Unit.get_mode() int
Get the mode of the relay.
- 返回:
The mode of the relay
Options: -
Relay4Unit.ASYNC_MODE: async -Relay4Unit.SYNC_MODE: sync
UIFLOW2:
- Relay4Unit.get_led_state(n: int) int
Get the state of the LED.
- 参数:
n (int) – The number of the LED.
UIFLOW2:
- Relay4Unit.get_relay_state(n: int) int
Get the state of the relay.
- 参数:
n (int) – The number of the relay.
- 返回:
The state of the relay.
UIFLOW2:
