User Tools

Site Tools


tutorials:iotc

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorials:iotc [2012/03/12 08:48]
pburgess
tutorials:iotc [2016/01/28 18:05] (current)
Line 1: Line 1:
 ====== An “Internet of Things” Camera====== ====== An “Internet of Things” Camera======
-**Simple remote monitoring using the Eye-Fi wireless SD card and Adafruit Data Logging Shield for Arduino**+**Simple remote monitoring using a first-generation ​Eye-Fi wireless SD card and Adafruit Data Logging Shield for Arduino** 
 + 
 +===== Introduction =====
  
 The //Eye-Fi// card is a tiny wireless memory card. It stores photos and fits inside a camera just like a regular SD card, but also has built-in WiFi transceiver that can upload images to your computer, smartphone or to various photo-sharing sites. We use one here when taking pictures for our tutorials — it’s a great timesaver, eliminating the extra USB transfer step that’s otherwise necessary. The //Eye-Fi// card is a tiny wireless memory card. It stores photos and fits inside a camera just like a regular SD card, but also has built-in WiFi transceiver that can upload images to your computer, smartphone or to various photo-sharing sites. We use one here when taking pictures for our tutorials — it’s a great timesaver, eliminating the extra USB transfer step that’s otherwise necessary.
Line 6: Line 8:
 {{ :​tutorials:​iotc:​eye-fi-card.png?​nolink&​ |}} {{ :​tutorials:​iotc:​eye-fi-card.png?​nolink&​ |}}
  
-Can the Eye-Fi card work in an Arduino SD card adapter? You bet! Adding a TTL Serial JPEG camera, together with some minimal prep work, we can then create a self-contained wireless monitoring camera. Hide it inside a hollowed-out book or a plush dinosaur toy and discover who’s been eating all your Thin Mints cookies!+Can the Eye-Fi card work in an Arduino SD card adapter? You bet! Adding a TTL Serial JPEG camera, together with some minimal prep work, we can then create a self-contained wireless monitoring camera ​with motion-sensing capabilities. Hide it inside a hollowed-out book or a plush dinosaur toy and discover who’s been eating all your Thin Mints cookies!
  
 {{ :​tutorials:​iotc:​iotc.jpg?​nolink&​ |}} {{ :​tutorials:​iotc:​iotc.jpg?​nolink&​ |}}
  
-What makes this combination way cooler than just a normal SD card or a USB cable to a computer is all the infrastructure provided by the Eye-Fi service — not just transferring images to your computer, but pushing them to your smartphone, photo-sharing sites like Flickr, issuing email or Twitter notifications,​ etc. This is all configured through the Eye-Fi application — there’s no difficult ​coding required.+What makes this combination way cooler than just a normal SD card or a USB cable to a computer is all the infrastructure provided by the Eye-Fi service — not just transferring images to your computer, but pushing them to your smartphone, photo-sharing sites like Flickr, issuing email or Twitter notifications,​ etc. This is all configured through the Eye-Fi application — there’s no additional ​coding required.
  
 {{ :​tutorials:​iotc:​gui.png?​nolink&​ |}} {{ :​tutorials:​iotc:​gui.png?​nolink&​ |}}
  
-The camera project didn’t require any major engineering effort, but rather was a simple “mash up” of existing elements — a perfect example of the //​sketching//​ principle of Arduino. Let’s see how it’s put together!+The camera project didn’t require any major engineering effort, but rather was a simple “mash up” of existing elements — a perfect example of the //​sketching//​ principle of Arduino. ​Being Arduino-based,​ it’s also easy to tweak…say if you’d like a time-lapse camera rather than motion sensing, or to hack in sensors such as a laser “trip wire.” ​Let’s see how it’s put together! 
 + 
 +===== Parts and Software Lists =====
  
 Parts used in this project include: Parts used in this project include:
Line 22: Line 26:
   * TTL Serial JPEG Camera (either the [[https://​www.adafruit.com/​products/​397|bare board]] or [[https://​www.adafruit.com/​products/​613|weatherproof version]])   * TTL Serial JPEG Camera (either the [[https://​www.adafruit.com/​products/​397|bare board]] or [[https://​www.adafruit.com/​products/​613|weatherproof version]])
   * [[https://​www.adafruit.com/​products/​85|Shield Stacking Headers for Arduino]] make it easier to change the wiring around as needed   * [[https://​www.adafruit.com/​products/​85|Shield Stacking Headers for Arduino]] make it easier to change the wiring around as needed
-  * [[http://​www.eye.fi/​|Eye-Fi wireless SD card]] (any model)+  * Eye-Fi wireless SD card (any model).
   * A suitable power supply: either a [[https://​www.adafruit.com/​products/​63|9V 1A wall adapter]]…or,​ for standalone wireless use, our [[https://​www.adafruit.com/​products/​248|6-cell AA battery holder]] is best. For the smallest possible package, a [[https://​www.adafruit.com/​products/​14|MintyBoost]] can also work, but provides only about two hours’ run time.   * A suitable power supply: either a [[https://​www.adafruit.com/​products/​63|9V 1A wall adapter]]…or,​ for standalone wireless use, our [[https://​www.adafruit.com/​products/​248|6-cell AA battery holder]] is best. For the smallest possible package, a [[https://​www.adafruit.com/​products/​14|MintyBoost]] can also work, but provides only about two hours’ run time.
   * The usual electronic project bits and bobs: wire, soldering tools, etc.   * The usual electronic project bits and bobs: wire, soldering tools, etc.
  
-Before getting into the full wireless project, you might want to try out the example sketches included with the [[https://​github.com/​adafruit/​VC0706-Serial-Camera-Library|VC0706 serial camera library]]. Once that’s working, the camera setup is easily adapted to this new task.+Links to software:
  
-The aforementioned ​example sketches place the camera on Arduino pins 2 and 3 in conjunction with the SoftwareSerial library, keeping the Arduino’s native serial port available for communicating to a host computer. But the sketch used here instead assigns the camera to the hardware serial port for added robustness. Devices have their own independent clock sources, and baud rates always have a bit of slop…sometimes they fall out of phase and a glitch occurs, as can happen between the camera and Arduino. The hardware serial port is less prone to these errors. Not 100%, but noticeably more robust ​than SoftwareSerial in this regard. Maybe 1 in 100 images arrive corrupted, vs. about 10x that rate with SoftwareSerial.+  * [[https://​github.com/​adafruit/​Adafruit-IoT-Camera-with-EyeFi-Sketch|Eye-Fi sketch for Arduino]] (required) 
 +  * [[https://​github.com/​adafruit/​Adafruit-VC0706-Serial-Camera-Library|VC0706 Serial Camera Library]] (required) 
 +  * [[https://​github.com/​adafruit/​RTClib|Realtime Clock Library]] (required) 
 +  * [[http://​support.eye.fi/​downloads/​|Eye-Fi Center configuration software]] for PC and Mac (not Adafruit code — please contact Eye-Fi tech support for any help or issues with this software) 
 + 
 +===== Make It! ===== 
 + 
 +Before getting into the full wireless project, you might want to work through the [[http://​www.ladyada.net/​products/​camera/​|TTL Serial Camera Tutorial]] and try the example sketches ​included with the [[https://​github.com/​adafruit/​Adafruit-VC0706-Serial-Camera-Library|VC0706 serial camera library]]. Once that’s working, the camera setup is easily adapted to this new task. 
 + 
 +The aforementioned tutorials ​place the camera on Arduino pins 2 and 3 in conjunction with the SoftwareSerial library, keeping the Arduino’s native serial port available for communicating to a host computer. But the sketch used here instead assigns the camera to the hardware serial port for added robustness. Devices have their own independent clock sources, and baud rates always have a bit of slop…sometimes they fall out of phase and a glitch occurs, as can happen between the camera and Arduino. The hardware serial port is less prone to these errors. Not 100%, but noticeably more resiliant ​than SoftwareSerial in this regard. Maybe 1 in 100 images arrive corrupted, vs. about 10x that rate with SoftwareSerial.
  
 But using the Arduino’s serial port for the camera prevents us from sending debugging and status messages over USB. Instead, the LEDs on the Data Logging Shield are used…various blink patterns indicate the current status. Using the serial port also requires that the camera be unplugged when uploading sketches to the board, since it would interfere with the serial transfer. But using the Arduino’s serial port for the camera prevents us from sending debugging and status messages over USB. Instead, the LEDs on the Data Logging Shield are used…various blink patterns indicate the current status. Using the serial port also requires that the camera be unplugged when uploading sketches to the board, since it would interfere with the serial transfer.
Line 36: Line 49:
 {{ :​tutorials:​iotc:​jumpers.jpg?​nolink&​ |}} {{ :​tutorials:​iotc:​jumpers.jpg?​nolink&​ |}}
  
-Pins 5 and 6 are then connected to the red and green LEDs on the Data Logging Shield. The finished setup resembles the following (with solder connections between adjacent components being made on the back of the board):+Pins 5 and 6 are then connected to the red and green LEDs on the Data Logging Shield. The finished setup resembles the following (with solder connections between adjacent components being made on the //back// of the board):
  
 {{ :​tutorials:​iotc:​wiring.png?​nolink&​ |}} {{ :​tutorials:​iotc:​wiring.png?​nolink&​ |}}
Line 50: Line 63:
 Before proceeding any further, back up any data you might currently have on your Eye-Fi card. Just in case there’s some bug that’s been overlooked in the sketch, I’d hate to be the one to clobber your priceless irreplaceable wedding photos. So please, PLEASE back that up first! Before proceeding any further, back up any data you might currently have on your Eye-Fi card. Just in case there’s some bug that’s been overlooked in the sketch, I’d hate to be the one to clobber your priceless irreplaceable wedding photos. So please, PLEASE back that up first!
  
-The Data Logging Shield requires that the card be properly formatted. Some cameras and operating systems use a bit of “artistic license” when formatting SD cards, and the shield can’t always read or write these. ​The best solution is to [[http://​www.adafruit.com/​forums/​viewtopic.php?​f=31&​t=20861|use ​the SdFormatter sketch as described in this forum thread]].+The Data Logging Shield requires that the card be properly formatted. Some cameras and operating systems use a bit of “artistic license” when formatting SD cards, and the shield can’t always read or write these. ​You might need to borrow a friend’s more recent digital camera to format ​the card. Recent versions of both Mac OS X and Windows 7 seem to handle ​this better as well; with the latter, select FAT32 with a 32K allocation block size when formatting.
  
 With the card connected to your computer though a USB reader, you can then use an application downloaded from the Eye-Fi web site to configure it for access to your wireless network and select various settings for how and where you want images transferred. Once configured, if you have a digital camera, test it with that first. When the digital camera setup is known working and images are being transferred as expected, you can erase the images on the card and move it over to the Data Logging Shield. With the card connected to your computer though a USB reader, you can then use an application downloaded from the Eye-Fi web site to configure it for access to your wireless network and select various settings for how and where you want images transferred. Once configured, if you have a digital camera, test it with that first. When the digital camera setup is known working and images are being transferred as expected, you can erase the images on the card and move it over to the Data Logging Shield.
Line 57: Line 70:
  
 Next, upload the EyeFi sketch, then re-install the jumpers between pins 0-2 and 1-3. You can then either press the reset button to start the sketch, or disconnect from the computer and attach a power adapter or battery. Next, upload the EyeFi sketch, then re-install the jumpers between pins 0-2 and 1-3. You can then either press the reset button to start the sketch, or disconnect from the computer and attach a power adapter or battery.
 +
 +**If using the latest Eye-Fi “X2” cards, you'll need to enable this one extra line in the sketch (it’s commented out by default)…around line 122:**
 +
 +  SD.enableCRC(true);​
 +===== Use It! =====
  
 {{ :​tutorials:​iotc:​green-on.jpg?​nolink&​ |}} {{ :​tutorials:​iotc:​green-on.jpg?​nolink&​ |}}
Line 82: Line 100:
  
 Provided the card and Eye-Fi services are properly configured, and provided the card is within range of your wireless access point, as images are captured and written to the card they’ll then be sent to the Eye-Fi server and in turn forwarded to your computer, smartphone, etc. — however you’ve configured it. This is all explained ([[http://​support.eye.fi/​|and supported]],​ thanks) on the Eye-Fi web site. They have apps for iPhone and Android, as well as Windows and Mac on the desktop. Provided the card and Eye-Fi services are properly configured, and provided the card is within range of your wireless access point, as images are captured and written to the card they’ll then be sent to the Eye-Fi server and in turn forwarded to your computer, smartphone, etc. — however you’ve configured it. This is all explained ([[http://​support.eye.fi/​|and supported]],​ thanks) on the Eye-Fi web site. They have apps for iPhone and Android, as well as Windows and Mac on the desktop.
 +
 +===== How It Works =====
  
 The sketch relies on a couple of tricks in order to work with Eye-Fi: First, you can’t just dump any old file anywhere on the card and expect it to work — it’s not a big truck! The sketch needs to simulate the same directory hierarchy as one of the supported cameras…in this case, it acts like a Canon camera, and images will be placed in the directory ''​DCIM/​CANON999''​. Second, the card will only transfer JPEG files that are 20K or larger. The 640x480 images used by the sketch are usually well over this limit, but if you change the program’s settings to use one of the smaller image sizes, the sketch will pad out the file if needed to this minimum size (any well-written JPEG viewer will disregard this extra data). I had some reservations about gaming the system this way, but the fact is that a few 20K images a day will be far //less// taxing on the Eye-Fi servers than the typical 12+ megapixel images to which it’s regularly subjected. The sketch relies on a couple of tricks in order to work with Eye-Fi: First, you can’t just dump any old file anywhere on the card and expect it to work — it’s not a big truck! The sketch needs to simulate the same directory hierarchy as one of the supported cameras…in this case, it acts like a Canon camera, and images will be placed in the directory ''​DCIM/​CANON999''​. Second, the card will only transfer JPEG files that are 20K or larger. The 640x480 images used by the sketch are usually well over this limit, but if you change the program’s settings to use one of the smaller image sizes, the sketch will pad out the file if needed to this minimum size (any well-written JPEG viewer will disregard this extra data). I had some reservations about gaming the system this way, but the fact is that a few 20K images a day will be far //less// taxing on the Eye-Fi servers than the typical 12+ megapixel images to which it’s regularly subjected.
  
 So there you have it. What uses can you come up with? //Is the mail here yet? Who’s sneaking in through the cat flap and eating all the kibble? Does the refrigerator light //really// turn off when the door is closed?// So there you have it. What uses can you come up with? //Is the mail here yet? Who’s sneaking in through the cat flap and eating all the kibble? Does the refrigerator light //really// turn off when the door is closed?//
 +
 +===== Play It Safe =====
  
 **Before you go running off with reckless abandon, and while these are probably obvious, there are a few points that need to be made for posterity:​** **Before you go running off with reckless abandon, and while these are probably obvious, there are a few points that need to be made for posterity:​**
Line 92: Line 114:
   * **Do not use this as a security camera. This is not a security-grade device.**   * **Do not use this as a security camera. This is not a security-grade device.**
   * **Follow the law. Covert surveillance is illegal in some places and settings.**   * **Follow the law. Covert surveillance is illegal in some places and settings.**
-  * **Don’t abuse the Eye-Fi servers. The “free” lifetime bandwidth is reflected in the price we all pay up-front.** +  * **Don’t abuse the Eye-Fi servers. The “free” lifetime bandwidth ​(for non-premium services) ​is reflected in the price we all pay up-front.**
- +
-[[https://​github.com/​adafruit/​EyeFi|The EyeFi sketch can be downloaded from this Github repository.]]+
/home/ladyada/public_html/wiki/data/attic/tutorials/iotc.1331542126.txt.gz · Last modified: 2016/01/28 18:05 (external edit)