You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+46-15Lines changed: 46 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,10 @@
1
1
# crelay
2
2
#### Controlling different relay cards for home automation with a Linux software
3
3
4
-
### About
5
-
This software is intended to run on Linux systems to control different relay cards in a unified way. It provides several interfaces for controlling the relays locally or remotely. The relays can be controlled by a human being via a device like smartphone or web browser, or directly by an intelligent device as used in the Internet of Things.
4
+
### About
5
+
Ever bougth a cute little USB relay card and wanted to use it on a Linux based device or computer? Chances are that your were out of luck because the Linux software support for the card provided by the manufacturer was non existent. Conrad, Sainsmart, Denkovi and friends are still ignoring the existence of this operating system. That's why I started this project.
6
+
7
+
This software is intended to run on Linux systems to control USB relay cards from different manufacturers in a unified way. It provides several interfaces for controlling the relays locally or remotely via the network. The relays can be controlled by a human being via a device like smartphone or web browser, or directly by an intelligent device as used in the Internet of Things.
6
8
The software was designed with the following requirements in mind:
7
9
8
10
- simple, intuitive usage and interface
@@ -14,13 +16,14 @@ The software was designed with the following requirements in mind:
14
16
New relay cards support can be added by providing the cards driver code for detecting the card, reading and setting the relays.
15
17
Currently the following relay cards are supported:
16
18
17
-
- Conrad USB 4-channel relay card(http://www.conrad.de/ce/de/product/393905), see <i>Note 1</i> below
18
-
- Sainsmart USB 4-channel relay card(http://www.sainsmart.com/sainsmart-4-channel-5v-usb-relay-board-module-controller-for-automation-robotics.html), see <i>Note 2</i> below
19
-
- HID API compatible relay cards (1/2/4/8 channel)
19
+
-[Conrad USB 4-channel relay card](http://www.conrad.de/ce/de/product/393905), see <i>Note 1</i> below
20
+
-[Sainsmart USB 4/8-channel relay card](http://www.sainsmart.com/sainsmart-4-channel-5v-usb-relay-board-module-controller-for-automation-robotics.html), see <i>Note 2</i> below
21
+
-[HID API compatible relay cards (1/2/4/8 channel)](http://www.ebay.com/itm/For-Smart-Home-5V-USB-Relay-2-Channel-Programmable-Computer-Control-/190950124351)
20
22
- Generic GPIO controlled relays, see <i>Note 3</i> below
21
23
<br>
22
24
23
25
The following picture shows a high level view on the modular software architecture.
@@ -45,9 +49,10 @@ The following picture shows a high level view on the modular software architectu
45
49
### Screenshots
46
50
47
51
#### Web GUI
48
-

49
-
<br><br>
50
-

52
+

53
+
<br>
54
+
----------
55
+

51
56
<br><br>
52
57
53
58
#### Command line interface
@@ -58,8 +63,8 @@ The following picture shows a high level view on the modular software architectu
58
63
Currently supported relay cards:
59
64
- Conrad USB 4-channel relay card
60
65
- Sainsmart USB 4-channel relay card
61
-
- Generic GPIO relays
62
66
- HID API compatible relay card
67
+
- Generic GPIO relays
63
68
The card which is detected first will be used.
64
69
65
70
The program can be run in interactive (command line) mode or in daemon mode with
@@ -90,7 +95,8 @@ The following picture shows a high level view on the modular software architectu
90
95
<br>
91
96
92
97
### HTTP API
93
-
An HTTP API is provided to access the server from external clients. This API is compatible with the PiRelay Android app. Therefore this app can be used on your Android phone to control <i>crelay</i> remotely.
98
+
An HTTP API is provided to access the server from external clients. This API is compatible with the PiRelay Android app. Therefore this app can be used on your Android phone to control <i>crelay</i> remotely.
99
+
I am considering to add a more universally usable Json format based API in the future.
94
100
95
101
- API url:
96
102
<pre><i>ip_address[:port]</i>/gpio</pre>
@@ -151,17 +157,31 @@ On some not so recent Linux distributions (like Debian Weezy) the HIDAPI library
151
157
make [DRV_CONRAD=n] [DRV_SAINSMART=n] [DRV_HIDAPI=n]
152
158
sudo make install
153
159
</pre>
154
-
<i>Note:</i> Optionally, you can exclude specific relay card drivers (and their dependencies) from the build, if you don't need them. To do this, specify the driver name as parameter of the "make" command as shown above.
160
+
<i>Note:</i> Optionally, you can exclude specific relay card drivers (and their dependencies) from the build, if you don't need them. To do this, specify the driver name as parameter of the "make" command as shown above.
161
+
155
162
<br>
156
163
157
164
### Installation of prebuilt binaries
158
-
To save you the hassle of building crelay from source, prebuild binaries are provided for selected architectures. Just save the binary from the bin/<arch> directory on your host system and execute it.
165
+
To save you the hassle of building crelay from source, prebuild binaries are provided for selected architectures. Just save the binary for your architecture on your host system and execute it.
166
+
167
+
The binaries can be downloaded from the [Latest release page](https://github.com/ondrej1024/crelay/releases/latest).
159
168
160
169
<i>Note:</i> The binaries use shared librabries, so you might need to install the needed libs to your system, if not already done previously:
Currently, there are official OpenWRT packages available for different architectures from the developement snapshot repositories. They can be downloaded here:
If anyone wants to build packages for other Linux distributions, please feel free to do so and share it here.
182
+
183
+
<br>
184
+
165
185
### Configuration
166
186
The parameters for *crelay* can be customized via the configuration file crelay.conf which should be placed in the `/etc/` system folder. An example file is provided together with the programs source code in the `conf/` folder.
167
187
@@ -216,16 +236,27 @@ The modular architecture of *crelay* makes it possible to easily add new relay c
216
236
See example files `relay_drv_sample.c` and `relay_drv_sample.h` in the src directory for details on how to write your own low level driver functions.
217
237
<br>
218
238
239
+
### Credits
240
+
The support for the different relay cards in *crelay* has only been possible thanks to the valuable contributions of the following people who reverse engineered the communication protocols of the cards and provided the protocol specifications.
241
+
242
+
*[Dominic Sacré](https://github.com/dsacre) who discovered the communication protocol of the Conrad card
243
+
*[Darryl Bond](https://github.com/darrylb123), who discovered the communication protocol of the HID API cards
244
+
* User stav from the RPi forum, who discovered the communication protocol of the Sainsmart card
245
+
246
+
<br>
247
+
248
+
### Notes
249
+
219
250
##### <i>Note 1 (Conrad USB 4-channel relay card)</i>:
220
251
The relay card software provided by Conrad is Windows only and uses a binary runtime DLL which implements the communication protocol between the host computer and the card. Thanks to a raspberrypi.org forum member, the communication protocol was discovered and made public. This made it possible to develop an open source driver for the Conrad card which can run on any Linux distribution.
221
252
222
253
Earlier versions of this program needed the cp210x kernel driver for the Silabs CP2104 chip with GPIO support. The official in-kernel cp210x driver does not support GPIO operations. Therefore the Silabs driver from their home page needed to be used:
The current version of *crelay* uses libusb to talk directly to the CP2104 on the Conrad card, therefore the cp210x kernel driver is **not needed** anymore.
256
+
The current version of *crelay* uses libusb to talk directly to the CP2104 on the Conrad card, therefore the cp210x kernel driver is **not needed** anymore.
226
257
<br>
227
258
228
-
##### <i>Note 2 (Sainsmart USB 4-channel relay card)</i>:
259
+
##### <i>Note 2 (Sainsmart USB 4/8-channel relay card)</i>:
229
260
The Sainsmart card uses the FTDI FT245RL chip. This chip is controlled directly through the open source libFTDI library. No Kernel driver is needed. However on most Linux distributions, the *ftdi_sio* serial driver is automatically loaded when the FT245RL chip is detected. In order to grant the <i>crelay</i> software access to the card, the default driver needs to be unloaded:
230
261
231
262
rmmod ftdi_sio
@@ -237,4 +268,4 @@ To prevent automatic loading of the driver, add the following line to /etc/modpr
237
268
<br>
238
269
239
270
##### <i>Note 3 (GPIO controlled relays)</i>:
240
-
Since GPIO pin configuration is strictly device specific, the generic GPIO mode is disabled by default and can only be used in daemon mode. In order to enable it, the specific GPIO pins used as relay control lines have to be specified in the configuration file, `[GPIO drv]` section.
271
+
Since GPIO pin configuration is strictly device specific, the generic GPIO mode is disabled by default and can only be used in daemon mode. In order to enable it, the specific GPIO pins used as relay control lines have to be specified in the configuration file, `[GPIO drv]` section.
0 commit comments