Connecting a WebCam
Since I haven’t connected a keyboard and mouse to my Pi, so that only one USB port was occupied with a wireless adapter, I decided to connect a Logitech C510 HD webcam which I had lying around. I tried to to capture a live-stream in order to place it onto this page, but it turned out, that this requires much more DSL bandwidth than I currently have. Thus, I decided to grab single frames each 5 minutes with fswebcam. The images are stored as JPG files in a subdirectory on the SD card, are labeled with a timestamp and converted into thumbnails using ImageMagick’s convert program. The WebCam is pointing onto the street in front of my house. Update: Meanwhile I migrated to pygame/opencv to grab single frames, because fswebcam frequently caused the webcam to fail.
Measuring light conditions
After taking some test shots with my Logitech C510 HD webcam, I soon realized that it required some exposure adjustments according to current light conditions. Most webcams are optimized for indoor use. As a consequence, pictures taken through the window are often overexposed in bright sunlight and underexposed during night. Therefore, I wanted to make my RasPi light-sensitive. Photoresistors (light-dependent resistors, LDR) provide simple means to achieve this. However, the RasPi lacks analog input pins. On the Adafruit Learning System one can find a tutorial how to do analog measurements without using an analog to digital converter (ADC), but this method is based on measuring the length of time to (dis)charge a capacitor, which is dependent on system load and therefore not that accurate. With an ADS1015 analog to digital converter, one can add up to 4 single input channels. Wiring is achieved via I2C, so that GPIO pins (SCL, SDA) can be shared with other I2C devices. For analog read-out, the LDR is placed into a voltage-divider circuit (as R1 or R2), with Vout connected to the A0 input pin of ADS1015.
Instructions to convert voltage readings to light-intensity (LUX) can be found on this page.