Portable Webcam Hardware - hardware+os
Okay, so we know that the webcam project works in Raspberry Pi. The next step is to bring out the portability of the device. So, we'll be making a portable Deer Camera project. Which is basically just a box with a camera on it. Because we're using Raspberry Pi, we can have all the features we want. So here's the shopping list:
Raspberry Pi B : $40
Case : $9
16 GB SD card: $12
ASUS N150 Wifi: $20
Add webcam for $10, and battery pack for $50, and we'd have spent about $140 total. The battery pack is really the expensive option, and I'm sure the more creative among you can get it cheaper. I'm just using the common iphone charger. Which turns out to be a mistake. I don't have a solution for this yet, but one potential solution that you can consider would be to get a 12V car battery, hook it up with cigarrete lighter to phone charger, and into the raspberry pi. We still need lights to see, but I'm leaving it out for now.
I'm thinking that the Raspberry Pi model A would be better. However, this being my first experiment, I decided to keep it simple and simply copy the OS from my desktop computer. It works! So, the next step is to create a copy from scratch and install it SSH way. Big problems.
First, format a 16 GB SD card and copy NOOBS into it. Assemble the hardware. I'm pilfering the HDMI, keyboard, mouse, and power supply from my desktop Raspberry Pi for setting it up. Booting NOOBS over it, I'm setting it up this way:
- GUI off
- SSH on
- Set locale+keyboard
- set wpa_cli
- set hostname
Pull out keyboard. Reboot. SSH into it. So far so good. Half hour since I first started. I assembled the hardware already. Here is the final desired setup:
Problem. There is no connection to the network. Obviously, the /etc/network/interfaces is faulty. All attempts to fix it failed. I look for instructions. All instructions involved putting in a GUI in order to set it up. I frantically searched for instruction to set up the network without GUI. Couldn't find it. So, 2 hours later, I'm back to square one, and booted up the GUI version. It works no problem.
Sigh. Since I'm being stubborn, I want to know what action items behind the scenes are necessary in order to put up the network via CLI interface, instead of GUI interface. So, I remove everything. And after a long and arduous search on the internet, with a good deal of experimentation on my own, I finally came up with this:
- wpa_cli (starts in interactive mode)
- -scan (wait until WPA-AP-AVAILABLE)
- -add_network (returns network#)
- -set_network 0 ssid "MyNetworkName"
- -set_network 0 psk "password"
- -enable network 0
Once you quit, you do these commands (instruction from the internet, I don't understand this):
- sudo ifdown wlan0
- sudo ifup wlan0
- ip addr
So, those are the commands that comes from instruction gleamed from the internet. Don't ask. I don't know the answer.
Reboot into SSH. Success! Well, not really (Siiiiiigh!!!). I ran into the message "Remote Host ID has changed". Something about man-in-the-middle attack. So, back into the last set up. Erase all keys. Reboot into SSH. Success, finally.
So now I have a Wifi and webcam into both USB plugs, and everything is just peachy. Time to install the software
- sudo apt-get update
- sudo apt-get upgrade
- sudo apt-get motion mplayer fswebcam
We want to do it real quick to see if the set up works:
- fswebcam -r 640x480 sample.jpg -D 15 -fps 1
- fswebcam 0l 1 --save pic%a%S.jpg
- rsync webcampi:/home/pi/pic*.jpg
After entering the password, I downloaded the file into the desktop pi, and use gpicview to see it. Success!
Phew. Finally done.
Next step, we need to configure motion software so the server daemon would be running at reboot. But that's topic for another time.