{"id":1702,"date":"2017-09-09T08:09:37","date_gmt":"2017-09-09T13:09:37","guid":{"rendered":"http:\/\/nootropicdesign.com\/projectlab\/?p=1702"},"modified":"2019-05-26T10:50:13","modified_gmt":"2019-05-26T15:50:13","slug":"wifi-camera-trap","status":"publish","type":"post","link":"https:\/\/nootropicdesign.com\/projectlab\/2017\/09\/09\/wifi-camera-trap\/","title":{"rendered":"Wi-Fi Camera Trap"},"content":{"rendered":"<p>Project source code at GitHub: <a href=\"https:\/\/github.com\/nootropicdesign\/wifi-camera-trap\" target=\"_blank\" rel=\"noopener noreferrer\">wifi-camera-trap<\/a><\/p>\n<p>We have lots of small wildlife around our house (mostly rabbits this year) and since I have a small camera module and a cheap PIR (passive infrared) motion sensor, I thought it would be fun to make a motion triggered wi-fi camera to deploy somewhere near the house.<br \/>\n<div id=\"attachment_1697\" style=\"width: 650px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2017\/09\/camera-trap-enclosure.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1697\" src=\"https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2017\/09\/camera-trap-enclosure-small.jpg\" alt=\"\" width=\"640\" height=\"480\" class=\"size-full wp-image-1697\" srcset=\"https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2017\/09\/camera-trap-enclosure-small.jpg 640w, https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2017\/09\/camera-trap-enclosure-small-300x225.jpg 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><p id=\"caption-attachment-1697\" class=\"wp-caption-text\">Wi-Fi Camera Trap<\/p><\/div><br \/>\n<br clear=\"all\"\/><\/p>\n<p>The project is quite simple. If the PIR sensor is triggered, software on an ESP8266 wi-fi microcontroller captures an image using the ArduCAM camera module and uploads it to an image server. I wrote a very simple Node.js server that saves the uploaded images and makes them available on a gallery page for easy viewing. Nothing fancy. <\/p>\n<p>Here are some of the great images we captured. The bunny&#8217;s movement triggered the PIR sensor with no problem!<br \/>\n<div id=\"attachment_1669\" style=\"width: 650px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2017\/08\/bunnies.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1669\" src=\"https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2017\/08\/bunnies-small.jpg\" alt=\"\" width=\"640\" height=\"480\" class=\"size-full wp-image-1669\" srcset=\"https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2017\/08\/bunnies-small.jpg 640w, https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2017\/08\/bunnies-small-300x225.jpg 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><p id=\"caption-attachment-1669\" class=\"wp-caption-text\">Bunnies over Wi-Fi<\/p><\/div><br \/>\n<br clear=\"all\"\/><\/p>\n<p>Inside the enclosure is an IoT Experimenter board that I designed to help me with my IoT projects. <a href=\"https:\/\/nootropicdesign.com\/projectlab\/2017\/09\/03\/iot-experimenter-esp8266-dev-board\/\" target=\"_blank\" rel=\"noopener noreferrer\">You can read more about it here<\/a>. It has an ESP8266 wi-fi chip and connector for an ArduCAM module. I&#8217;m powering the whole device from a 5V battery pack. The IoT Experimenter is designed for input of 9V, but the onboard 5V regulator drops the 5V input down to about 4V, which is still fine for the camera module and PIR sensor in this project.<\/p>\n<p>You can use any ESP8266 board you have. The camera connects to both the I2C and SPI pins, and the PIR sensor is connected to &#8220;Arduino pin 3&#8221; which is the RX pin on the ESP8266 but you can move it to any pin.<br \/>\n<div id=\"attachment_1704\" style=\"width: 650px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2017\/09\/camera-trap-inside.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1704\" src=\"https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2017\/09\/camera-trap-inside-small.jpg\" alt=\"\" width=\"640\" height=\"913\" class=\"size-full wp-image-1704\" srcset=\"https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2017\/09\/camera-trap-inside-small.jpg 640w, https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2017\/09\/camera-trap-inside-small-210x300.jpg 210w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><p id=\"caption-attachment-1704\" class=\"wp-caption-text\">Wi-Fi Camera Trap &#8211; inside<\/p><\/div><br \/>\n<br clear=\"all\"\/><\/p>\n<p>Here&#8217;s what it looks like outside of the enclosure:<br \/>\n<div id=\"attachment_1699\" style=\"width: 650px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2017\/09\/camera-trap-hardware.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1699\" src=\"https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2017\/09\/camera-trap-hardware-small.jpg\" alt=\"\" width=\"640\" height=\"480\" class=\"size-full wp-image-1699\" srcset=\"https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2017\/09\/camera-trap-hardware-small.jpg 640w, https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2017\/09\/camera-trap-hardware-small-300x225.jpg 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><p id=\"caption-attachment-1699\" class=\"wp-caption-text\">Wi-Fi Camera Trap Hardware<\/p><\/div><br \/>\n<br clear=\"all\"\/><\/p>\n<p>Here&#8217;s a closeup of the sensor. These are super cheap on AliExpress or Ebay. The output pin goes HIGH when there is new movement detected.<br \/>\n<div id=\"attachment_1701\" style=\"width: 650px\" class=\"wp-caption alignleft\"><a href=\"https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2017\/09\/camera-trap-pir-sensor.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1701\" src=\"https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2017\/09\/camera-trap-pir-sensor.jpg\" alt=\"\" width=\"640\" height=\"480\" class=\"size-full wp-image-1701\" srcset=\"https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2017\/09\/camera-trap-pir-sensor.jpg 640w, https:\/\/nootropicdesign.com\/projectlab\/wp-content\/uploads\/2017\/09\/camera-trap-pir-sensor-300x225.jpg 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><p id=\"caption-attachment-1701\" class=\"wp-caption-text\">Cheap PIR Sensor<\/p><\/div><br \/>\n<br clear=\"all\"\/><\/p>\n<h3>Software<\/h3>\n<p>I prefer to program ESP8266 chips using Arduino so I can take advantage of the hundreds of useful Arduino libraries. There&#8217;s plenty of information about using <a href=\"https:\/\/github.com\/esp8266\/Arduino\" target=\"_blank\" rel=\"noopener noreferrer\">Arduino code on the ESP8266 here<\/a>. This project uses the <a href=\"https:\/\/github.com\/ArduCAM\/Arduino\" target=\"_blank\" rel=\"noopener noreferrer\">ArduCAM library<\/a> control the camera module.<\/p>\n<p>I&#8217;m also using the excellent <a href=\"https:\/\/github.com\/tzapu\/WiFiManager\" target=\"_blank\" rel=\"noopener noreferrer\">WiFiManager library<\/a> to make it easier to connect the ESP8266 to a network. Instead of hardcoding the SSID and password in code, if the chip can&#8217;t connect to any networks it already knows about, the WiFiManager will set up an access point (AP) named &#8220;CameraTrap&#8221;. Use your computer or phone to connect to the CameraTrap access point and a captive portal page will prompt you for your network name and password. If you aren&#8217;t automatically shown the captive portal page, just navigate to 10.0.0.200 and it will load.<\/p>\n<p>After the CameraTrap code captures an image, it needs to upload it somewhere. I&#8217;ve provided a simple Node.js server for this purpose. The code POSTs the image to \/upload on the image server which writes it to disk. You will have to specify the server hostname in the CameraTrap code. Note that the camera is actually installed upside down in the enclosure (so the wires fit) so my server rotates the image 180 degrees when it saves it to disk. On any machine where you can run a node server, type<\/p>\n<div class=\"code\">\nnpm install<br \/>\nnode app.js\n<\/div>\n<p>The server will run on port 8000. In any browser, just navigate to <\/p>\n<div class=\"code\">\nhttp:\/\/yourserver:8000\/images\n<\/div>\n<p>to see the images. (Make sure you don&#8217;t accidentally include a trailing slash in the URL.)<\/p>\n<p>All the software is available in the <a href=\"https:\/\/github.com\/nootropicdesign\/wifi-camera-trap\" target=\"_blank\" rel=\"noopener noreferrer\">wifi-camera-trap GitHub repository<\/a>. The Arduino code is in the CameraTrap directory, and the Node.js image server is in the imageserver directory.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Project source code at GitHub: wifi-camera-trap We have lots of small wildlife around our house (mostly rabbits this year) and since I have a small camera module and a cheap PIR (passive infrared) motion sensor, I thought it would be fun to make a motion triggered wi-fi camera to deploy somewhere near the house. The [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[3,31,30],"tags":[],"class_list":["post-1702","post","type-post","status-publish","format-standard","hentry","category-arduino","category-esp8266","category-iot"],"_links":{"self":[{"href":"https:\/\/nootropicdesign.com\/projectlab\/wp-json\/wp\/v2\/posts\/1702","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nootropicdesign.com\/projectlab\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nootropicdesign.com\/projectlab\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nootropicdesign.com\/projectlab\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nootropicdesign.com\/projectlab\/wp-json\/wp\/v2\/comments?post=1702"}],"version-history":[{"count":11,"href":"https:\/\/nootropicdesign.com\/projectlab\/wp-json\/wp\/v2\/posts\/1702\/revisions"}],"predecessor-version":[{"id":2270,"href":"https:\/\/nootropicdesign.com\/projectlab\/wp-json\/wp\/v2\/posts\/1702\/revisions\/2270"}],"wp:attachment":[{"href":"https:\/\/nootropicdesign.com\/projectlab\/wp-json\/wp\/v2\/media?parent=1702"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nootropicdesign.com\/projectlab\/wp-json\/wp\/v2\/categories?post=1702"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nootropicdesign.com\/projectlab\/wp-json\/wp\/v2\/tags?post=1702"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}