subscribe to our Youtube


14455 questions

17168 answers


0 members

We are migrating to our new platform at Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
+1 vote
768 views 2 comments
Is there a way to configue the Digital Input as a counter. To count the number of times the input was on and store that counter until polled. eg. poll once per hour or once per day?

1 Answer

0 votes

You can easyle write shell script which count digital input activity .

Just use for digital input tracking.

More information here:

by anonymous
The wiki link shows how to read the state. Where will I find info on writing a script that saves the counter variable to post it hourly and reset the value after I posted?

Meaning step 1: count the get DIN1  

Step 2: Save the counter in variable?:  for example where is the %ms saved so that I might be able to edit it or create my own variable like %inputcounter

Step 3: Post the variable to my server each hour and not on change of input state? That might mean that I must do it in my shell script, but I am really having a difficult time gathering information on what commands to run in the shell script if I want to complete this task.

Thanks in advance, any information regarding this will help immensely.
by anonymous
reading the state does not help in counting. the input pulse may be shorter than the reading interval and thus be lost.

the better solution is event-based - to trigger the counter value increase by the input edge.

in order not to lost the counted value during power break, a regular write to a file (not to /tmp!) is needed. do not write too often however, flash memory writing cycles count is limited.