5MP Motion Camera  1.1.1.1
A waterproof, low power, battery operated, motion activated, 5 mega-pixel, WiFi camera.
How to Build a Waterproof, Battery-Operated, Low-Power, Motion-Activated, 5 Mega-pixel WiFi Camera

This project shows you how to build a WiFi camera that sleeps until activated by a microwave motion sensor. It carefully conserves power to maximize battery life. (You can expect to get a full week of use from the battery.) The camera takes great color pictures and movies in a range of sizes from 320x240px up to 2592x1944px. The camera's Adafruit Feather M0 sends the pictures to a CGI for image processing and storage. (See the JPEG Catcher project for further details.) There is no SD card in this project. The images are stored "in-your-cloud" where the CGI is hosted. This project teaches you how to move relatively large hunks of data like the camera's 8MB image buffer in small hunks like the WINC1500's 1400 byte MTU over WiFi to a server. It does this using the old-school method of base64 encoding the binary image data. This makes the data into a stream of visible characters that get piped into the CGI on standard input. The CGI decodes the data back into binary format and saves it to storage. From there a web server makes the images browsable. The camera has a wide assortment of settings that control all aspects of picture taking. The Camera Settings Project provides a mobile-responsive web page for adjusting those settings. This means you won't have to compile a new binary and load it into the Feather just to adjust the camera's exposure, brightness, or contrast, et cetera. The settings are passed from the web page to a web socket server in the form of Google flatBuffers. This is the new-school way to move relatively-small, fixed length, data structures around the web in binary format. The flatBuffers project provides libraries in many languages so that it's easy to go from JavaScript to C++ and back. This project includes both old and new school data communication methods for several reasons;

  • There is still a whole lot of legacy code in use and you might one day be happy to take a job maintaining it so wouldn't it be nice if you new how it worked?
  • The old school way built the Internet and eMail as we know it and really good old-ideas often come around again in new forms. So while the implementation is old, the concepts used are still relevant to today's engineering problems.
  • The Internet of Things needs very efficient, low-power, machine-to-machine communication and projects like flatBuffers are a good solution. The need is so ubiquitous it's essential that everyone in the robotics/embedded space is familiar with such solutions.

Schematic

5MP_Motion_Camera_v1_2.jpg
Eechema Schematic

Building

I used platformio to build this project. If you plan to do the same you'll need to create a platformio.ini file. It should look something like the one below. Replace the items in all-caps with your own configuration.

[common]
lib_deps_external =
https://github.com/arduino-libraries/WiFi101.git
[env:adafruit_feather_m0]
platform = atmelsam
board= adafruit_feather_m0
framework = arduino
upload_port = /dev/YOUR_TTY_DEVICE
upload_speed = 115200
lib_deps = ${common.lib_deps_external}
build_flags =
'-DWIFI_SSID="YOUR WIFI ACCESS POINT SSID"'
'-DWIFI_PASS="YOUR WIFI PASSWORD"'
'-DHTTP_HOST="IP ADDRESS OF YOUR CGI/WEBSOCKET SERVER"'
'-DHTTP_HOST_PORT=4444'
'-DSOCKET_PORT=8880'
'-DHTTP_HOST_URL="/cgi-bin/jpeg_catcher"'
'-std=c++14'
'-std=gnu++14'
build_unflags =
'-std=gnu++11'

Credits

Bugs, Issues, and Pull Requests

If you find a bug please create an issue. If you'd like to contribute please send a pull request.

References

The following were helpful references in the development of this project.