Cheap tweeting RFID home security/automation system V1.5



@labosdata

CONCEPT
One of the first things we bought when we founded our hackerspace was a cheep RFID access control system. The original plan was just to connect it to an electric lock on the door and access the space whithout a traditional key. We soon realised that the stuff in our space is not cheap enough to relay on a cheap electromagnetic lock and moved on to other projects. A year later we stumbeled upon the RFID reader and started thinking what can it be usefull for, and EUREKA it was the solution for keeping tabs on enyone not authorized by us that sometimes enters the space with a spare key.
And so we made the door tweet and email us when it’s locked and unlocked with and without rfid authentication. And well, this is a hackerspace, so why stop there?
This is the list of all current uses in ver.1.5
Post lock state on twitter.
Post room temperature on state change on twitter.
Email us on lock state change
Turn on Alarm sound and blink the light violently in the room on unauthorized entering.
Automaticly playing/stoping music playlists in mpd on authorized open/close state.
Automaticly turning lights in the room on/off on open/close state.
Shortly,when a virtual and/or physical trigger is activated it can execute any program/command on any computer it can access via ssh.

Ver.2.0 for the new version we plan on adding the following functions:
Custom tweet/e-mail/playlist for every user(card).
Party switch: Custom: playlist/volume/RGB-led lights profile/tweet party mode.
Adding new triggers/sensors/input devices.
sustav1

PARTS
In the ver.1.5 we used:

HARDWARE
1x Arduino Duemilanove
1x tl-wr703n router
1x AD2000-M RFID access control
1x Always on pc (not necessary for just tweeting/e-mail)
5x 433Mhz controlled RC switches
1x USB-UART TTL adapter
1x Dallas one wire temperature sensor
1x Powered USB 2.0 hub
SOFTWARE:
Homebrew arduino code
OpenWRT on the router
open.sen.se web service, for loging and posting data online
Debian on PC (but you can use any linux)
MPD & MPC for playing music from PC.
Mplayer for the siren sound.
Dropbox for captured intrusions video sharing on twitter
ssh for secure connection between router and pc.

RFID
sustav2
We used the cheap AD2000-M card codes can also be read from pin 16 on the microcontroller(not yet implimented).
The pins we used are the first four connectors as follows:

+12V dc
GND & jumper to next pin & Arduino GND
Jumper(GND)
Wire to Arduino pin A1

ARDUINO
sustav3

The pins on Arduino are connected as follows:
A0 -RFID, pin 4
A1 -microswitch in the lock
GND -RFID GND, micro-switch GND, 433 transmitter GND pin
5V -433 transmitter Vcc pin
D4 -433 transmitter data pin

YOU NEED TO EDIT THE ARDUINO OUTPUT SO THAT IT CORESPONDS TO YOUR FEED NUMBERS REGISTRED AT open.sen.se

ARDUINO CODE

#include
#define PartyPin A2
#define lock A0
#define sens A1
#define close 0
#define open 1
RCSwitch mySwitch = RCSwitch();
String dataString=””;
boolean flagNeovlasten=1;
boolean state = close;
boolean flagSerialSent=0, partySerialSent;
boolean lockState, partyState;
boolean ALARM=0;
boolean PARTY=0;

void setup() {
Serial.begin(115200);
Serial.println(“Starting…\n”);
/mySwitch.enableTransmit(4);
pinMode(PartyPin, INPUT_PULLUP);
pinMode(lock, INPUT_PULLUP);
pinMode(sens, INPUT_PULLUP);
pinMode(13, OUTPUT);

lockState = digitalRead(lock);
partyState = digitalRead(PartyPin);
}
void loop(){
oldloop();

boolean val1 = digitalRead(lock);
delay(5);
boolean val12 = digitalRead(lock);
if (val1 == val12) {
if (val1 != lockState) {
if (val1 == LOW && digitalRead(sens)==close) {
state = !state;
flagSerialSent=0;
}
}
lockState = val1;
}

if(digitalRead(sens) == open && state == close && flagNeovlasten == 1){
Serial.println(44776);
flagNeovlasten=0;
flagSerialSent=0;
ALARM=1;
}
if(digitalRead(sens) == open && state == open && flagSerialSent == 0){
Serial.println(44777);
flagSerialSent=1;
ALARM=0;
}
if(digitalRead(sens) == close && state == close && flagSerialSent == 0){
Serial.println(44778);
OFF();
flagSerialSent=1;
flagNeovlasten=1;
ALARM=0;
}
if(digitalRead(PartyPin)==0 && state == open && partySerialSent == 0){
Serial.println(44779);
partySerialSent=1;
}

if(digitalRead(PartyPin)==1 && state == open && partySerialSent == 1){
Serial.println(44775);
partySerialSent=0;
}

if(ALARM){
mySwitch.send(5592337,24);
delay(100);
mySwitch.send(5592340,24);
delay(100);
}

}

void serialEvent(){
dataString=””;
while(Serial.available() > 0){
char c = Serial.read();
dataString += c;
delay(10);
}
if(dataString.startsWith(“ON”)) ON();
else if(dataString.startsWith(“OFF”)) OFF();
else if(dataString.startsWith(“ALARM1″)) ALARM=1;
else if(dataString.startsWith(“ALARM0″)) ALARM=0;
else if(dataString.startsWith(“UNLOCK”)) state=open;
else if(dataString.startsWith(“LOCK”)) state=close;
else if(dataString.startsWith(“A”))mySwitch.send(5588305,24);
else if(dataString.startsWith(“a”))mySwitch.send(5588308,24);
else if(dataString.startsWith(“B”))mySwitch.send(5591377,24);
else if(dataString.startsWith(“b”))mySwitch.send(5591380,24);
else if(dataString.startsWith(“C”))mySwitch.send(5592145,24);
else if(dataString.startsWith(“c”))mySwitch.send(5592148,24);
else if(dataString.startsWith(“D”))mySwitch.send(5592337,24);
else if(dataString.startsWith(“d”))mySwitch.send(5592340,24);
else if(dataString.startsWith(“E”))mySwitch.send(1394001,24);
else if(dataString.startsWith(“e”))mySwitch.send(1394004,24);
}
void ON(){
mySwitch.send(5588305,24);
mySwitch.send(5591377,24);
mySwitch.send(5592145,24);
mySwitch.send(5592337,24);
mySwitch.send(1394001,24);
}
void OFF(){
mySwitch.send(5588308,24);
mySwitch.send(5591380,24);
mySwitch.send(5592148,24);
mySwitch.send(5592340,24);
mySwitch.send(1394004,24);
}

TPLINK TLWR703N & OPENWRT

Don’t forget to assign static ip addresses to the router and any pc you want to control.

First thing you need to do is to install usb basic support and then add an extroot to your device, and install usb video support , mjpg-streamer. This will turn your webcam into a cheap IPcam.

Next you need to install drivers for the Arduino with

opkg install kmod-usb-serial-ftdi

And if you are using Duemilanove or Arduino Uno

opkg install kmod-usb-acm

If you are using PL2303 based USB/serial adapters

opkg install kmod-usb-serial-pl2303

If you are using CP201x based USB/serial adapters

opkg install kmod-usb-serial-cp210x

Insert your Arduino and verify that its recognised with

dmesg | grep -i usb

you should get a response that looks like FTDI USB Serial now attached to /dev/ttyUSB0, and if it is you can try it by opening serial communication:

cat /dev/ttyUSB0 &

and send a command manually with:

echo -n “ON” > /dev/ttyUSB0

That should turn all of your 433 RC switches on.

Repeate check for your USB-UART TTL adapter with your dalas one wire sensor, it should be on /dev/ttyUSB1 or something similar.

Add aliases for the two devices so that they don’t mix up on reboot.

Edit /etc/rc.local so that it opens two way communication with the Arduino on every reboot:

vi /etc/rc.local

Press i for insert and add:

cat /dev/arduino > /tmp/serial.txt &
exit 0

You also need to enable ssh public key communication between the router and the always on pc, or any other pc via dropbear so the script can send ssh commands.

Save and exit with esc , ZZ.

Next we are going to make our service named secsysd, so open secsysd with:

vi /etc/init.d/secsysd

Enter i for insert,
Review the script, enter custom ip address feeds,apykay & paths.Paste it and save it with esc, ZZ.

secsysd:

#!/bin/sh /etc/rc.common

START=91

start() {

#serial.txt is writen from rc local
# >>> /etc/rc.local cat /dev/arduino > /tmp/serial.txt
#variable 1: tail -n 2 /tmp/serial.txt | cut -f2 > /tmp/row.txt & sleep 2

#open.sen.se
apikey= #your apikey

#FEEDS, enter yours:
OPEN=44777
CLOSED=44778
INTRUDER=44776

SERVERIP= #your always on pc local ip address
ROUTERIP= #This routers static ip goes here
#replece feeds with yours from open.sen.se
VARO=”EMPTY”

while [ 1 ]
do

TXTSIZE=$(ls -al /tmp/serial.txt | cut -f 5 -d ‘ ‘) #(limiter 5 polje je varijabla)
LIMIT=100000

VARN=$(tail -n 2 /tmp/serial.txt | cut -f2)

if [ "$VARN" != "$VARO" ]
then
TEMP=$(digitemp_DS9097 -a -q -o”%.2C”)
echo $VARN
curl ‘http://api.sen.se/events/?sense_key=’$apikey -X POST -H “Content-type: application/json” -d ‘[{"feed_id": '$VARN',"value": '$TEMP'}]‘

if [ "$VARN" -eq "$INTRUDER"]

then echo INTRUDER
ssh -f root@$SERVERIP -i /etc/dropbear/dropbear_rsa_host_key “sh -c ‘nohup wget -O Dropbox/video.mjpg http://$ROUTERIP:8080/?action=stream > /dev/null 2>1 &’”
ssh -f root@$SERVERIP -i /etc/dropbear/dropbear_rsa_host_key “sh -c ‘nohup mplayer /home/labos/intruder.mp3 > /dev/null 2>1 &’”
fi

if [ "$VARN" -eq "$CLOSED" ]
then
echo CLOSED
ssh -f root@$SERVERIP -i /etc/dropbear/dropbear_rsa_host_key “sh -c ‘nohup killall mplayer & nohup mpc stop > /dev/null 2>1 &’”
ssh -f root@$SERVERIP -i /etc/dropbear/dropbear_rsa_host_key “sh -c ‘nohup killall wget && nohup ffmpeg -framerate 5 -i Dropbox/video.mjpg Dropbox/video/upad_$(date +”%d.%m.%H:%M:%S”).mp4 > /dev/null 2>1 &’”
fi

if [ "$VARN" -eq "$OPEN" ]
then
echo OPEN
echo -n “ON” > /dev/arduino
ssh -f root@$SERVERIP -i /etc/dropbear/dropbear_rsa_host_key “sh -c ‘nohup killall wget & nohup killall mplayer > /dev/null 2>1 &’”

ssh -f root@$SERVERIP -i /etc/dropbear/dropbear_rsa_host_key “sh -c ‘nohup mpc play > /dev/null 2>1 &’”
fi

fi

if [ "$TXTSIZE" -gt "$LIMIT" ]
then
rm /tmp/serial.txt
fi

VARO=$VARN

done
}

Enable and start the service with:

/etc/init.d/secsysd enable && /etc/init.d/secsysd start

OPEN.SEN.SE
sustav 5
If you ask open.sen.se for an invite , they will send it to you in a day or two.

login
click:

Channels>add channel>Arduino & other…>Get started>
>Name your device:open (you’ll need two more devices closed, unauthorized)
> Device is: Arduino based
>Description: lock-open-feed

>Sending data: http posting
>Save and continue

>Name this feed: Door open
>Which way does your feed go: Input
>What type of data will be flowing in this Feed: Other…
>Save feed
>Finish
Note and save the Input feed number. For exsample mine now is: #52060

Then click:
Applications>Messengers & Notifiers and install Tweet it
> 1 Choose data source: open
> 2 Create a tweet template:
“%DATE %TIME Door unlocked, temperature upon unlock was %VALUE °C!”

> 3 Save settings under the name: door unlocked

> Save and continue
> Complete installation
>Connect to twitter #you need to be logged in to twitter on the brawser.

in popup click:
>Authorize app

Do that for closed,unauthorised and any custom feeds you need.And that’s it!

433Mhz RC switches
sustav4

We used the model:RCS1000N RC switches from brennenstuhl,so if you want to be sure that they work with the arduino code buy this model, otherwise edit their codes in the arduino code.

USB aliases – Multiple Arduinos on an OpenWRT device

dev
If you want to add multiple Arduino or other USB to UART devices to your Openwrt router you will need to symlink them so that the devices don’t mix up while the router reboots.

Our objective is to symlink /dev/ttyUSB0, /dev/ttyUSB1 … to /dev/device0, /dev/device1… In our example we will use a setup with an USB 2.0 hub, and an Arduino. USB 2.0 hub solves a bug in the usb 1.0 connection between the arduino and OpenWRT.
First we need to find out idVendor,idProduct and bcdDevice for each connected device, we can do that with “lsusb -v”:

idVendor 0×0403 Future Technology Devices International, Ltd
idProduct 0×6001 FT232 USB-Serial (UART) IC
bcdDevice 6.00

The first zeros are ignored and we use:

PRODID=”403/6001/600″

And this is the whole script:

PRODID=”403/6001/600″
SYMLINK=”arduino”

if [ "${PRODUCT}" = "${PRODID}" ];
then if [ "${ACTION}" = "add" ];
then
DEVICE_NAME=$(ls /sys/$DEVPATH | grep tty)
if [ -z ${DEVICE_NAME} ];
then logger -t Hotplug Warning DEVICE_NAME is empty
exit

fi
logger -t Hotplug Device name of cp210 is $DEVICE_NAME
ln -s /dev/$DEVICE_NAME /dev/${SYMLINK}
logger -t Hotplug Symlink from /dev/$DEVICE_NAME to /dev/${SYMLINK} created
fi

fi
if [ "${PRODUCT}" = "${PRODID}" ];
then if [ "${ACTION}" = "remove" ];
then rm /dev/${SYMLINK}
logger -t Hotplug Symlink /dev/${SYMLINK} removed
fi

fi

You need to save the scripts under /etc/hotplug.d/usb/. Script names dictate the execution order so name them in this way: 20-arduino1 30-digitemp…

there is one more thing you need to enable executing the scripts: In /etc/hotplug2.rules, remove ‘^’ before ^usb$ and restart the router:

vi /etc/hotplug2.rules

$include /etc/hotplug2-common.rules

SUBSYSTEM ~~ (^net$|^input$|^button$|usb$|^ieee1394$|^block$|^atm$|^zaptel$|^tty$) {
exec /sbin/hotplug-call %SUBSYSTEM%
}

DEVICENAME == watchdog {
exec /sbin/watchdog -t 5 /dev/watchdog
next-event
}

reboot&exit

And now you should have /dev/arduino ready for use!

#labOS u “novom” prostoru :)

Hi geeks,

nakon kratkog ljetnog predaha i ljetno-jesenske selidbe WE ARE BACK !  ;)

Za one koji do sada nisu upoznati, nakon godinu dana aktivnog djelovanja/stvaranja/druženja, dobili smo novi prostor na korištenje !!! Da, da … Od sada prostor koristimo samo mi (ne moramo ga više djeliti sa ostalim grupama) u sklopu Zajednice tehničke kulture aka. Dom tehnike.

labos_panorama

#labOS – New generation

Ulazak kroz glavni ulaz u zgradu -> okret na lijevo -> lagano do kraja hodnika -> zadnja vrata sa lijeve strane = #labOS

See ya ASAP …

Radionica “Osnove 3D modeliranja” u Osijeku

U vremenu od 04. do 05. svibnja 2013. godine #labOS hacklab i Dom tehnike organiziraju dvodnevnu radionicu “Osnove 3D modeliranja”. Radionica se temelji na Blenderu, slobodnom i otvorenom 3D programu za modeliranje, UV razmatanje, teksturiranje, simuliranje, animiranje, compositing, kreiranje tekstura i skeleta, kreiranje interaktivnih 3D aplikacija, video editiranje i dr.. Blender se može koristiti na različitim operativnim sustavima od Linux-a i Microsoft Windows-a, preko Mac OSX-a do OpenBSD-a

Radionica će se održati u Osijeku od 04. do 05. svibnja u prostoru Doma tehnike (2. kat) u Tvrđi prema sljedećem rasporedu:

Prvi dio – subota 04. svibnja 2013., od 10:00 do 14:00 sati i od 16:00 do 20:00 sati: osnove rada u Blenderu (upoznavanje s radnim sučeljem, osnove modeliranja, vizualno upravljanje objektima);

Drugi dio – nedjelja 05. svibnja 2013., od 10:00 do 14:00 sati i od 16:00 do 20:00 sati: naprednije funkcije u Blenderu (bojanje, renderiranje, osvjetljenje, animiranje).

Cilj je ove radionice upoznati sve zainteresirane za 3D tehnologije, kao i (buduće) stručnjake u tom području, s osnovama rada u Blenderu te svim grafičkim mogućnostima i prednostima koje isti pruža u području 3D grafike.

Kotizacija za pohađanje dvodnevne radionice iznosi 200,00 kn.

Prijave se zaprimaju na sljedećoj stranici – http://bit.ly/blender-2013 (Prijave su obvezne zbog organizacije prostora i materijala).

Sudionici radionice trebaju donijeti (prijenosno) računalo s već instaliranim Blenderom ili iznajmiti laptop.

Predavači
Tomislav Čorak i Miroslav Brozović.

Miroslav Brozović dolazi iz Zagreba. U Blenderu radi preko 7 godina, a 3D tehnologijama bavi se već 10 godina. Danas djeluje kao suradnik na raznim 3D projektima te organizira i drži mnogobrojne radionice i predavanja.
Neki od projekata na kojima je radio:
Sony-AVC reklama na Motovun film festivalu 2008:

Red bull soapbox 2009 video prezentacija:

Suradnja na Iron Maiden reklami:

Nekomercijalna 3d igra:

http://www.blendernation.com/2007/09/12/game-m84/

Tomislav Čorak dolazi iz Vinkovaca. U slobodno se vrijeme bavi računalnom grafikom. Blender koristi već 6 godina za izradu vizualizacija, animacija, ilustracija i dizajn te aktivno sudjeluje u razvoju i promociji Blendera.

Za sve dodatne informacije obratite nam se putem e-pošte – info@linux-osijek.org

RTL-SDR: Softverski Definirani Radio za manje od 100kn

433 cap 433Mhz test
USB DVB-T prijemnici koji su utemeljeni na tehnologiji RTL2832U čipa mogu se koristiti kao jeftini softverski definirani radio s kojim je moguće hvatati sve od meteoroloških stanica, satelita ili GPS-a, pa sve do ham radio prijenosa sa međunarodne svemirske postaje. Na slikama je moguće vidjeti dio signala za daljinsko upravljanje električnim instalacijama na 433 MHz koje planiramo reproducirati preko Arduina i TP-link tl-wr703n routera.

SDR je sustav u kojem su komponente implementirane u softver umjesto tradicionalne hardverske izvedbe. RTL-SDR dopušta pregledavanje velikog dijela VHF i UHF frekvencija od 52 MHz do 2,2 GHz.

Iako je RTL-SDR sjajna alatka za hvatanje širokog spektra radijskih frekvencija, važno je napomenuti da zakon o elektroničkim komunikacijama zabranjuje slušanje, korištenje i prosljeđivanje sadržaja radijskih poruka ne namijenjenih javnosti.

Za detaljnije informacije i popis podržanih uređaja pogledajte rtl-sdr – OsmoSDR.