After having presented RFIDer and after having show you a simple shell script to control motion detecion of a D-Link DCS-960L, i want to describe how to merge those two programs in order to enable/disable motion detection using rfid tokens and a rfid reader.
As usually i’m using a RaspberryPI as a central unit.
Step 1: download rfider (see github page), copy the binary file rfider to /home/pi/ and make it executable.
Step 2: create file /home/pi/cam.sh , make it executable and paste into it the code shown in the previous article about D-Link DCS-960L.
Step 3: create file file /home/pi/exec.sh , make it executable and paste into it the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
#!/bin/sh # list of valid tokens TOKENS="TOKEN1 TOKEN2 TOKEN3" # token read by RFIDer TOKEN="" # read token value sent by RFIDer read TOKEN < /dev/stdin # check if the token read is in the "valid list" OK= for CHKTOKEN in $TOKENS ; do if [ "$CHKTOKEN" = "$TOKEN" ]; then OK=1 fi done # if the token is valid call the camera ... if [ "$OK" = "1" ]; then ACTION="toggle" if [ -e /home/pi/cam.sh ]; then . /home/pi/cam.sh fi fi exit 0 |
Remember to replace TOKEN1, TOKEN2 e TOKEN3 with your tokens id (my tokens have 10-digits code)
Step 4: look into directory /dev/input/by-id/ and get the device name related to your rfid reader
Step 5 : modify file /etc/rc.local adding before the line exit 0 the followin command:
1 |
/home/pi/rfider -d DEVICE /home/pi/exec.sh & |
Remember to replace DEVICE with the full path find in Step 4.
Step 6: Reboot you Raspberry.
Now you are ready to manage your camera’s motion detection using rfid tokens.