0.1.4 • Published 1 year ago
@balena/usbrelay v0.1.4
USB Relay
Control simple USB HID Relays using Node JS like this one:
To install
npm i @balena/usbrelay
To use:
const USBRelay = require("@balena/usbrelay");
const relay = new USBRelay(); //gets the first connected relay
To use a specific relay, specify a HID path:
const relay = new USBRelay(path);
Get connected relays:
USBRelay.Relays; //returns an array with HID data including paths
Set relay state:
relay.setState(1, true); // turns Relay 1 of the device on
relay.setState(1, false); // turns Relay 1 of the device off
Relay numbers are NOT zero-based, so if you want to refer to Relay #1, use 1.
To turn all relays off:
relay.setState(0, false); // relay number 0 references all relays of the device
To turn a relay on, wait 1 second, and then turn off:
relay.setState(1, true);
setTimeout(function () {
relay.setState(1, false);
}, 1000);
0.1.3-hraftery-switch-from-balenaci-to-flowzone-756fa0812568c8908706e140cae32fbc2721dad3-1
1 year ago
0.1.3-hraftery-switch-from-balenaci-to-flowzone-c6f66e1ae1415ac7e153479610d9218809312aae-1
1 year ago
0.1.4
1 year ago
0.1.3
1 year ago
0.1.2
2 years ago
0.1.1
2 years ago