How to install USB-Relay-1 unit on Fedora 24

Relay specifications:

Keyes 1-Channel USB Control Switch Relay Module for PC - Red (5V)

1. 5V SingLe relay, the relay can max. control 250V, 10A AC load and 30V, 10A DC load; 2. Control terminal connection mode: NC / COM / NO; 3. Onboard square USB interface, stable connection; 4. Adopts high performance USB control chip; High quality PCB; Fixed hole size: 3mm, fixed hole central moment: 52.2 x 20.6mm

Compiler requirements:

hidapi, hidapi-devel and gcc needs to be installed before compiling will been possible.

Compiling, installing and testing:

Software and driver source

Driver source: https://github.com/darrylb123/usbrelay

Installing process:

mkdir ~/usbrelay
cd ~/usbrelay
sudo dnf install unzip wget
wget https://github.com/darrylb123/usbrelay/archive/master.zip
unzip master.zip
cd usbrelay-master
sudo dnf install hidapi hidapi-devel gcc
gcc -o usbrelay usbrelay.c -lhidapi-libusb

Testing:

sudo ./usbrelay

Switching relay on and off by the following commands:

sudo ./usbrelay IBLB4_1=1 2>/dev/null
sudo ./usbrelay IBLB4_1=0 2>/dev/null

Comment:

This application might work on other relay models also, and is not just meant for this relay unit only. It also can supports units with multiple relays on it.