Showing posts with label wifi. Show all posts
Showing posts with label wifi. Show all posts

Tuesday, December 3, 2013

Raspberry Pi Journal #39


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

Total: $81.

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:


  1. GUI off
  2. SSH on
  3. Set locale+keyboard
  4. set wpa_cli
  5. 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:


  1. wpa_cli (starts in interactive mode)
  2. -scan (wait until WPA-AP-AVAILABLE)
  3. -scan_result
  4. -add_network (returns network#)
  5. -set_network 0 ssid "MyNetworkName"
  6. -set_network 0 psk "password"
  7. -enable network 0
  8. -save_config


Once you quit, you do these commands (instruction from the internet, I don't understand this):


  • iwconfig
  • 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


check it


  • 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.

Monday, August 26, 2013

Raspberry Pi Journal #11

The Making of Cigar Box Computer

It was a long time ago where I saw a smallish motherboard computer that somebody suggest would make a great cigar box computer. I passed on that kit, but I always wondered if I should have it someday. Computer processing power is just such a tremendous amount, that most of it is wasted. I've always wanted a small, cheap and rather underpowered computer to do my daily web surfing and working.

For a time, I use a Kindle Fire HD with bluetooth keyboard. It's just such a neat little device, and I've used that successfully for my Nanowrimo activities. Enter the Raspberry Pi. After waiting for a great while, I finally managed to locate a Raspberry Pi and proceeded to go to the local thriftshop and look for some empty boxes.

I picked up a wooden cigar box for $1.49. It comes complete with wax paper and a square wooden rod. Perfect! Well, not really. I needed some holes for cables on the back. Out comes the drill. I drilled a series of holes in the approximate shape, followed by some shavings with my trusty swiss army knife. Done.


I got my Raspberry Pi from element14. This was before sparkfun got a massive dose of Raspberry Pi. As I write this, I saw some kit, along with the new camera at Microcenter. I will have to revisit the store and get another one. I'll be running headless on that one. 

You can see the cigar box in the back, along with my $250 32inch HDMI flat screen.


You can see the holes on the back. A big one for USB cables on the left, and a small round one on the right. At one time, the drill slipped and I drilled my hand. Ouchie. That's when I decided pulling out my knife would be better. The sharp swiss army knife turned out to be an easy way to make holes.


I'm using Gigaware USB 2.0 Desktop Hub. I also have a USB 3 Hub, but that one didn't work. I routed the power cable through the small hole. That power cable comes from my old multi switch device. I connected it on the "computer" switch.


I connected one of the USB output from the hub into the micro USB to power the Raspberry Pi. It's okay to do this because the power micro USB connector does not contain data pin. Only power pins. This way, whenever I turn on the USB hub, I turn on the Pi. Very convenient.

For data, I still need to connect the USB data cable from Raspberry Pi to the hub. I used the bottom USB connector and into the hub.


I use Logitech n400 Wireless keyboard with Pad. It's really light and convenient. It takes some practice, though. Took me two weeks to get comfortable with it. The dongle has some kind of USB extension. I simply put it in. It has quite a nice range. I'm really happy with it, especially since it works right out of the box.



I plugged in male to female USB cable. I knew I will put the box in out of the way place, so in order to conveniently plug in memory card/flash drive, I use this extension.



This is Belkin n150 USB Wifi Adapter. I simply pick one off the shelf, the cheapest kind I could find. I probably should have visited microcenter store, because the last time I was there, I saw some really tiny ones that would not crowd the USB plug.



And there it is, the final box incarnation. Everything fits in perfectly, with the wooden rod placed so that the Pi does not shift in the box. Plenty of space to wound the cables in. The micro USB power connector eventually broke off, leaving just a bare wire. I managed to squeeze the plastic together, but I will have to watch out for it. It happens every time I replace the SD card.



This is my SD card to USB converter. It's very convenient to use. I also have USB flash drive with lots of capacity. I don't know about the transfer rate, but for medium movie files, it works great.




Speaking of movie files, I have an old Flip video recorder. Remember those? It was a cute way to record movies. I plugged in the Flip into USB connector, and the Pi autodetect the device. For a time, I use this:

lxterminal -e omxplayer -o hdmi filename

but later on, the sound went all out. I never did managed to fix it without it blanking the screen, and I don't want to have to reset the frame buffer every time. So, eventually, I gave up and used media player instead. mplayer works great with framedrop feature. I'm pretty happy with it.

So there you have it: My very own cigar box computer. I love it so much, especially considering that the Pi does not draw much power, and neither does the TV. The TV was rated to cost $6 per year. Interesting, eh? I wonder how they come up with that?