FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
+1 vote
814 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 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 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 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.