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
Stable build Status ,
4
+
Develop build Status 
5
+
1
6
*[About](#about)
2
7
*[Get Started](#get-started)
3
8
*[Configuration](#configuration)
4
9
*[Debugging](#debugging)
5
10
*[Expander](#expander)
6
11
*[Troubleshoting](#troubleshoting)
7
12
8
-
9
-
# About
10
-
Arduino program to handle relays and control them using switches with support for double-click and long-press. Integration with home automation systems is possible through MySensors integration.
11
-
Configuration is very simple - one line for a single relay and one line for single switch
12
-
Every switch support debouncing, multiple types of switches and additional actions like double-click and long-press - everything in a single line of configuration. Relays can be configured as LOW/HIGH level trigger, startup state ON or OFF and impulse type.
13
+
## About
14
+
Arduino program to handle relays and control them using switches with support for double-click and long-press. Integration with home automation systems is possible through MySensors integration over serial, LAN or MQTT.
15
+
Configuration is very simple - one line for a single relay and one line for single switch.
16
+
Every switch support debouncing, multiple types and additional actions like double-click and long-press - everything in a single line of configuration. Relays can be configured as LOW/HIGH level trigger, startup state ON or OFF and impulse type.
13
17
One relay can have one or more switches, or not at all if you want to control it only by home automation system.
14
18
15
-
# Get Started
19
+
### Supported platforms and hardware
20
+
* Arduino Mega2560 and other AVR ATmega family
21
+
* ESP8266
22
+
* ESP32 - Experimental! Tests with LAN worked fine, but had no luck with MQTT
23
+
* Ethernet (LAN or MQTT)
24
+
* W5100
25
+
* ENC28J60
26
+
* expanders (described later in this doc)
27
+
* MCP23017
28
+
* PCF8574
29
+
30
+
31
+
## Get Started
16
32
17
-
## Create config file
33
+
### Download
34
+
Most convinient is to clone the repo, but you have to have installed `git`:
Copy file "config.h.sample" into "config.h". There is sample configuration you need to examine and customize for your own needs.
19
42
20
-
## Build
43
+
###Build
21
44
You need PlatformIO - it is free and you can get it here https://platformio.org/platformio-ide. Arduino IDE is not supported.
22
-
By default sketch is built for Arduino Mega 2560. Build options can be customized in `platformio.ini` - more information in separate sections.
45
+
By default sketch is built for Arduino Mega 2560, but you choose environment that suits your needs.
46
+
Build options can be customized in `platformio.ini` - more information in separate sections.
23
47
Remote upload (ie. Arduino connected to Raspberry PI) is supported. For more information read https://docs.platformio.org/en/latest/core/userguide/remote/cmd_agent.html.
24
48
25
-
# Configuration
49
+
### Updating
50
+
If you have 'git', just type `git pull`. Otherwise download zip file and extract to new directory - remember, to backup 'config.h'.
51
+
It is also convinient to have 'config.h' someware else, then you can use symbolic link. In Windows you have 2 options:
52
+
53
+
CMD:
54
+
```
55
+
mklink "<your local config directory>\config.h" "<your repo directory>\include\config.h"
56
+
```
57
+
or PowerShell (assuming that you run in main repo directory):
* RELAY_TRIGGER_LOW or RELAY_TRIGGER_HIGH - required, trigger level
38
75
* RELAY_STARTUP_ON or RELAY_STARTUP_OFF - optional, startup state
39
76
* RELAY_IMPULSE - optional, relay is turned on only for short period of time (defined in constant RELAY_IMPULSE_INTERVAL, 250ms by default), ignored for DING_DONG and REED_SWITCH buttons
77
+
* RELAY_INDEPENDENT - described in (#dependent-relays)
40
78
* relay dependOn - ID of relay that needs to be turned on before this one
41
79
* relay description - reported on MySensor Gateway, can help identify device on initial configuration in Home Automation System, max. 30 chars, can be empty ("")
42
80
@@ -57,23 +95,21 @@ Params description:
57
95
* double-click relay id - sensor id used in relay configuration, -1 when not used, ignored for DING_DONG/REED_SWITCH
58
96
* button description - debug only information, max. 30 chars, can be empty ("")
59
97
60
-
61
-
## Example config with REED_SWITCH
98
+
### Example config with REED_SWITCH
62
99
```
63
100
const RelayConfigDef gRelayConfig[] PROGMEM = {
64
-
{26, 31, RELAY_TRIGGER_HIGH, "Garage Door"},
101
+
{26, 31, RELAY_TRIGGER_HIGH, -1, "Garage Door"},
65
102
...
66
103
};
67
104
const ButtonConfigDef gButtonConfig[] PROGMEM = {
68
105
{43, REED_SWITCH, 26, -1, -1, "Garage Door reed switch"},
69
106
...
70
107
};
71
108
```
72
-
In this case relay 26 is always reported throught as S_DOOR sensor, i.e. in Home Assistant this relay can be found in entities as binary_sensor.multi_relay_0_26.
109
+
In this case relay 26 is always reported throught as S_DOOR sensor, i.e. in Home Assistant this relay can be found in entities as binary_sensor.
73
110
74
-
75
-
## Dependent relays
76
-
The "dependOn" option in relays configuration is intended for turning ON and OFF power supplies, not to create scenes.
111
+
### Dependent relays
112
+
The "dependOn" option in relays configuration is intended for turning ON and OFF power supplies or simple scenes.
77
113
For example, you have 12V power supply and two 12V LED lights:
78
114
```
79
115
...
@@ -85,8 +121,18 @@ For example, you have 12V power supply and two 12V LED lights:
85
121
When you turn on _LED Strip_ and/or _Stairs light_, then _Power supply 12V_ will be automatically turned on.
86
122
_Power supply 12V_ will be automatically turned off, when all parent devices will be turned off.
* In case of static IP address (no DHCP) you have to define following parameters:
176
+
*`#define MY_IP_ADDRESS 192,168,178,87` - IP address of the device
177
+
*`#define MY_IP_GATEWAY_ADDRESS 192,168,178,1` - IP address of your router
178
+
*`#define MY_IP_SUBNET_ADDRESS 255,255,255,0` - local network mask
179
+
*`#define MY_PORT 5003` - if not using MQTT, MySensors gateway will listen on this port (if using default 5003 you dont need this in config.h)
180
+
*`#define MY_USE_UDP` - if not using MQTT, you can choose UDP (default is TCP)
181
+
182
+
This are still experimental options and waiting for contribution with working config.
183
+
184
+
### MQTT Configuration
185
+
*`#define MY_GATEWAY_MQTT_CLIENT` - enable MySensors MQTT support
186
+
*`#define MY_MQTT_PUBLISH_TOPIC_PREFIX "multi-relay/out"` - gateway will send events to this topic
187
+
*`#define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "multi-relay/in"` - gateway will listen for commands on this topic
188
+
*`#define MY_MQTT_CLIENT_ID "multi-relay-2"` - client id when connecting to MQTT broker
189
+
*`#define MY_CONTROLLER_IP_ADDRESS 192,168,178,17` - MQTT broker IP address
190
+
*`#define MY_CONTROLLER_URL_ADDRESS "test.mosquitto.org"` - MQTT broker URL instead of ip address
191
+
*`#define MY_PORT 1883` - MQTT broker port
192
+
*`#define MY_MQTT_USER "<YOUR MQTT USERNAME>"` - user name, if your MQTT broker requires authentication
193
+
*`#define MY_MQTT_PASSWORD "<YOUR MQTT PASSWORD>"` - user password, if your MQTT broker requires authentication
194
+
*`#define MY_NODE_ID 1` - may be required (need tests)
195
+
196
+
197
+
## Debugging
198
+
In a `platformio.ini` file in section [env] you can uncomment (remove ";" at the beginning) some `build_flags`:
125
199
*`DEBUG_STATS=1000` - time statistics can be printed on serial, when they are triggered via appropriate MySensors command - read more in MySensors commands sections
126
200
*`DEBUG_COMMUNICATION` - show some debug information about received MySensors commands on serial
127
201
*`DEBUG_ACTION` - detailed information about button actions on serial
128
202
*`DEBUG_STARTUP` - detaled information about configuration parameters. Usefull when you want report some problems with sketch.
129
203
130
-
131
-
# Expander
204
+
## Expander
205
+
Expanders alow you to have more GPIO pins over I2C protocol. On a single I2C data line you can connect one or more expanders.
206
+
It is recomended to use expanders only for relays, because they are much slower than internal GPIO, and switches are checked all the time.
132
207
Only one expander library at a time is supported.
208
+
To build expander version just select appropriate `env` with sufix `pcf` or `mcp`.
133
209
134
-
## PCF8574
135
-
To use expander PCF8574 you have to install library:
136
-
* download https://github.com/skywodd/pcf8574_arduino_library as zip archive
137
-
* extract directory PCF8574 into `lib/PCF8574`
138
-
Basic information about expander and library you can find here - https://youtu.be/JNmVREucfyc (PL, library in description)
139
-
140
-
And in a `platformio.ini` file in section [common_env_data] uncomment `EXPANDER_PCF8574` in `build_flags`.
0 commit comments