|
|
| Line 18: |
Line 18: |
|
| |
|
| Pelican case ordered. | | Pelican case ordered. |
|
| |
| ===Camera LED (No Success)===
| |
|
| |
| I tried unsuccessfully to set the camera LED state from Python script:
| |
|
| |
| <pre>
| |
| import picamera
| |
| camera = picamera.PiCamera()
| |
| print camera.led
| |
| camera.led = False
| |
| </pre>
| |
|
| |
| According to the help page for the camera object, <code>help(camera)</code>, this attribute is supposed to control the camera. I also read you had to be root, so I also tried doing this as root by running Python via sudo:
| |
|
| |
| <pre>
| |
| $ sudo python
| |
| >>> import picamera
| |
| [...]
| |
| </pre>
| |
|
| |
| No success there. The LED light would come on once I had created the camera object, and would not turn off by setting the led attribute to False.
| |
|
| |
| ===Camera LED (Success)===
| |
|
| |
| To turn off the camera LED, you can edit the file <code>/boot/config.txt</code> and add a directive to turn off the camera board's LED. Add the following to the top of the file:
| |
|
| |
| <pre>
| |
| # disable the camera led
| |
| disable_camera_led=1
| |
| </pre>
| |
|
| |
| Reboot will be necessary, but once you do that, there will no longer be an annoying glaring red LED every time the camera is on and talking to the computer!
| |
|
| |
| ===USB Flash Drive===
| |
|
| |
| Plug in 64 GB flash drive.
| |
|
| |
| To mount and make readable/writable by default Pi user, start without the jump drive plugged in. Run this command to monitor hardware that is plugged in:
| |
|
| |
| <pre>
| |
| tail -f /var/log/messages
| |
| </pre>
| |
|
| |
| Plug in your USB drive. It should probably be called <code>/dev/sda1</code>. Once you know the name of the device, you can mount it to a folder (which must exist ahead of time):
| |
|
| |
| <pre>
| |
| sudo mount -t vfat -o uid=pi,gid=pi /dev/sda1 /home/pi/timelapse
| |
| </pre>
| |
|
| |
| Test that you can indeed make stuff in the new jumpdrive:
| |
|
| |
| <pre>
| |
| cd /home/pi/timelapse
| |
| touch file
| |
| </pre>
| |
|
| |
| Hooray! Now move all the scripts there:
| |
|
| |
| <pre>
| |
| cp /somewhere/else/lapse.py .
| |
| </pre>
| |
|
| |
| Here's that lapse.py script again:
| |
|
| |
| <pre>
| |
| import picamera
| |
| from datetime import datetime
| |
| import time
| |
| import os
| |
|
| |
| camera = picamera.PiCamera()
| |
|
| |
| lapse_dir = datetime.strftime(datetime.now(),"timelapse_%Y%m%d-%H%M%S")
| |
| os.system('mkdir '+lapse_dir)
| |
|
| |
| ###print "Don't forget - to turn off the LED - run this as root!"
| |
| ###camera.led = False
| |
|
| |
| while True:
| |
|
| |
| prefix = datetime.strftime(datetime.now(),"%Y%m%d-%H%M%S")
| |
| filename = lapse_dir+"/"+prefix+".jpg"
| |
|
| |
| camera.capture(filename)
| |
| print "Saving photo to %s"%(filename)
| |
|
| |
| time.sleep(2)
| |
| </pre>
| |
|
| |
| ===Serving Up Photos===
| |
|
| |
| To serve up the photos, SSH into the Pi, and cd to the directory where the photos are located. Start a screen session by running the <code>screen</code> command. Now run a Python simple HTTP server by running the command:
| |
|
| |
| <pre>
| |
| $ python -m SimpleHTTPServer 8080
| |
| </pre>
| |
|
| |
| Now the directory of photos from the Pi camera should be accessible at the Pi's IP address, port 8080. For example, if the Pi is at the IP 192.168.0.111, then the photos can be viewed by pointing a browser (also on the local network, of course, along with the Pi) to the address:
| |
|
| |
| <pre>
| |
| 192.168.0.111:8080
| |
| </pre>
| |
|
| |
| This is typed into the browser, and the files in the directory are served up by the Python simple HTTP server.
| |
|
| |
|
| ==Finished== | | ==Finished== |