Post subject: FridgeBit: refrigerator door opener counter
Posted: Fri Apr 15, 2016 6:42 pm
Joined: Wed Apr 15, 2015 3:57 am Posts: 408
This probably would have made a good April Fools Day joke for you guys, but I had an old Android phone lying around and thought I could modify my shake2text program to be sensitive enough to detect when I open my fridge if I duct tape the old phone to it (fortunately it's an old fridge).
It sort of seems to work, but unfortunately my old phone doesn't seem to like the WakeLock command to keep it going after the screen konks out.
If I get a big chunk of time and a lot of ambition, I am thinking of making something similar using a Bluetooth Arduino board running on a 9V battery and maybe a magnetic switch. Not really sure if there is something out there similar already...
! fridgebit ! program has to be trained first ! on average jolts... ! you can move the phone around gently for a minute ! or two to fill the buffer up ! ! ! BUNDLE.CREATE global
Fn.DEF readln$(f$) FILE.EXISTS isoldfile, f$ IF isoldfile TEXT.OPEN r,fh3,f$ TEXT.READLN fh3, a$ ELSE LET A$="" ENDIF FN.RTN a$ FN.END
dinit() dmode("console") TTS.INIT
Buf=0 % buffer index Bufsiz=30 % ring buffer size buffull=0 % true if buffer full Noise = 0.5 % threshhold for noise sens=0.5 % sensitivity in # of standard deviations
DIM changes[bufsiz] % ring buffer
PRINT "Filling buffer..." PRINT "Move phone around gently until Ready" PRINT
! Open the acclerometer sensor SENSORS.OPEN 1 SENSORS.READ 1,oldy,oldx,oldz TIMER.SET 100
! endless loop DO PAUSE 50 IF jolt jolt=0 eat++ showgr(eat) sendmsg(eat)
ONTIMER: SENSORS.READ 1,y,x,z Dx = (x-oldx): Dy = (y-oldy): Dz = (z-oldz) Change = dx*dx+dy*dy+dz*dz IF change > noise THEN Buf++ IF buf>bufsiz buf=1:buffull=1 ENDIF Changes[buf] =change ENDIF Oldx=x:Oldy=y:Oldz=z
IF buffull IF !bflag PRINT "ready!" bflag=1 ENDIF ARRAY.AVERAGE avgchange, changes ARRAY.STD_DEV sdev, changes
Bigchange=avgchange IF change > bigchange+sdev*sens PRINT change TIME year$, month$, day$, hour$, minutes$, seconds$ t$ = month$+"-"+day$+" "+hour$+" :"+minutes$+":"+seconds$ PRINT t$ jolt=1 % tell main program there is a jolt Bigjolts++ ENDIF
! Set flag if screen touched ONCONSOLETOUCH: T=1 CONSOLETOUCH.RESUME
Users browsing this forum: No registered users and 1 guest
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum