10466 questions

12474 answers

19396 comments

21924 members

+1 vote
659 views 2 comments
by
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
by

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

Just use gpio.sh for digital input tracking.

More information here:

https://wiki.teltonika.lt/view/RUT240_Input/Output

by
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 gpio.sh 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
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.