Skip to main content

Relay

A switching relay.

The contacts should be labelled NO (normally open), COM (common), and NC (normally closed). When relay is energized it connects NO and COM. When relay is not energized it connects NC and COM. Some relays may be missing NO or NC contacts. When relay module is not powered, or is in bootloader mode, it is not energized (connects NC and COM).

import { Relay } from "@devicescript/core"

const relay = new Relay()

Registers

enabled

Indicates whether the relay circuit is currently energized or not.

  • type: Register<boolean> (packing format u8)

  • read and write

import { Relay } from "@devicescript/core"

const relay = new Relay()
// ...
const value = await relay.enabled.read()
await relay.enabled.write(value)
  • track incoming values
import { Relay } from "@devicescript/core"

const relay = new Relay()
// ...
relay.enabled.subscribe(async (value) => {
...
})
note

write and read will block until a server is bound to the client.

variant

Describes the type of relay used.

  • type: Register<number> (packing format u8)

  • optional: this register may not be implemented

  • constant: the register value will not change (until the next reset)

  • read only

import { Relay } from "@devicescript/core"

const relay = new Relay()
// ...
const value = await relay.variant.read()
note

write and read will block until a server is bound to the client.

maxSwitchingCurrent

Maximum switching current for a resistive load.

  • type: Register<number> (packing format u32)

  • optional: this register may not be implemented

  • constant: the register value will not change (until the next reset)

  • read only

import { Relay } from "@devicescript/core"

const relay = new Relay()
// ...
const value = await relay.maxSwitchingCurrent.read()
note

write and read will block until a server is bound to the client.