Monday, June 17, 2013

Next Steps - The Future of Home Security

Okay, we're able to take a picture of our home every minute using a cron job (pi, not root) and we're able to view that picture from 1500 miles away through a WRT54G that only allows SSH (thanks Cox!) on our smartphone using ftpCafe.

Next, we need an alert on our phone when 2 images differ substantially - a txt is fine.

The "hard" part here is the image processing - how do you detect that 2 images differ substantially? Sending the txt is easy - twilio has taken care of that.

BTW, once you validate a phone number with twilio, how do you invalidate?

Resources : twilio, ffmpeg, motion, fswebcam, avconv

http://portforward.com/english/routers/port_forwarding/Linksys/WRT54G/HTTP.htm

Thursday, June 13, 2013

Cheezy Pi Based Home-Security System

1) $5 web cam from Frys + $15 (Patriot) Wirelsss USB adapter (8188CU)
2) wlan0 should work right away. Ensure you have the right hookup in your /etc/network/interfaces based on your WiFi setup - most of the online examples say WPA - but, it might well be ESSID - WEP.
3) Install fswebcam if it's not there already. I'm on Wheezy, don't remember
4) Test the camera using fswebcam - you should easily be able to dump to a file.jpg

5) Insert (crontab -e) a cron job to reboot every N hours based on your experience with the wlan0 - mine quit after a few hours. This will be a root crontab entry - > sudo crontab -e ... and then "0 0-23/2 * * * /sbin/reboot"
6) Insert a pi-user cron task to take the picture every so often (say once a minute) "* * * * * fswebcam "
7) In your router (192.168.1.1) forward port 22 (SSH) the IP address of your Pi's wlan0 port (which you can get using ifconfig -a). You can do HTTP also - just be warned you're wasting time trying to look at stuff through HTTP outside your router firewall.
8) Get your IP address (what the world knows you by, just enter "what's my IP address" in the Google search field.
9) Sign up with a free DNS host - like freedns.afraid.org, use this IP address you just found.

And you're done - on your smartphone, you can use ftpCafe. It's not as slick a UI as ES File Explorer, but it WORKS! And ES File Explorer just pouts!

Yes, that's cheezy - you have to browse to the folder each time and load the image, but, hey - you've got your eye on your place till something better comes along!

Next : use carriots to send an alert to your phone when the Pi detects that 2 pictures taken within a minute differ significantly!! You don't want to miss that one. Even Donald Trump's hair is on end. He calls it end of life testing.

Tuesday, June 11, 2013

Life, and Death of Pi

Runs a few hours, then loses the WiFi link. Why? Why does it need a reboot to get the wireless back? Why doesn't the router need to be reset?

From /var/log/syslog :

Jun 11 06:25:07 raspberrypi rsyslogd: [origin software="rsyslogd" swVersion="5.8.11" x-pid="1918" x-
info="http://www.rsyslog.com"] rsyslogd was HUPed
Jun 11 06:39:01 raspberrypi /USR/SBIN/CRON[3257]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime ] &&
[ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -ignore_readdir_r
ace -cmin +$(/usr/lib/php5/maxlifetime) ! -execdir fuser -s {} 2>/dev/null \; -delete)

Jun 11 12:17:01 raspberrypi /USR/SBIN/CRON[3440]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 11 12:39:01 raspberrypi /USR/SBIN/CRON[3450]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -type f -ignore_readdir_race -cmin +$(/usr/lib/php5/maxlifetime) ! -execdir fuser -s {} 2>/dev/null \; -delete)

++++++++++++++++ and then +++++++++++++

Jun 11 12:39:12 raspberrypi ifplugd(wlan0)[1603]: Link beat lost.
Jun 11 12:39:23 raspberrypi ifplugd(wlan0)[1603]: Executing '/etc/ifplugd/ifplugd.action wlan0 down'.
Jun 11 12:39:23 raspberrypi dhclient: Internet Systems Consortium DHCP Client 4.2.2
Jun 11 12:39:23 raspberrypi ifplugd(wlan0)[1603]: client: Internet Systems Consortium DHCP Client 4.2.2
Jun 11 12:39:23 raspberrypi dhclient: Copyright 2004-2011 Internet Systems Consortium.
Jun 11 12:39:23 raspberrypi ifplugd(wlan0)[1603]: client: Copyright 2004-2011 Internet Systems Consortium.
Jun 11 12:39:23 raspberrypi dhclient: All rights reserved.
Jun 11 12:39:23 raspberrypi ifplugd(wlan0)[1603]: client: All rights reserved.
Jun 11 12:39:23 raspberrypi dhclient: For info, please visit https://www.isc.org/software/dhcp/
Jun 11 12:39:23 raspberrypi ifplugd(wlan0)[1603]: client: For info, please visit https://www.isc.org/software/dhcp/
Jun 11 12:39:23 raspberrypi dhclient:
Jun 11 12:39:23 raspberrypi dhclient: Listening on LPF/wlan0/00:02:72:c3:99:74

Jun 11 12:39:23 raspberrypi ifplugd(wlan0)[1603]: client: Listening on LPF/wlan0/00:02:72:c3:99:74
Jun 11 12:39:23 raspberrypi dhclient: Sending on   LPF/wlan0/00:02:72:c3:99:74
Jun 11 12:39:23 raspberrypi ifplugd(wlan0)[1603]: client: Sending on   LPF/wlan0/00:02:72:c3:99:74
Jun 11 12:39:23 raspberrypi dhclient: Sending on   Socket/fallback
Jun 11 12:39:23 raspberrypi ifplugd(wlan0)[1603]: client: Sending on   Socket/fallback
Jun 11 12:39:23 raspberrypi dhclient: DHCPRELEASE on wlan0 to 192.168.1.1 port 67
Jun 11 12:39:23 raspberrypi ifplugd(wlan0)[1603]: client: DHCPRELEASE on wlan0 to 192.168.1.1 port 67
Jun 11 12:39:24 raspberrypi ifplugd(wlan0)[1603]: Program executed successfully.
Jun 11 12:39:25 raspberrypi ntpd[2624]: Deleting interface #2 wlan0, 192.168.1.112#123, interface stats: received=419, sent=424, dropped=0, active_time=23922 secs
Jun 11 12:39:25 raspberrypi ntpd[2624]: 199.30.140.74 interface 192.168.1.112 -> (none)
Jun 11 12:39:25 raspberrypi ntpd[2624]: 195.216.64.208 interface 192.168.1.112 -> (none)
Jun 11 12:39:25 raspberrypi ntpd[2624]: 199.7.177.206 interface 192.168.1.112 -> (none)
Jun 11 12:39:25 raspberrypi ntpd[2624]: 198.199.97.84 interface 192.168.1.112 -> (none)
Jun 11 12:39:25 raspberrypi ntpd[2624]: peers refreshed
Jun 11 12:41:31 raspberrypi ddclient[2088]: WARNING:  cannot connect to 192.168.1.1:80 socket: IO::Socket::INET: connect: Network is unreachable

+++++++++++++ it keeps trying every 5 minues +++++++++ W Goin On?

Jun 11 14:06:32 raspberrypi ddclient[2088]: WARNING:  cannot connect to 192.168.1.1:80 socket: IO::Socket::INET: connect: Network is unreachable
Jun 11 13:17:25 raspberrypi kernel: imklog 5.8.11, log source = /proc/kmsg started.
Jun 11 13:17:25 raspberrypi rsyslogd: [origin software="rsyslogd" swVersion="5.8.11" x-pid="1956" x-info="http://www.rsyslog.com"] start
Jun 11 13:17:25 raspberrypi kernel: [    0.000000] Booting Linux on physical CPU 0
Jun 11 13:17:25 raspberrypi kernel: [    0.000000] Initializing cgroup subsys cpu
Jun 11 13:17:25 raspberrypi kernel: [    0.000000] Linux version 3.6.11+ (dc4@dc4-arm-01) (gcc version 4.7.2 20120731 (prerelease) (crosstool-NG linaro-1.13.1+bzr2458 - Linaro GCC 2012.08) ) #456 PREEMPT Mon May 20 17:42:15 BST 2013
Jun 11 13:17:25 raspberrypi kernel: [    0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d


Death by Pi

Eben Upton : "I wanted to get kids interested in programming. I ended up getting them interested in reliability, dependability, failsafe mechanisms, mission-critical system-design and how to avoid crap."

Ridiculous - how do you work with something that functions okay for hours and hours and then just quits? I mean the Wi-Fi link. I had this thing watching my garage, and now, I've had to bring it in just so I can plug in the ethernet cable to debug what went wrong.

Monday, June 10, 2013

Hartmut Esslinger is Not Dead

When it comes to hooking up your Raspberry Pi to the Wireless LAN using a WiFi dongle, aka wireless USB, adapter, this post is all you'll ever need :

http://www.raspberrypi.org/phpBB3/viewtopic.php?p=151456#p151456

Who in the world is obcd anyway? Venerate him.

Long story short, all I had to do was change a couple of lines in my /etc/network/interfaces file from

wpa-ssid "name"
wpa-psd "pswd"

to

wireless-essid "name"
wireless-key "pswd"

And the damn thing just works - when I do ifconfig -a, I see a non-zero Rx and Tx bytes for wlan0!! This got my off my desk with my arms pumping. Who the heck is obcd? Why do we even allow the other idiots to post?

Shame on me though, when the Patriot RTL8188 was plugged in, it would periodically blink 6 times regularly. And, if I did

iwlist wlan0 scan

it clearly told me that my network was an ESSID. And, when I used windows to look at properties, it showed me it was WEP.

So, why was I doing WPA?

Coz I knew no better. That's why!

Technobabble is going to have to work very hard to catch up to this!

Raspberry Pi will Not do Wireless (Yet)

Interesting : in this video, when all he's done is just hook put the dongle in and boot, ifconfig -a shows that wlan0 has some Tx and Rx bytes to boast of.

In my case, both give me 0. Hmmm..

I follow the instructions in this

http://www.adafruit.com/blog/2012/09/07/how-to-wifi-wireless-internet-on-raspberry-pi-piday-raspberrypi-raspberry_pi/

tutorial, but still, when I do ifconfig -a, I see 0 for Tx and Rx bytes.


But, aha, now, when I do

iwlist wlan0 scan

I see interesting stuff..

Still, no use - if I disconnect the ethernet cable and reboot - no connection on the DHCP client list from the router.

The light on the dongle blinks intermittently - maybe it's an error code?

This post seems fairly helpful :

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=26&t=6256

Scratch all of that. All of them posts are crap, including Missus Engman.

Sunday, June 9, 2013

Eben's Backlog

He's got work to do to avoid ending up on the scrap heap like Narcissus Negroponte.

First, how about a good set of tutorials that let grown up people use the Pi, which will then send the Pi sales through the roof, generate moderate profit and thereby enable him to do truly great things for the cause of mankind?

Like?

A tutorial that shows you how to put a decent OS on your Linksys WRT54G v6 (unfortunately, the Tomato bloke decided this is too hard to support). The only one around seems to be : dd-wrt.com - which unfortunately, though it looks like it's written in English, was actually written in Spanish, then auto-translated into Finnish and then into English manually. They did their best, but I'm not sure if it's written for 21st century humans or 23rd century machines. The ultimate goal is to be able to set static IP addresses for your Pi's - so you'd know 192.168.1.105 is for the garage, 106 is for the living room, etc. You get the idea.

A tutorial that tells you how to set the default console screen size in the case of booting without a display connected - nothing at the TV port or the HDMI port.

A tutorial that tells you how to use a free DNS service (preferably one certified and endorsed by the RP Foundation) to be able to enter a meaningful URL to get to your Pi - assuming you're running a server.

A tutorial that tells you how you can use a $5 webcam to implement no-running-cost (but for the cost of your internet connection) home-surveillance. Ooops - sorry, that's my job - that's what these next few posts will be about.

A tutorial that tells you step-by-step how to get your RPi connected to your internet via a WiFi USB dongle. Sure, there are folks out there who claim that the Patriot dongle or the Whizzpup dongle work right out of the box, but, what if you go into the crazy wpa_gui deal and it doesn't see a single service though every other internet device in your house does? What if you run wpa_gui and now, though ifconfig has shown you wlan0 exists, wpa_gui doesn't show it? Eben!

A tutorial that shows you how you can work on your Raspberry Pi (that is, as if you had a keyboard and mouse and monitor connected to it), except those keyboard, mouse and monitor actually belong to your laptop and you VNC'd into your Pi by first setting up X11 forwarding on it. Fortunately for us mere mortals, Technobabble has come to the rescue : http://tech.element77.com/2013/05/remote-desktop-access-to-raspberry-pis.html