Add Human Activity Sensor
This commit is contained in:
Executable
+11
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
LAST_SEEN_FILE=/var/tmp/human_last_seen
|
||||
LAST_CHECKED_FILE=/var/tmp/human_last_checked
|
||||
|
||||
LAST_SEEN=`stat /var/tmp/human_last_seen --format=%Y`
|
||||
TIME_NOW=`date +%s`
|
||||
|
||||
AGO=$(( $TIME_NOW - $LAST_SEEN ))
|
||||
echo $AGO
|
||||
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
|
||||
READER=human-activity-sensor
|
||||
LAST_SEEN_FILE=/var/tmp/human_last_seen
|
||||
LAST_CHECKED_FILE=/var/tmp/human_last_checked
|
||||
|
||||
echo "Human Activity Daemon"
|
||||
echo ""
|
||||
echo "Last seen file: $LAST_SEEN_FILE"
|
||||
echo "Last checked file: $LAST_CHECKED_FILE"
|
||||
echo ""
|
||||
echo "Values stream:"
|
||||
|
||||
LAST_VAL=-1
|
||||
while [[ true ]]; do
|
||||
VAL=`$READER`
|
||||
touch $LAST_CHECKED_FILE
|
||||
if [[ $VAL == "1" ]]; then
|
||||
touch $LAST_SEEN_FILE
|
||||
fi
|
||||
if [[ $LAST_VAL != $VAL ]]; then
|
||||
echo "[`date "+%F %T"`] $VAL"
|
||||
LAST_VAL=$VAL
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
PIN_PIR=3
|
||||
|
||||
# init
|
||||
gpio mode $PIN_PIR input
|
||||
|
||||
# read
|
||||
gpio read $PIN_PIR
|
||||
|
||||
Reference in New Issue
Block a user