Uncategorized

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

  1. 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

  1. 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

  1. Build the Code
    Compile the code using the following commands:

bash

Copy Code

make

sudo make install

Testing the USB Relay

  1. Connect the USB Relay
    Plug the USB relay device into your computer.
  2. 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.

  1. 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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.