Browse Source

Support for EXS Wifi Relay 3.1 (untested)

fastled
Xose Pérez 7 years ago
parent
commit
8183b44e03
5 changed files with 97 additions and 43 deletions
  1. +1
    -1
      code/espurna/config/general.h
  2. +23
    -0
      code/espurna/config/hardware.h
  3. +47
    -38
      code/espurna/hardware.ino
  4. +5
    -4
      code/espurna/relay.ino
  5. +21
    -0
      code/platformio.ini

+ 1
- 1
code/espurna/config/general.h View File

@ -188,7 +188,7 @@ PROGMEM const char* const custom_reset_string[] = {
#define RELAY_FLOOD_CHANGES 5 #define RELAY_FLOOD_CHANGES 5
// Pulse with in milliseconds for a latched relay // Pulse with in milliseconds for a latched relay
#define RELAY_LATCHING_PULSE 50
#define RELAY_LATCHING_PULSE 10
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// I18N // I18N


+ 23
- 0
code/espurna/config/hardware.h View File

@ -785,6 +785,29 @@
#define LED1_PIN 2 #define LED1_PIN 2
#define LED1_PIN_INVERSE 0 #define LED1_PIN_INVERSE 0
// -----------------------------------------------------------------------------
// EX-Store Wifi Relay v3.1
// https://ex-store.de/ESP8266-WiFi-Relay-V31
// -----------------------------------------------------------------------------
#elif defined(EXS_WIFI_RELAY_V31)
// Untested
// Info
#define MANUFACTURER "EXS"
#define DEVICE "WIFI_RELAY_V31"
// Buttons
#define BUTTON1_PIN 0
#define BUTTON1_RELAY 1
#define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
// Relays
#define RELAY1_PIN 13
#define RELAY1_TYPE RELAY_TYPE_LATCHED
#define RELAY1_RESET_PIN 12
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Unknown hardware // Unknown hardware
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------


+ 47
- 38
code/espurna/hardware.ino View File

@ -26,7 +26,7 @@ void hwUpwardsCompatibility() {
setSetting("btnGPIO", 1, 0); setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12); setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(WEMOS_D1_MINI_RELAYSHIELD) #elif defined(WEMOS_D1_MINI_RELAYSHIELD)
@ -34,7 +34,7 @@ void hwUpwardsCompatibility() {
setSetting("ledGPIO", 1, 2); setSetting("ledGPIO", 1, 2);
setSetting("ledLogic", 1, 1); setSetting("ledLogic", 1, 1);
setSetting("relayGPIO", 1, 5); setSetting("relayGPIO", 1, 5);
setSetting("relayLogic", 1, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_BASIC) #elif defined(ITEAD_SONOFF_BASIC)
@ -44,7 +44,7 @@ void hwUpwardsCompatibility() {
setSetting("btnGPIO", 1, 0); setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12); setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_TH) #elif defined(ITEAD_SONOFF_TH)
@ -54,7 +54,7 @@ void hwUpwardsCompatibility() {
setSetting("btnGPIO", 1, 0); setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12); setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_SV) #elif defined(ITEAD_SONOFF_SV)
@ -64,7 +64,7 @@ void hwUpwardsCompatibility() {
setSetting("btnGPIO", 1, 0); setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12); setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_TOUCH) #elif defined(ITEAD_SONOFF_TOUCH)
@ -74,7 +74,7 @@ void hwUpwardsCompatibility() {
setSetting("btnGPIO", 1, 0); setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12); setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_POW) #elif defined(ITEAD_SONOFF_POW)
@ -84,7 +84,7 @@ void hwUpwardsCompatibility() {
setSetting("btnGPIO", 1, 0); setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12); setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("selGPIO", 5); setSetting("selGPIO", 5);
setSetting("cf1GPIO", 13); setSetting("cf1GPIO", 13);
setSetting("cfGPIO", 14); setSetting("cfGPIO", 14);
@ -106,7 +106,7 @@ void hwUpwardsCompatibility() {
setSetting("btnGPIO", 1, 0); setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12); setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_4CH) #elif defined(ITEAD_SONOFF_4CH)
@ -125,10 +125,10 @@ void hwUpwardsCompatibility() {
setSetting("relayGPIO", 2, 5); setSetting("relayGPIO", 2, 5);
setSetting("relayGPIO", 3, 4); setSetting("relayGPIO", 3, 4);
setSetting("relayGPIO", 4, 15); setSetting("relayGPIO", 4, 15);
setSetting("relayLogic", 1, 0);
setSetting("relayLogic", 2, 0);
setSetting("relayLogic", 3, 0);
setSetting("relayLogic", 4, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("relayType", 2, RELAY_TYPE_NORMAL);
setSetting("relayType", 3, RELAY_TYPE_NORMAL);
setSetting("relayType", 4, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SLAMPHER) #elif defined(ITEAD_SLAMPHER)
@ -138,7 +138,7 @@ void hwUpwardsCompatibility() {
setSetting("btnGPIO", 1, 0); setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12); setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_S20) #elif defined(ITEAD_S20)
@ -148,7 +148,7 @@ void hwUpwardsCompatibility() {
setSetting("btnGPIO", 1, 0); setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12); setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ELECTRODRAGON_WIFI_IOT) #elif defined(ELECTRODRAGON_WIFI_IOT)
@ -161,8 +161,8 @@ void hwUpwardsCompatibility() {
setSetting("btnRelay", 2, 2); setSetting("btnRelay", 2, 2);
setSetting("relayGPIO", 1, 12); setSetting("relayGPIO", 1, 12);
setSetting("relayGPIO", 2, 13); setSetting("relayGPIO", 2, 13);
setSetting("relayLogic", 1, 0);
setSetting("relayLogic", 2, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("relayType", 2, RELAY_TYPE_NORMAL);
#elif defined(WORKCHOICE_ECOPLUG) #elif defined(WORKCHOICE_ECOPLUG)
@ -172,7 +172,7 @@ void hwUpwardsCompatibility() {
setSetting("btnGPIO", 1, 13); setSetting("btnGPIO", 1, 13);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 15); setSetting("relayGPIO", 1, 15);
setSetting("relayLogic", 1, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(JANGOE_WIFI_RELAY_NC) #elif defined(JANGOE_WIFI_RELAY_NC)
@ -183,8 +183,8 @@ void hwUpwardsCompatibility() {
setSetting("btnRelay", 2, 2); setSetting("btnRelay", 2, 2);
setSetting("relayGPIO", 1, 2); setSetting("relayGPIO", 1, 2);
setSetting("relayGPIO", 2, 14); setSetting("relayGPIO", 2, 14);
setSetting("relayLogic", 1, 1);
setSetting("relayLogic", 2, 1);
setSetting("relayType", 1, RELAY_TYPE_INVERSE);
setSetting("relayType", 2, RELAY_TYPE_INVERSE);
#elif defined(JANGOE_WIFI_RELAY_NO) #elif defined(JANGOE_WIFI_RELAY_NO)
@ -195,8 +195,8 @@ void hwUpwardsCompatibility() {
setSetting("btnRelay", 2, 2); setSetting("btnRelay", 2, 2);
setSetting("relayGPIO", 1, 2); setSetting("relayGPIO", 1, 2);
setSetting("relayGPIO", 2, 14); setSetting("relayGPIO", 2, 14);
setSetting("relayLogic", 1, 0);
setSetting("relayLogic", 2, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("relayType", 2, RELAY_TYPE_NORMAL);
#elif defined(OPENENERGYMONITOR_MQTT_RELAY) #elif defined(OPENENERGYMONITOR_MQTT_RELAY)
@ -206,15 +206,15 @@ void hwUpwardsCompatibility() {
setSetting("btnGPIO", 1, 0); setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12); setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(JORGEGARCIA_WIFI_RELAYS) #elif defined(JORGEGARCIA_WIFI_RELAYS)
setSetting("board", 19); setSetting("board", 19);
setSetting("relayGPIO", 1, 0); setSetting("relayGPIO", 1, 0);
setSetting("relayLogic", 1, 1);
setSetting("relayGPIO", 2, 2); setSetting("relayGPIO", 2, 2);
setSetting("relayLogic", 2, 1);
setSetting("relayType", 1, RELAY_TYPE_INVERSE);
setSetting("relayType", 2, RELAY_TYPE_INVERSE);
#elif defined(AITHINKER_AI_LIGHT) #elif defined(AITHINKER_AI_LIGHT)
@ -250,7 +250,7 @@ void hwUpwardsCompatibility() {
setSetting("btnGPIO", 1, 0); setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12); setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(TINKERMAN_ESPURNA_H) #elif defined(TINKERMAN_ESPURNA_H)
@ -260,7 +260,7 @@ void hwUpwardsCompatibility() {
setSetting("btnGPIO", 1, 4); setSetting("btnGPIO", 1, 4);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12); setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 1);
setSetting("relayType", 1, RELAY_TYPE_INVERSE);
setSetting("selGPIO", 2); setSetting("selGPIO", 2);
setSetting("cf1GPIO", 13); setSetting("cf1GPIO", 13);
setSetting("cfGPIO", 14); setSetting("cfGPIO", 14);
@ -321,10 +321,10 @@ void hwUpwardsCompatibility() {
setSetting("relayGPIO", 2, 5); setSetting("relayGPIO", 2, 5);
setSetting("relayGPIO", 3, 4); setSetting("relayGPIO", 3, 4);
setSetting("relayGPIO", 4, 15); setSetting("relayGPIO", 4, 15);
setSetting("relayLogic", 1, 0);
setSetting("relayLogic", 2, 0);
setSetting("relayLogic", 3, 0);
setSetting("relayLogic", 4, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("relayType", 2, RELAY_TYPE_NORMAL);
setSetting("relayType", 3, RELAY_TYPE_NORMAL);
setSetting("relayType", 4, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_B1) #elif defined(ITEAD_SONOFF_B1)
@ -356,7 +356,7 @@ void hwUpwardsCompatibility() {
setSetting("btnGPIO", 1, 9); setSetting("btnGPIO", 1, 9);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 5); setSetting("relayGPIO", 1, 5);
setSetting("relayLogic", 1, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_T1_2CH) #elif defined(ITEAD_SONOFF_T1_2CH)
@ -369,8 +369,8 @@ void hwUpwardsCompatibility() {
setSetting("btnRelay", 2, 2); setSetting("btnRelay", 2, 2);
setSetting("relayGPIO", 1, 12); setSetting("relayGPIO", 1, 12);
setSetting("relayGPIO", 2, 4); setSetting("relayGPIO", 2, 4);
setSetting("relayLogic", 1, 0);
setSetting("relayLogic", 2, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("relayType", 2, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_T1_3CH) #elif defined(ITEAD_SONOFF_T1_3CH)
@ -386,9 +386,9 @@ void hwUpwardsCompatibility() {
setSetting("relayGPIO", 1, 12); setSetting("relayGPIO", 1, 12);
setSetting("relayGPIO", 2, 5); setSetting("relayGPIO", 2, 5);
setSetting("relayGPIO", 3, 4); setSetting("relayGPIO", 3, 4);
setSetting("relayLogic", 1, 0);
setSetting("relayLogic", 2, 0);
setSetting("relayLogic", 3, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
setSetting("relayType", 2, RELAY_TYPE_NORMAL);
setSetting("relayType", 3, RELAY_TYPE_NORMAL);
#elif defined(ITEAD_SONOFF_RF) #elif defined(ITEAD_SONOFF_RF)
@ -398,7 +398,7 @@ void hwUpwardsCompatibility() {
setSetting("btnGPIO", 1, 0); setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1); setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 12); setSetting("relayGPIO", 1, 12);
setSetting("relayLogic", 1, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(WION_50055) #elif defined(WION_50055)
@ -408,7 +408,16 @@ void hwUpwardsCompatibility() {
setSetting("btnGPIO", 1, 13); setSetting("btnGPIO", 1, 13);
setSetting("btnRelay", 1,1); setSetting("btnRelay", 1,1);
setSetting("relayGPIO", 1, 15); setSetting("relayGPIO", 1, 15);
setSetting("relayLogic", 1, 0);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#elif defined(EXS_WIFI_RELAY_V31)
setSetting("board", 35);
setSetting("btnGPIO", 1, 0);
setSetting("btnRelay", 1, 1);
setSetting("relayGPIO", 1, 13);
setSetting("relayResetGPIO", 1, 12);
setSetting("relayType", 1, RELAY_TYPE_NORMAL);
#else #else


+ 5
- 4
code/espurna/relay.ino View File

@ -67,15 +67,16 @@ void relayProviderStatus(unsigned char id, bool status) {
} else if (_relays[id].type == RELAY_TYPE_INVERSE) { } else if (_relays[id].type == RELAY_TYPE_INVERSE) {
digitalWrite(_relays[id].pin, !status); digitalWrite(_relays[id].pin, !status);
} else if (_relays[id].type == RELAY_TYPE_LATCHED) { } else if (_relays[id].type == RELAY_TYPE_LATCHED) {
digitalWrite(_relays[id].pin, LOW);
digitalWrite(_relays[id].reset_pin, LOW);
if (status) { if (status) {
digitalWrite(_relays[id].pin, HIGH); digitalWrite(_relays[id].pin, HIGH);
delay(RELAY_LATCHING_PULSE);
digitalWrite(_relays[id].pin, LOW);
} else { } else {
digitalWrite(_relays[id].reset_pin, HIGH); digitalWrite(_relays[id].reset_pin, HIGH);
delay(RELAY_LATCHING_PULSE);
digitalWrite(_relays[id].reset_pin, LOW);
} }
delay(RELAY_LATCHING_PULSE);
digitalWrite(_relays[id].pin, LOW);
digitalWrite(_relays[id].reset_pin, LOW);
} }
#endif #endif


+ 21
- 0
code/platformio.ini View File

@ -675,3 +675,24 @@ build_flags = ${common.build_flags_1m} -DWION_50055
upload_speed = 115200 upload_speed = 115200
upload_port = "192.168.4.1" upload_port = "192.168.4.1"
upload_flags = --auth=fibonacci --port 8266 upload_flags = --auth=fibonacci --port 8266
[env:exs-wifi-relay-v31]
platform = espressif8266
framework = arduino
board = esp07
board_flash_mode = dout
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m} -DEXS_WIFI_RELAY_V31
[env:exs-wifi-relay-v31-ota]
platform = espressif8266
framework = arduino
board = esp07
board_flash_mode = dout
lib_deps = ${common.lib_deps}
lib_ignore = ${common.lib_ignore}
build_flags = ${common.build_flags_1m} -DEXS_WIFI_RELAY_V31
upload_speed = 115200
upload_port = "192.168.4.1"
upload_flags = --auth=fibonacci --port 8266

Loading…
Cancel
Save