USB — Реле 2.0 (ID:1115)
Модуль USB — Реле 2.0 подключается к компьютеру через USB порт с помощью стандартного шнура от принтера. Используя специальную программу для операционной системы Windows, можно управлять электроприборами с помощью компьютерной мыши.
Для начала необходимо скачать программу для управления USB-реле:
Софт: USB — Реле (ID:1114)
Установки дополнительных драйверов не потребуется.
1 . Подключаем USB — реле в любой свободный порт компьютера с помощью такого шнура:
Ссылка на шнур в нашем магазине http://dvrobot.ru/search/317.html.
2. Запускаем программу USB Relay Manager.
3. Нажимаем кнопку «Find device».
4. В текстовом окне выбираем нужное нам реле. В нашем случае это BB21W.
5. Нажимаем кнопку «Open device», при этом красный индикатор сменится на зеленый.
6. Реле готово к работе!
У нас двухканальный модуль, поэтому активными будут строки Relay 1 и Relay 2.
В графе Relay 1 нажимаем «open», что бы включить, «close» что бы выключить первую нагрузку.
В графе Relay 2 нажимаем «open», что бы включить, «close» что бы выключить вторую нагрузку.
Способ подключения нагрузки показан на фото:
Источник
USB — Реле 4.0 (ID:1116)
Модуль USB — Реле 4.0 подключается к компьютеру через USB порт с помощью стандартного шнура от принтера. Используя специальную программу для операционной системы Windows, можно управлять электроприборами с помощью компьютерной мыши.
Для начала необходимо скачать программу для управления USB-реле:
Софт: USB — Реле (ID:1114)
Установки дополнительных драйверов не потребуется.
1 . Подключаем USB — реле в любой свободный порт компьютера с помощью такого шнура:
2. Запускаем программу USB Relay Manager.
3. Нажимаем кнопку «Find device».
4. В текстовом окне выбираем нужное нам реле. В нашем случае это BB21W.
5. Нажимаем кнопку «Open device», при этом красный индикатор сменится на зеленый.
6. Реле готово к работе!
У нас двухканальный модуль, поэтому активными будут строки Relay 1 — Relay 4.
В графе Relay 1 нажимаем «open», что бы включить, «close» что бы выключить первую нагрузку.
В графе Relay 2 нажимаем «open», что бы включить, «close» что бы выключить вторую нагрузку.
В графе Relay 3 нажимаем «open», что бы включить, «close» что бы выключить третью нагрузку.
В графе Relay 4 нажимаем «open», что бы включить, «close» что бы выключить четвертую нагрузку.
Способ подключения нагрузки показан на фото:
Для одновременной работы сразу четырех реле мощности USB порта компьютера может не хватить, поэтому в модуле USB — РЕЛЕ 4.0 предусмотрен разъем для подключения внешнего источника питания 12 Вольт. Приобрести совместимый блок питания можно в нашем магазине.
Источник
2 channel usb relay драйвер
This project provides open-source API for low-cost USB HID relays (search on eBay for «5V USB Relay Programmable Computer Control For Smart Home»).
The big advantage of HID-based interface is that no kernel drivers and no simulated COM-ports are needed. It is easy to detect and address the connected devices. Ebay vendors currently offer only an API library for Windows, and only in binary form.
We are not associated with the manufacturer(s) of these devices or author(s) of the original software offered by ebay sellers.
The project home page is on the V-USB wiki — because the firmware of the device is based on V-USB. V-USB enables amazingly simple and low-cost USB hardware solutions.
This repository contains only the host side software.
Binary downloads, documentation, bugs, TO-DOs and more
All this is in the Github project : releases, wiki pages and Issues.
A simple command-line utility for Linux (x86 or x64), Apple OS X and Windows (XP and newer, 32 and 64-bit).
Shared library for Linux (x86 or x64), Apple OS X and Windows.
Python (CPython) — supported thru the shared library
The Windows version of the shared lib, USB_RELAY_DEVICE.DLL , is backward compatible with the binary from the device vendor. Windows GUI demo app is similar to the device vendor’s but written in C++/CLI.
Required to build:
- Windows version: builds with VC++ and WDK 7.1, or VC++ 2013 «community edition» with its matching SDK (Win8.1).
- Linux version builds with gcc and libusb v. 0.1. Tested on RH, Ubuntu, Mint.
- OS-X 10.9+ version builds with Xcode and plain IOKit libraries.
Currently we reuse some code from other V-USB projects, which is dual-licensed: GPL + commercial. Until we remove this code, we cannot set any other license.
We could not locate any copyright information in the software package offered by the eBay sellers. No source code was reused from that package, besides of the C API header (the .h file).
About
Software for USB-connected relays with HID interface. See the WIKI for more info.
Источник
2 channel usb relay драйвер
USB Relay Driver For Linux
Latest Stable Release 0.9 (Zip, tar.gz)
A cheap USB relay available from Ebay with 1,2,4 or 8 relay output. The double throw relay ratings are 10A 250VAC each.
The USB device is HID compatible and comes with Windows control software. This code can control the relay vi HIDAPI which is a cross platform library. This code was tested under linux both on x86 and Raspberry Pi ARM. The program is command line only as it is likely to be used by shell scripts.
The output of lsusb for the device is:
HIDAPI is a fairly recent addition to linux and is available as a package for Fedora 20 but not for Pidora (F18). The package was built for Pidora (Fedora 18) using the F20 hidapi source package.
Installing Debian Packages:
This code is a maintained package in Debian (and Raspian). Use normal apt-get commands:
Installing Fedora Packages:
The packages are available in Fedora36+
Other Linux platforms will need to build the source, see below
The relay modules does not set the USB serial number but has a unique serial when the HID device is queried, the current state of the relays is also sent with the serial. The HID serial is matched and the ON/OFF command is sent to the chosen relay.
Building The Code:
The usual make, make install dance assuming the hidapi and hidapi-devel packages have been installed. Note that there are two options for the hidapi library: hidapi-hidraw or hidapi-libusb. Different distributions have better results with one or the other. YMMV.
You can also build using Docker. Assuming you have Docker installed (only tested with version 18), execute the build script:
The usbrelay binary, libusbrelay.so and libusbrelay_py.so libraries will be built in the root directory of the repo.
The code needs to access the device. This can be achieved either by running the program with root privileges (so sudo is your friend) or by copying 50-usbrelay.rules to /etc/udev/rules.d
Add users that need to operate the relays to the usbrelay group:
Running the program without arguments will display each module that matches device 16c0:05df or 0519:2018. The program can be invoked with the debug (-d) or quiet (-q) flags. The debug information is sent to stderr while the state is sent to stdout for use in scripts. The only limit to the number of these relays that can be plugged in and operated at once is the number of USB ports. Using neither the -d or -q flags just prints the state of the relays to stdout.
To get the relay state
To use the state in a script:
To set the relay state of 1 or more modules at once:
Operate relay 9 to set the state of all relays together
The path to a device can be used in lieu of the serial, this can be useful for devices with corrupted serials
Alternatively if using libusb instead of hidraw you may use the usb device path
Change the serial permanently
Use the fictitious relay 0 to set the serial permanently. If you have duplicate serials, make sure only one is plugged in when you change it. Maximum of 5 character serial. It is probably sensible to change one module at a time to avoid serial collisions. You may also use the device path to set the serial as above
This also optionally includes a python extension. In order to build the python extension, you must have the Python 3 development libraries installed. The docker build process will produce the python library as well.
With the dependency installed, the library can be built and installed with:
Once installed, the library can be used by any python script, assuming it is running as a user with suitable permissions per the changes to udev above.
The following is a test script included as test.py, showing how to use the library:
Once the library is installed, you can run the test script in python as follows:
It will turn on and then off every relay attached to every board on your system.
Fine-grained UDEV permissions
When using many relays on a system, which is shared by several users and it is not desired to give all users access to all relays, one can add the following line to udev rules, e.g. /etc/udev/rules.d/50-dct-tech-usb-relay-2.rules .
This ensures that subsequent rules can use relay ID stored in the ID_SERIAL environment variable to match different relays. For example giving permissions for different relays to different users can be achieved by the following rules:
Support for Ucreatefun USB Modules
A USB relay became available that is supported by the software but with severe limitations
- Status of the relays is not available
- There is no serial so there can only be one of these modules attached to a system, unless referred to by device path. The module has a USB serial number of A0001 on every module.
- The number of relays is not available
The module has a USB device ID of 0519:2018. There are modules with 1,2,4,and 8 relays. The module accepts a request for relay 9 which turns on/off all relays. Operating the module works the same as for the DccTech modules except the serial used is A0001 Running usbrelay without arguments prints all possible relays (8) to stdout.
Referencing devices by physical USB port
Symbolic links can be used to devices to allow physical USB ports to be referenced. The following line in a /etc/udev/rules.d file will create a symbolic link with the name of the USB port:
The default 50-usbrelay.rules udev file creates these links for UCREATEFUN relays.
The following example has a ucreatefun usb relay plugged into a USB port and 2 dcttech relays plugged into a USB hub attached to another port:
MQTT support requires the successful installation of the python library described above. Check this first (with a module plugged in) by running:
MQTT support provides capability of using Home Assistant or nodered with usbrelay. The capability is made up of:
- usbrelayd
- usbrelay.service
- usbrelayd.conf
A python daemon using libusbrelay to connect to an MQTT server. When the daemon starts, it publishes the state of all usbrelay devices found and subscribes to command topics for each relay. To install:
Modify /etc/usbrelayd.conf to suit your circumstances.
A systemd unit for controlling and monitoring the usbrelayd daemon The systemd service file references your MQTT broker hostname as mymqttbroker. Either create that hostname in DNS or /etc/hosts. Alternatively, If you are using an external MQTT broker, modify the service file accordingly. To install:
A udev rule file that reacts and starts/stops the usbrelayd.service when a module is pluggedin or removed. The file should be installed with the initial installation.
After installation and configuration confirm the correct operation.
MQTT Topics for controlling usbrelays
- Current state: stat/SERIAL/Relay (eg stat/OMG12/1 )
- Command: cmnd/SERIAL/Relay ON/OFF (eg cmnd/OMG12/2 )
Источник
USB реле
Жила-была простенькая ферма для майнинга. И случалось так, что висла она намертво. И спасти её мог только сброс по питанию, но доставлять себя в другой город ради этого ой как не хотелось.
И было куплено USB реле.
Вообще, способов осуществить поставленную задачу много. Все зависит от фантазии. Всякие там сторожевые платы, выезжающие лотки сидюков и т.д.
Но вариант с реле мне показался наиболее просто реализуемым.
Обозреваемая модель построена на реле SRD-05VDC от фирмы SONGLE.
Управляется оно напряжением 5V и может коммутировать до 10А 30V DC и 10A 250V AC.
Надо отметить, что реле — это только синий квадратик, т.е. тут мы имеем целую плату в сборе, построенную на двух реле.
Я с электроникой на вы, поэтому объясню как смогу, извиняйте. Внутри реле находится три контакта.
Контакт 2 подпружинен, и при отсутствии тока он замнут с контактом 3. Когда подаем ток, сердечник внутри реле сдвигает контакт 2, замыкая его с контактом 1. Вот вроде и вся хитрость.
При подключении платы к компьютеру установка драйверов не потребовалась(win7-64):
Однако USB кабеля в комплекте нет, это стоит учесть.
Диск с софтом тоже не поставляется. Я искал программу в интернете.
Внешний вид программы:
Алгоритм действий простой:
— выбираем нужное устройство из списка;
— ждем «open device»;
— управляем реле кнопками «open» и «close»;
Чем больше реле на плате, тем больше будет активных кнопок.
Вместе с программой поставляются исходные коды:
Тестирование реле провел на мультиметре:
Вроде все работает. Всем доволен. Рекомендую к покупке. Спасибо за внимание.
Источник