Is it possible to Log a GPIO Pulse?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Humanoidx
New user
Posts: 9
Joined: 01 Apr 2017, 20:50

Is it possible to Log a GPIO Pulse?

#1 Post by Humanoidx » 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.

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Is it possible to Log a GPIO Pulse?

#2 Post by grovkillen » 26 Jan 2018, 06:32

Please open an issue on Github. That is something that should be logged for sure.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Is it possible to Log a GPIO Pulse?

#3 Post by toffel969 » 26 Jan 2018, 11:21

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

Humanoidx
New user
Posts: 9
Joined: 01 Apr 2017, 20:50

Re: Is it possible to Log a GPIO Pulse?

#4 Post by Humanoidx » 30 Jan 2018, 03:08

Thanks alot, that roughly works, a little delayed but at least its logging.

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Is it possible to Log a GPIO Pulse?

#5 Post by toffel969 » 30 Jan 2018, 07:54

Humanoidx wrote: 30 Jan 2018, 03:08 Thanks alot, that roughly works, a little delayed but at least its logging.
Glad I could help. @ grovkillen: maybe this could be added to github any way. Do you see a good reason why longpulse should be in seconds rather than msec? If you need the length, just add 0s, if pulse lengths exceeds variable, use timer instead. What do you think?
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Is it possible to Log a GPIO Pulse?

#6 Post by grovkillen » 30 Jan 2018, 08:05

toffel969 wrote: 30 Jan 2018, 07:54
Humanoidx wrote: 30 Jan 2018, 03:08 Thanks alot, that roughly works, a little delayed but at least its logging.
Glad I could help. @ grovkillen: maybe this could be added to github any way. Do you see a good reason why longpulse should be in seconds rather than msec? If you need the length, just add 0s, if pulse lengths exceeds variable, use timer instead. What do you think?
I think the reason is the timing, long pulse is "not that important" to end on exact 1.0000 seconds. Since the long pulse lets the rest of the loop carry on we might not know exactly when in the time span of a loop the long pulse will end. The pulse will halt everything else and wait for the mSecs to count up until reached target level. The long pulse is more of a "more than"....

I believe we should leave it as is until future releases. Or is it something we feel need to be added to the "future" milestone?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Is it possible to Log a GPIO Pulse?

#7 Post by toffel969 » 30 Jan 2018, 10:55

grovkillen wrote: 30 Jan 2018, 08:05
toffel969 wrote: 30 Jan 2018, 07:54
Humanoidx wrote: 30 Jan 2018, 03:08 Thanks alot, that roughly works, a little delayed but at least its logging.
Glad I could help. @ grovkillen: maybe this could be added to github any way. Do you see a good reason why longpulse should be in seconds rather than msec? If you need the length, just add 0s, if pulse lengths exceeds variable, use timer instead. What do you think?
I think the reason is the timing, long pulse is "not that important" to end on exact 1.0000 seconds. Since the long pulse lets the rest of the loop carry on we might not know exactly when in the time span of a loop the long pulse will end. The pulse will halt everything else and wait for the mSecs to count up until reached target level. The long pulse is more of a "more than"....

I believe we should leave it as is until future releases. Or is it something we feel need to be added to the "future" milestone?
Maybe I didn't express myself clearly. I still think we need a pulse (where accuracy is very important) and longpulse command (that is non-blocking). I am suggesting we change the unit of time from sec to msec, so that one can use sub 1 values in a non-blocking pulse.
On a different note, I really think the pwm fade should be a non-blocking commmand (long pulse style), as fade times are almost always above 1 sec.
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Is it possible to Log a GPIO Pulse?

#8 Post by grovkillen » 30 Jan 2018, 11:24

Ah, I hear ya.

I will talk with psy0rz and TD-er about how to go about that.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Is it possible to Log a GPIO Pulse?

#9 Post by grovkillen » 30 Jan 2018, 18:52

We think both these suggestions made by Toffel is logic and we'll add them to the 2.0.0 release.

https://github.com/letscontrolit/ESPEasy/issues/794
https://github.com/letscontrolit/ESPEasy/issues/793
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Is it possible to Log a GPIO Pulse?

#10 Post by toffel969 » 31 Jan 2018, 07:37

grovkillen wrote: 30 Jan 2018, 18:52 We think both these suggestions made by Toffel is logic and we'll add them to the 2.0.0 release.

https://github.com/letscontrolit/ESPEasy/issues/794
https://github.com/letscontrolit/ESPEasy/issues/793
cool beans, thx :-)
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest