xoseperez / espurna

Home automation firmware for ESP8266-based devices
http://tinkerman.cat
GNU General Public License v3.0
2.99k stars 636 forks source link

Relay pulse support #22

Closed xoseperez closed 6 years ago

xoseperez commented 7 years ago

Originally reported by: Nuno Sousa (Bitbucket: nunofgs, GitHub: nunofgs)


Hello, I am planning on using a relay to open/close a garage door.

I have a relay connected to an esp8266 but I need to toggle the relay for about 500ms (should be configurable ideally). I believe ESPEasy supports this and refers to it as a "pulse".

Any chance this could be added to espurna?

xoseperez commented 7 years ago

Original comment by jeylites (Bitbucket: jeylites, GitHub: jeylites):


Noted, i will give it a shot and see how it goes on a wemos D1 mini. Last thing is, is it available on the current build or have to pull from branch? Thank you.

xoseperez commented 7 years ago

Yes, but right now the configuration is shared by all the relays, i.e. if your set it to normally off 1 second pulse, all of them would do 1 second pulses when turned on.

xoseperez commented 7 years ago

Original comment by jeylites (Bitbucket: jeylites, GitHub: jeylites):


Does the inching - pulse mode works on more than one relay in one device?

Does it also work on 4ch pro, all relays?

xoseperez commented 7 years ago

Original comment by Matheus Telles (Bitbucket: matheustelles, GitHub: matheustelles):


Suggestion: Set which relays on the same board are configured for pulse. So one 4ch board can be hybrid for pulse and switch.

xoseperez commented 7 years ago

Removing milestone: 1.5.0 (automated comment)

xoseperez commented 7 years ago

Original comment by Zerosub (Bitbucket: Zerosub, GitHub: Zerosub):


I have all the connectors, and i'm willing to do so, but i would need some short explanation on how to do it.

Do you have a link where it's explained what to connect and how to monitor?

xoseperez commented 7 years ago

Do you have the chance to connect a serial monitor to the board to get some info from it? I hope I will receive the sample board soon to test it myself.

xoseperez commented 7 years ago

Original comment by Zerosub (Bitbucket: Zerosub, GitHub: Zerosub):


Thank you for the quick reply. I already had those settings exactly like you suggested.

Unfortunately, the board closes the relais upon powercycle. That means it does this before the software kicks in. That's really bad, as after a power loss, the garage door will open up without interaction.

I remember that it has been this way with the original firmware from ITEAD, too.

I'll have to find another way to manage this.

xoseperez commented 7 years ago

When the device boots up it will either leave the relay open, close it or read the previous status from EEPROM, depending on the relay boot mode setting. For your setup my configuration would be:

  1. Relay boot mode to "always off"
  2. Relay pulse mode to "normally off"
  3. Relay pulse time to 10 seconds (or whatever time it takes for the door to open)
xoseperez commented 7 years ago

Original comment by Zerosub (Bitbucket: Zerosub, GitHub: Zerosub):


Hi Xose, your Version 1.5 compiled well and i could flash the device smoothly. My intention was, to use it as a garagedoor opener.

The bad thing about this: when the device boots up, it switches the relay, so the door opens and shuts randomly. Is this a hardware issue or something that could be fixed by firmware?

Thnx for yout excellent work on these Itead devices!

xoseperez commented 7 years ago

Please note that the ITEAD_1CH_INCHING hardware is flagged untested. Will soon receive a sample from Itead to confirm behaviour.

xoseperez commented 7 years ago

The 1ch-inching-debug environment has been fixed and the inching branch released with version 1.5.0.

xoseperez commented 7 years ago

Original comment by Zerosub (Bitbucket: Zerosub, GitHub: Zerosub):


i'm getting there:

git clone https://bitbucket.org/xoseperez/espurna

cd espurna/code

git fetch && git checkout inching

pio run -e node-debug

pio run -e 1ch-inching-debug

But while compiling, i get the following error:

#!Compiling .pioenvs/1ch-inching-debug/FrameworkArduino/FS.o
In file included from espurna/config/all.h:3:0,
from /home/arne/espurna/code/espurna/espurna.ino:22:
/home/arne/espurna/code/espurna/relay.ino: In function 'void relayPulseMode(unsigned int, bool)':
espurna/config/general.h:23:33: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator!='
#define RELAY_PULSE_NONE        0
^
/home/arne/espurna/code/espurna/relay.ino:122:51: note: in expansion of macro 'RELAY_PULSE_NONE'
digitalWrite(LED_PULSE, relayPulseMode != RELAY_PULSE_NONE);
^
/home/arne/espurna/code/espurna/relay.ino: In function 'void relaySetup()':
/home/arne/espurna/code/espurna/relay.ino:316:55: error: 'RELAY1_PIN_INVERSE' was not declared in this scope
_relays.push_back((relay_t) { RELAY1_PIN, RELAY1_PIN_INVERSE });
^
*** [.pioenvs/1ch-inching-debug/src/espurna.ino.o] Error 1

now i'm stuck. What am i missing?

xoseperez commented 7 years ago

Original comment by Zerosub (Bitbucket: Zerosub, GitHub: Zerosub):


how do i compile the inching branch? There is no 1ch-inching Environment to compile , or at least i'm to blind to see. Thnx in advance

xoseperez commented 7 years ago

Original comment by Nuno Sousa (Bitbucket: nunofgs, GitHub: nunofgs):


Just to follow up. The inching branch works perfectly on a wemos d1+relay shield. I set inching to 1 second and it is now controlling my garage door. Thanks!

xoseperez commented 7 years ago

Hi. The behaviour you describe is planned to add on the next release. Right now it's waiting for final tests in branch "inching". You can checkout that branch and test it yourself. The only difference from what you request is that the interval is configurable but in seconds, so the minimum value is 1 second.