Installing & Testing USB Relay on Linux Ubuntu
Prerequisites
Before testing the USB relay, ensure you have the following installed:
- Ubuntu operating system
- Required packages:
- git
- python3
- libhidapi-dev
- libhidapi-hidraw0
- python3-pip
Installation Steps
- Install Required Packages
Open a terminal and run the following commands:
bash
Copy Code
sudo apt-get update
sudo apt-get install git python3 libhidapi-dev libhidapi-hidraw0 python3-pip
- Clone the USB Relay Repository
Download the USB relay code from GitHub:
bash
Copy Code
git clone https://github.com/darrylb123/usbrelay.git
cd usbrelay
- Build the Code
Compile the code using the following commands:
bash
Copy Code
make
sudo make install
Testing the USB Relay
- Connect the USB Relay
Plug the USB relay device into your computer. - Run the USB Relay Command
To check if the relay is recognized, execute:
bash
Copy Code
sudo usbrelay
This command will display the connected relay devices and their states.
- Control the Relay
You can control the relay using commands like:
bash
Copy Code
sudo usbrelay RELID_1=1 # Turn on relay 1
sudo usbrelay RELID_1=0 # Turn off relay 1
Additional Notes
- If you encounter permission issues, consider adding your user to the plugdev group:
bash
Copy Code
sudo usermod -a -G plugdev <your_username>
- For debugging, you can use the -d option:
bash
Copy Code
sudo usbrelay -d