Giter Club home page Giter Club logo

gpio-watch's Introduction

gpio-watch

gpio-watch is a tool for running scripts in response to GPIO events.

Synopsis

gpio-watch [-s script_directory] [-e default_edge] [pin[:edge]] ...

Description

gpio-watch was written to make it easy to connect external edge-triggered sensors -- like pushbuttons -- to a Raspberry Pi (or other computer with available GPIO lines). It will watch a set of pins for events, and will trigger shell scripts in response to those events.

gpio-watch accepts a list of pins to watch for events. By default it will trigger on both rising and falling events, but you can change the default behavior with the -e default_edge command line option.

You may also modify the behavior per-pin by appending an edge mode after the pin number, such as 4:rising to monitor the rising edge on pin 4.

Options

  • -s script_directory -- location in which gpio-watch will look for event handling scripts. Scripts must be named after the pin number triggering the event. For example, if you specify -s /etc/gpio-scripts, and gpio-watch processes an event on pin 4, it will attempt to run /etc/gpio-scripts/4.

    Defaults to /etc/gpio-scripts.

  • -e default_edge -- specifies whether gpio-watch should monitor rising, falling, or both edges by default. You can also specify edge detection per-pin.

    The special keyword switch activates switch debouncing logic. In this mode, gpio-watch sets the edge mode to both but only activates the event script when the button has been released. The release (falling) event must happen more than DEBOUNCE_INTERVAL (current hardcoded as 100000 nanoseconds) after the press (rising) event to activate the script.

Example

Watch switches connected to pins 21, 22, and 23:

gpio-watch -e switch 21 22 23

If you were to press a button connected to pin 23, gpio-watch would attempt to run:

/etc/gpio-scripts/23 23 0

That is, the event script is called with both the pin number and the current pin value to permit a single script to handle multiple events.

Build & install

make
sudo make install

License

gpio-watch, a tool for running scripts in response to gpio events Copyright (C) 2014 Lars Kellogg-Stedman [email protected]

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

gpio-watch's People

Contributors

balbinus avatar falkorichter avatar kfftfuftur avatar larsks avatar thesin- avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gpio-watch's Issues

A version compatible with the chardev interface?

On many recent distributions, the /sys/class/gpio devices are no longer present and require a kernel recompile to come back.
This is because, as explained here, the associated interface has been marked deprecated in 2015 and removed in late 2020.

It would be nice if this tool was updated to use the new kernel interface

Script not firing on first press

Running a script based on a switch on gpio 4:
/usr/bin/gpio-watch -e switch 4

The first press results in nothing, no output from gpio-watch and the script does not run. After the initial press the scripts run without issue.

pios issue

error: script directory "/etc/gpio-scripts" does not exist.

gpio-watch command not working after reboot

Hi,
First off, thanks for this little tool, it is very helpful with my home made domotic system: D

i was using a python script to watch gpio as a deamon but it would crash after some hours of running.

I'm having an issue with your tool, first install without an issue, everything works, coded my bash scripts, all good.
after rebooting the raspberry pi, it seems that the tool does not pick up any activity from the gpio, i juste get a blanc line without any logs when I press the button. (executing in the command directly in the console)
I ran my python tool to see if it was a hardware probleme but the python did pick up the gpio state change.

i tried doing a sudo make install as i only dit a make and used the tool from this folder, it started working again, but after a reboot, same thing :/

weather i use the tool in /usr/bin ou from the make folder, nothing is picked up.

I'm running a script as a service which executes /path/to/gpio-watcher -s /path/to/scripts/ 15, the service runs ok, and I can see my scripts executed correctly. I tried disabling the service in case it was breaking the tool on startup but it did not resolve the issue.

Do you have any idea of what can cause this probleme ? How can i assist you in debugging this ? don't hesitate to ask me for logs or try some things, i would be happy to help.

have a nice day

Event script not running

Setting up gpio-watch with

 /home/pi/gpio-watch/gpio-watch -D /home/pi/gpio-watch -e both 25

When the event is triggered (reed switch on pin 25) I get an error message

run_script:105 pin 25: event script exited with status = 255

the "25" script is verified executable, and should run

echo "door status changed to $2"

It works when I execute it manually.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.