Monday, November 3, 2014

Julian's Raspberry Pi Front Door / Garage Opener install, headless, with no KB or monitor


I have put my place up for rent for short term stays. The problem is getting the key to the tenant while I am at work etc.

My building has an electronic opening secuirty gate that is hooked upto the intercoms in each apartment. A guest will buzz my number, i pickup the intercom and say hi, then hit the button on my intercom that buzzes them into the building.

So, I plan to make a raspberry pie with a relay attached to the intercom, that will open the front gate in the same way, just over the internet. I will then hook that up to a virtual button and the tenant can let themselves in to the building. When they get to my front door, I have a pin number lock. They enter the pin, they get in, and the spare key is waiting for them. Neat huh?

Step 1 - Buy and Setup the pi for SSH

Buy all the things: raspberry pie, SD card, mini USB cable for power, relay switch, wires etc

Get the debian image from here: http://www.raspberrypi.org/downloads/ (1GB approx)

Get this for windows: http://sourceforge.net/projects/win32diskimager/

Format the whoile SD card for FAT32

Unzip both downloads, then with win32diskimager put the whole image on the SD card.

This boots it with sshd running and DHCP. Plug in a network cable, look at your router for the newest IP, connect to it with an SSH client

ssh pi@yourip

u: pi
p: raspberry

So after you login... you see this

NOTICE: the software on this Raspberry Pi has not been fully configured. Please run 'sudo raspi-config'

switch to root as always...


pi@raspberrypi ~ $ sudo su -

This opened the config menu for for some reason... anywho

I select (1) to extend the root disk to take up the rest of the SD card. Then i rebooted.

When you get logged in again,,,,

Step 2 - Config

apt-get update
apt-get install node
apt-get install npm

npm config set registry http://registry.npmjs.org/
npm install forever -g


wget -O WebIOPi-0.7.0.tar.gz http://sourceforge.net/projects/webiopi/files/WebIOPi-0.7.0.tar.gz/download
tar xvf WebIOPi-0.7.0.tar.gz

cd WebIOPi-0.7.0
./setup.sh
/etc/init.d/webiopi start

http://192.168.1.118:8000/
u:webiopi
p:raspberry

yay! now you can click IN and OUT on left had side to operate gpios

git clone git://git.drogon.net/wiringPi
cd wiringPi
git pull origin
./build

yay! now you can run

gpio mode 7 out
gpio mode 7 in

to turn pin 7 on and off. in means OFF

tadaaa! finished.
mostly

edit /etc/ssh/sshd_config
add Port 8001
port forward 8001

Now change passwords

root@raspberrypi:~# webiopi-passwd
WebIOPi passwd file generator
Enter Login: pi
Enter Password: 
Confirm password:

raspi-config (option 2)

NOW WIFI!
this just worked
http://www.howtogeek.com/167425/how-to-setup-wi-fi-on-your-raspberry-pi-via-the-command-line/

Step 3 - Assemble

... to follow!

----
Set Up DNS and hide that port number!


Get a domain
mydomain.com

create an amazon s3 bucket with EXACT same name domain name, and whatever prefix
bucketname = openthegate.mydomain.com

enable Static Website Hosting on the bucket
Redirect all requests to another host name
openthegate.no-ip.biz

goto no-ip.com and create a host with the IP of your router and enable Port 80 Redirect to 8000
openthegate.no-ip.biz 54.x.x.x:8000

check the port is open here
http://www.yougetsignal.com/tools/open-ports/

create an aws route53 record set for mydomain.com
create an alias record to point to your bucket
openthegate.mydomain.com ALIAS s3-website-ap-southeast-2.amazonaws.com

copy the NS name server names
goto registrar and re-point name servers to AWS route53 DNS servers

Now when you hit the domain http://openthegate.mydomain.com
it will look up the domain, look at the zone file and see that the name servers are over at AWS
it will goto AWS, check the NS servers, see the ALIAS and goto the bucket
The bucket re-directs all port 80 requests to your no-ip record
which then points to port 8000 on your local router

Forward the ports on your router 8000 > 8000

Now it all works. HAHAHAHAHAHAHA