Closed
Description
Originally reported by: laurinaitis (Bitbucket: laurinaitis, GitHub: laurinaitis)
Hello Xose,
I modified ESPURNA to work with 8-Channel Relay Module. Maybe you can include this in a standard package?You can comment on unnecessary relays. It would be much more convenient to update ESPURNA.
File: hardware.h
#!arduino
// -----------------------------------------------------------------------------
// Development boards
// -----------------------------------------------------------------------------
#if defined(NODEMCU_LOLIN)
// Info
#define MANUFACTURER "NODEMCU"
#define DEVICE "LOLIN"
// Buttons
#define BUTTON1_PIN 3
#define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#define BUTTON1_RELAY 1
// Relays
#define RELAY1_PIN 3
#define RELAY1_TYPE RELAY_TYPE_NORMAL
#define RELAY2_PIN 15
#define RELAY2_TYPE RELAY_TYPE_NORMAL
#define RELAY3_PIN 13
#define RELAY3_TYPE RELAY_TYPE_NORMAL
#define RELAY4_PIN 12
#define RELAY4_TYPE RELAY_TYPE_NORMAL
#define RELAY5_PIN 14
#define RELAY5_TYPE RELAY_TYPE_NORMAL
#define RELAY6_PIN 4
#define RELAY6_TYPE RELAY_TYPE_NORMAL
#define RELAY7_PIN 5
#define RELAY7_TYPE RELAY_TYPE_NORMAL
#define RELAY8_PIN 16
#define RELAY8_TYPE RELAY_TYPE_NORMAL
// #define RELAY2_TYPE RELAY_TYPE_INVERSE
// LEDs
#define LED1_PIN 2
#define LED1_PIN_INVERSE 1
#elif defined(WEMOS_D1_MINI_RELAYSHIELD)
// Info
#define MANUFACTURER "WEMOS"
#define DEVICE "D1_MINI_RELAYSHIELD"
// Buttons
// No buttons on the D1 MINI alone, but defining it without adding a button doen't create problems
#define BUTTON1_PIN 0 // Connect a pushbutton between D3 and GND,
// it's the same as using a Wemos one button shield
#define BUTTON1_MODE BUTTON_PUSHBUTTON | BUTTON_DEFAULT_HIGH
#define BUTTON1_RELAY 1
// Relays
#define RELAY1_PIN 14
#define RELAY1_TYPE RELAY_TYPE_NORMAL
#define RELAY2_PIN 12
#define RELAY2_TYPE RELAY_TYPE_NORMAL
#define RELAY3_PIN 13
#define RELAY3_TYPE RELAY_TYPE_NORMAL
#define RELAY4_PIN 15
#define RELAY4_TYPE RELAY_TYPE_NORMAL
#define RELAY5_PIN 1
#define RELAY5_TYPE RELAY_TYPE_NORMAL
#define RELAY6_PIN 3
#define RELAY6_TYPE RELAY_TYPE_NORMAL
#define RELAY7_PIN 5
#define RELAY7_TYPE RELAY_TYPE_NORMAL
#define RELAY8_PIN 4
#define RELAY8_TYPE RELAY_TYPE_NORMAL
// LEDs
#define LED1_PIN 2
#define LED1_PIN_INVERSE 1
// -----------------------------------------------------------------------------
// Default values
// -----------------------------------------------------------------------------
#ifndef BUTTON1_RELAY
#define BUTTON1_RELAY 0
#endif
#ifndef BUTTON2_RELAY
#define BUTTON2_RELAY 0
#endif
#ifndef BUTTON3_RELAY
#define BUTTON3_RELAY 0
#endif
#ifndef BUTTON4_RELAY
#define BUTTON4_RELAY 0
#endif
#ifndef BUTTON5_RELAY
#define BUTTON5_RELAY 0
#endif
#ifndef BUTTON6_RELAY
#define BUTTON6_RELAY 0
#endif
#ifndef BUTTON7_RELAY
#define BUTTON7_RELAY 0
#endif
#ifndef BUTTON8_RELAY
#define BUTTON8_RELAY 0
#endif
#ifndef RELAY1_RESET_PIN
#define RELAY1_RESET_PIN 0
#endif
#ifndef RELAY2_RESET_PIN
#define RELAY2_RESET_PIN 0
#endif
#ifndef RELAY3_RESET_PIN
#define RELAY3_RESET_PIN 0
#endif
#ifndef RELAY4_RESET_PIN
#define RELAY4_RESET_PIN 0
#endif
#ifndef RELAY5_RESET_PIN
#define RELAY5_RESET_PIN 0
#endif
#ifndef RELAY6_RESET_PIN
#define RELAY6_RESET_PIN 0
#endif
#ifndef RELAY7_RESET_PIN
#define RELAY7_RESET_PIN 0
#endif
#ifndef RELAY8_RESET_PIN
#define RELAY8_RESET_PIN 0
#endif
#ifndef RELAY1_DELAY_ON
#define RELAY1_DELAY_ON 0
#endif
#ifndef RELAY2_DELAY_ON
#define RELAY2_DELAY_ON 0
#endif
#ifndef RELAY3_DELAY_ON
#define RELAY3_DELAY_ON 0
#endif
#ifndef RELAY4_DELAY_ON
#define RELAY4_DELAY_ON 0
#endif
#ifndef RELAY5_DELAY_ON
#define RELAY5_DELAY_ON 0
#endif
#ifndef RELAY6_DELAY_ON
#define RELAY6_DELAY_ON 0
#endif
#ifndef RELAY7_DELAY_ON
#define RELAY7_DELAY_ON 0
#endif
#ifndef RELAY8_DELAY_ON
#define RELAY8_DELAY_ON 0
#endif
#ifndef RELAY1_DELAY_OFF
#define RELAY1_DELAY_OFF 0
#endif
#ifndef RELAY2_DELAY_OFF
#define RELAY2_DELAY_OFF 0
#endif
#ifndef RELAY3_DELAY_OFF
#define RELAY3_DELAY_OFF 0
#endif
#ifndef RELAY4_DELAY_OFF
#define RELAY4_DELAY_OFF 0
#endif
#ifndef RELAY5_DELAY_OFF
#define RELAY5_DELAY_OFF 0
#endif
#ifndef RELAY6_DELAY_OFF
#define RELAY6_DELAY_OFF 0
#endif
#ifndef RELAY7_DELAY_OFF
#define RELAY7_DELAY_OFF 0
#endif
#ifndef RELAY8_DELAY_OFF
#define RELAY8_DELAY_OFF 0
#endif
#ifndef RELAY1_LED
#define RELAY1_LED 0
#endif
#ifndef RELAY2_LED
#define RELAY2_LED 0
#endif
#ifndef RELAY3_LED
#define RELAY3_LED 0
#endif
#ifndef RELAY4_LED
#define RELAY4_LED 0
#endif
#ifndef RELAY5_LED
#define RELAY5_LED 0
#endif
#ifndef RELAY6_LED
#define RELAY6_LED 0
#endif
#ifndef RELAY7_LED
#define RELAY7_LED 0
#endif
#ifndef RELAY8_LED
#define RELAY8_LED 0
#endif
// -----------------------------------------------------------------------------
File: relay.ino
// Dummy relays for AI Light, Magic Home LED Controller, H801,
// Sonoff Dual and Sonoff RF Bridge
#ifdef DUMMY_RELAY_COUNT
for (unsigned char i=0; i < DUMMY_RELAY_COUNT; i++) {
_relays.push_back((relay_t) {0, RELAY_TYPE_NORMAL});
}
#else
#ifdef RELAY1_PIN
_relays.push_back((relay_t) { RELAY1_PIN, RELAY1_TYPE, RELAY1_RESET_PIN, RELAY1_LED, RELAY1_DELAY_ON, RELAY1_DELAY_OFF });
#endif
#ifdef RELAY2_PIN
_relays.push_back((relay_t) { RELAY2_PIN, RELAY2_TYPE, RELAY2_RESET_PIN, RELAY2_LED, RELAY2_DELAY_ON, RELAY2_DELAY_OFF });
#endif
#ifdef RELAY3_PIN
_relays.push_back((relay_t) { RELAY3_PIN, RELAY3_TYPE, RELAY3_RESET_PIN, RELAY3_LED, RELAY3_DELAY_ON, RELAY3_DELAY_OFF });
#endif
#ifdef RELAY4_PIN
_relays.push_back((relay_t) { RELAY4_PIN, RELAY4_TYPE, RELAY4_RESET_PIN, RELAY4_LED, RELAY4_DELAY_ON, RELAY4_DELAY_OFF });
#endif
#ifdef RELAY5_PIN
_relays.push_back((relay_t) { RELAY5_PIN, RELAY5_TYPE, RELAY5_RESET_PIN, RELAY5_LED, RELAY5_DELAY_ON, RELAY5_DELAY_OFF });
#endif
#ifdef RELAY6_PIN
_relays.push_back((relay_t) { RELAY6_PIN, RELAY6_TYPE, RELAY6_RESET_PIN, RELAY6_LED, RELAY6_DELAY_ON, RELAY6_DELAY_OFF });
#endif
#ifdef RELAY7_PIN
_relays.push_back((relay_t) { RELAY7_PIN, RELAY7_TYPE, RELAY7_RESET_PIN, RELAY7_LED, RELAY7_DELAY_ON, RELAY7_DELAY_OFF });
#endif
#ifdef RELAY8_PIN
_relays.push_back((relay_t) { RELAY8_PIN, RELAY8_TYPE, RELAY8_RESET_PIN, RELAY8_LED, RELAY8_DELAY_ON, RELAY8_DELAY_OFF });
#endif
#endif
// -----------------------------------------------------------------------------
Also I tested MQTTgroups (Switch configuration), with 8 relays it does not work well, I do not really know where to look for a reason (I do not understand this place in your code).
Thank you very much for your excellent work!
Marius