Now on to the hardware for the wifi webcam. I wanted to keep the whole “remote webcam” portion of the monitoring system under $75.
The heart of the wifi webcam is the Seagate Dockstar, which has been heavily modified. The following hardware mods have been done to the Dockstar: A serial debug header, a micro SDHC card slot, missing RTC parts, internal 802.11b/g wifi, and CPU heatsink. The only external piece of hardware is a plain old webcam.
Here’s the modified Dockstar:
The serial header has been added so that the bootloader, linux system in NAND, and linux system on the micro SDHC card could be changed. It also comes in handy for figuring out what IP address the device is using without having to log into the router to see what DHCP lease was assigned to the device.
The micro SDHC card allows for fast internal storage of the whole operating system (debian squeeze). Luckily Seagate was kind enough to expose all the necessary pins for the SDHC controller on the Kirkwood. Using some reverse-engineering done by some guy called MindSmith at this forum: http://plugapps.com/forum/viewtopic.php?f=6&t=258 and some of my own knowledge, putting a micro SDHC card on the Dockstar was pretty easy. The only “hard” part was modifying an already modified version of U-Boot to make it support booting from a SD/MMC card. More on that in another post….
Also in the link above are the locations for where necessary connections are to enable the RTC in the Dockstar. I theived some 32.768KHz crystals from junk boards I had lying around, grabbed some 15pF caps for loading the crystal, and ended up having to buy some 33pF caps and 10M-ohm resistors (the resistor is used for oscillator feedback….basically speaking). Since I had no idea what the part number was for the crystal I used, I had to guess on the load caps. Usually 15pF-ish is plenty to load it, but when booting Linux, the debug output kept saying the RTC was not ticking. Strangely putting a scope probe on the crystal’s lead made it start oscillating. Usually putting the probe on the lead makes the crystal stop oscillating due to the extra load the probe puts on the crystal. I could actually see the crystal start after I put the probe on. So I increased the load cap from 15pF to 33pF and everything was fine. I also added the lowest Vf/cost schottky diode and 1F super cap with the lowest ESR/cost for RTC power backup. I ended up finding a suitable diode for < $1, and a nice low ESR supercap for under $3. I had a 0.47F cap w/ a ESR of about 350 ohms, but as I found out a few years back here at work, that ESR translates into an immediate drop of capacitor voltage when main power is removed. Simply put, the lower the ESR, the lower the immediate drop of capacitor voltage. The ideal supercap was this Aerogel capacitor whose ESR is under an ohm, but the thing is physically large and expensive. The cap I found has an ESR of about 2 ohms and is fairly small (it’s max working woltage is only 2.7V, which keeps the cap small). The other thing w/ the low ESR is the large inrush current needed to charge the cap. When the cap is empty, it looks like a resistor to ground when power first gets to the cap. Obviously the lower the resistance of this resistor (the cap’s ESR), the larger the inrush current is. With a 2 ohm ESR, that looks almost like a short to ground to the power supply (initially anyways). I hoped the Dockstar supply could provide a quick shot of ~900mA (1.8V/2 ohms) to the cap the 1st time it’s powered. I also had to find a diode that had a low forward voltage drop, while allowing sufficient continuous current to pass through it without blowing up. Unfortunately, these two parameters are mutually exclusive. In other words, the lower the forward voltage drop of the diode, the lower the continuous current it can handle, and the more current you want to pass through the thing, the higher its forward voltage drop. I found a suitable diode with a low Vf and sufficient surge current handling ability. The diode I chose was a STMicro STPS0520Z and the cap I chose was a Nichicon JUMT1105MPD. The purpose of the diode is to allow current to pass to the capacitor and power the RTC’s power pin, but block current from flowing back into the system depleting the capacitor’s charge very quickly. The Marvell reference schematic shows a 1.5V watch battery powering the RTC, but the cap solution is cheaper and easier to hack into the dockstar with the downside of less backup time. I just needed a little time to backup the RTC in case power is lost quickly. The default date may cause the EXT3 filesystem to not mount if the current date is older than the journal creation date. I don’t know how true this is….but still, the RTC works. Yay!
The internal wifi needed to be a dirt cheap USB wifi adapter that was already supported by linux and could authenticate using WPA (this is a software thing rather than hardware actually…) A suitable adapter was found that has the Realtek RTL8187B USB chipset onboard: RNX-G1LX This turned out to be really easy to hack an external antenna on as the case of the dockstar has a tin shield lining the inside of it, thus blocking any internal RF (although I don’t think this shield will help w/ EMI too much as there’s too many ways EMI can escape out of the box). Plus stripline antennas (antennas etched on the PCB) perform poorly at long distances from the access point. This enables me to use an antenna with a little gain so that I can use the wifi over 100 feet from the access point and through multiple walls. Basically to mod this, I removed the trace that goes to the stripline antenna and put a U.FL connector on the PCB instead. The series capacitor was left in circuit though. I had some U.FL to RP-SMA pigtails from a previous idea that I never used, so those worked well. The RP-SMA jack is mounted on the side of the Dockstar. I also had to remove the USB jack from the wifi card and cut the etched antenna off so the PCB would fit inside the Dockstar. The Dockstar has an internal USB port, so the wifi card is connected to that. Linux detected the card right away, and after a little screwing around, it connected easily to the access point using WPA (by means of wpa_supplicant).
Lastly, I added a small aluminum heatsink to the Dockstar’s CPU as it tends to run a tad hot. One of my Dockstars is destined for the garage, which gets pretty toasty in the summer. Anything to keep the heat down inside the Dockstar will be helpful. This heatsink was cut from a larger heatsink (actually I cut 4 heatsinks from a single heatsink I had that was short enough to fit in the Dockstar case).
For the webcam, I needed something that had a resolution over 640×480, good low-light performance, was relatively small, and most importantly, dirt cheap. I initially tested a Logitech C200 which doesn’t meet any of my requirements except physical size. Its max resolution of 640×480 was crappy at best, low-light performance wasn’t great, the manual focus was a pain, and $20 was expensive for this in store. However, it did serve to prove out my concept before springing on webcams that would meet my requirements. The biggest plus to the C200 from Target was that it was easily returnable =). I finally settled on a used Logitech C500 It supposedly has good low-light performance, good max resolution (granted not at 30fps, but I don’t need 30fps for watching doors), auto-focus, and best of all, they were $13 each, shipped (I bought 4). The low-light performance still isn’t superb, but I may be able to make it infrared capable (a filter inside the camera needs to be removed so it can see in IR). Other than that, the cameras have been excellent. I can also steal the camera for use on Skype if I want to. The thing looks really nice over Skype actually.