Humanoidx wrote: ↑26 Jan 2018, 06:06
Hey guys, I need some help... Im using my Espeasy as a high pressure aeroponics controller.
Previously I have been spraying my plants roots 1 second every 10 minutes using timers and GPIO on/off commands, Doing this I am able to log the GPIO with a Switch Device and send myself a notification through domotics if it has stayed on or off too long.
Code: Select all
on rules#timer=1 do
if [system enable#status]=1
gpio,5,0
timerset,2,[Timer1#SprayON1]
endif
endon
on rules#timer=2 do
if [system enable#status]=1
gpio,5,1
timerset,1,[Timer1#SprayOFF1]
endif
endon
I would now like to switch to an off time of 5 minutes and an on time of 500 mSec.
Ive tried doing this using 1 timer and a gpio short pulse as shown below.
Code: Select all
on rules#timer=1 do
if [system enable#status]=1
pulse,5,1,[Timer1#SprayON1]
timerset,1,[Timer1#SprayOFF1]
endif
endon
Howeverrrr...... when I do this, it no longer logs when the gpio switches, it seems like the pulse command in rules doesn't send this info to the switch device, even if I bump up the pulse to 10000 msec.
Is there any way around this?, perhaps this can be an addition to the next build?
Many thanks for the development, I love ESP Easy.
The normal pulse command is a blocking command. It doesnt react to anything during the time of the pulse --> it misses the input. maybe it is possible to adapt the longpulse command to values shorter than 1 ?
I just checked in the source. It should be easily possible to use longpulsevalues shorter than 1 sec. In _P001_Switch.ino
Thats the original code:
Code: Select all
if (command == F("longpulse"))
{
success = true;
if (event->Par1 >= 0 && event->Par1 <= PIN_D_MAX)
{
pinMode(event->Par1, OUTPUT);
digitalWrite(event->Par1, event->Par2);
setPinState(PLUGIN_ID_001, event->Par1, PIN_MODE_OUTPUT, event->Par2);
setSystemTimer(event->Par3 * 1000, PLUGIN_ID_001, event->Par1, !event->Par2, 0);
log = String(F("SW : GPIO ")) + String(event->Par1) + String(F(" Pulse set for ")) + String(event->Par3) + String(F(" S"));
addLog(LOG_LEVEL_INFO, log);
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_001, event->Par1, log, 0));
}
}
by removing the factor "1000", the longpulse should now take msec, rather than sec. Try to chang it to:
Code: Select all
if (command == F("longpulse"))
{
success = true;
if (event->Par1 >= 0 && event->Par1 <= PIN_D_MAX)
{
pinMode(event->Par1, OUTPUT);
digitalWrite(event->Par1, event->Par2);
setPinState(PLUGIN_ID_001, event->Par1, PIN_MODE_OUTPUT, event->Par2);
setSystemTimer(event->Par3 , PLUGIN_ID_001, event->Par1, !event->Par2, 0);
log = String(F("SW : GPIO ")) + String(event->Par1) + String(F(" Pulse set for ")) + String(event->Par3) + String(F(" S"));
addLog(LOG_LEVEL_INFO, log);
SendStatus(event->Source, getPinStateJSON(SEARCH_PIN_STATE, PLUGIN_ID_001, event->Par1, log, 0));
}
}
change the source, compile bin and try with longpulse command . Suggested rule(you need NTP):
Code: Select all
On Clock#Time=**:*0 do
longpulse,5,1,500
Endon
On Clock#Time=**:*5 do
longpulse,5,1,500
Endon
That should do the trick
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8