2 # Simple sleep monitor (Harvie 2012)
4 # You probably have soundcard with one output and input
5 # Take PIR motion sensor from security system
6 # Use PIR to switch connection between left channels of output and input (tips of 3.5mm jacks)
7 # Connect grounds of these two together (maybe you will not need it - depending on your soundcard)
10 # Use alsamixer and some GUI recorder (like audacity) to tune volume to some usable level
11 # Place PIR facing to your bed and go sleep
16 out
=/tmp
/sleeplog-
"$(date +%F_%r)".txt
17 speaker-test
-t sine
&>/dev
/null
&
21 while getopts "s" OPT
; do
22 test "$OPT" == 's' && screen
=true
;
24 arecord | .
/goertzel
-i -q -a -t $tresh -s 2000 |
while read line
; do
26 time="$(echo "$line" | cut -f 1)"
27 level
="$(echo "$line" | cut -f 2)"
28 echo -ne "$time\t$date\t$(date '+%F%t%r')\t"
29 test "$level" -gt "$tresh" && {
30 echo -n "Nothing detected...";
31 $screen && xset dpms force off
33 echo -n "Motion detected!!!!";
34 $screen && xset dpms force on
36 test "$lastdate" != 0 && {
37 after
=$
(( $date - $lastdate))
38 echo -ne "\t$level After $after secs";
44 echo "Your file: $out"
This page took 0.376994 seconds and 4 git commands to generate.