Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Do not forget to apply/set the script to pin5 (/iot gpio digital set pin5 script=script_name), as shown in the "email notification" example above.


If the mechanical switch is used to send the signal to the GPIO pin, it is suggested to use the following script instead (in case the script is initiated more than once when the signal is received on the pin):

:global gpioscriptrunning;
if (!$gpioscriptrunning) do={:set $gpioscriptrunning true;
:log info "script started - GPIO changed";
:do {if ([/iot gpio digital get pin5 input] = "0") do={/tool e-mail send to="config@mydomain.com" subject=[/system identity get name] body="pin5 received logical 0"} else {/tool e-mail send to="config@mydomain.com" subject=[/system identity get name]  body="pin5 received logical 1"};
:delay 1s;
:set $gpioscriptrunning false} on-error={:set $gpioscriptrunning false;
:log info "e-mail error, resetting script state..."}}

If the GPIO pin state changes more than once within mili/microseconds - the script above will make sure that e-mail notification is not sent more than once.

Monitoring voltage

Last but not least - is to "monitor voltage" using the analog pins.  You need a script that will read/monitor voltage on schedule and then send the data via e-mail, MQTT or HTTPS (fetch).

...