Introduction: ESP8266 Remote Camera
In this Instructable I will show you how you can make a remote IP camera from components you can easily purchase on Ebay, Banggood, or any other economic supplier. I wanted the camera to be portable, reasonable compact, and run within my home network.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: The Design
I chose to use an Arduino Mega over an Arduino Uno because I needed 2 serial ports, and while I could emulate a second on the Uno, it wasn't as reliable at higher speeds. I picked the smallest ESP8266 package, the ESP-01 to save space. To store the images I used a Sainsmart microSD card adapter. For a camera, I chose the ArduCAM Mini 2MP because it has a built in FIFO as well as an adjustable lens to focus the image. To attach it to the board I used a short section CAT5 cable since it had the right number of conductors and the connector made for a easy way to attach and detach the camera from the shield. It also allowed me to easily point the camera in different directions or add extensions to the cable.
I used Fritzing to capture the schematic and layout the PCB. The boards were made by PCBWay, but any manufacturer capable of accepting Gerber files can make the PCBs.
- Arduino Mega
- Blank PCB shield
- USB programming cable
- 12V DC, 250mA or more, 2.1mm plug, centre pin positive power adapter
- ESP8266 (ESP-01)
- ESP8266 Programming Board
- ArduCAM Mini 2MP
- microSD Card reader module + microSD card
- AMS1117-33 (3.3 linear voltage regulator)
- n-channel mosfet (for level converting)
- 4 10kΩ resistors
- 50V 100 uF capacitor
- Vertical RJ45 network jack
- CAT5 cable and connector (or some other 8 conductor cable)
- a 8-pin double row female header (for the ESP-01)
- a 6-pin single row female header (for the microSD card reader)
- 12mm nylon standoff (to support the microSD card reader)
- 3 1-pin male headers (for testpoints)
- a 2-pin male header (for testpoints)
- a 3-pin male header (for testpoints)
- Acrylic Arduino Mega case (optional)
- Soldering Iron
- Flush cutters
- RJ45 crimper (if an existing cable with connector is not on hand)
Step 2: Flashing the ESP8266
To flash the ESP8266 I followed a guide by All About Circuits. I flashed the ESP8266 with the AT command set 2.1.0 and SDK version 1.1.0 which can be found here with the ESP8266 flashing tool. I also used PuTTY to check if the firmware was properly installed. The schematic of the circuit I used to program the ESP8266 can also be found above. I built the programming board on small proto-board, as it was not worth having a PCB manufactured. Note the pinout of communications connector on the programming board matches the pinout of the serial to USB adapter that I used.
Materials for Flashing
- Serial to USB adapter (CP2102)
- USB A to B convertor (so I could use a regular USB cable)
- 40x60mm proto-board, 2.54mm pitch
- 6 pin screw terminal socket
- 8 pin double row female header
- 2 push buttons (momentary)
- AMS1117-33 (3.3 linear voltage regulator)
- 16V 47 uF electrolytic capacitor
- 2 10kΩ resistors
- various bits of wire
Step 3: Assembling the Shield
There are many ways you can solder the headers in, but I chose to first plug them into the Mega, then place the shield PCB on top. Then I tacked the corner pins with solder and checked the alignment, before soldering all the pins. Once all those pins were soldered, I removed the PCB from the Mega, and soldered the rest of the components on. I started from the middle of the board, and worked my way to the outside. Before powering the board for the first time, I checked to ensure that there were no shorts between pins or between power and ground.
Step 4: Programming the Arduino Mega
I used a slightly modified version of a SparkFun ESP8266 library for the Arduino (modified library attached). I took code snippets from SparkFun (microSD card, ESWP8266 webserver) and ArduCAM. The code is structured as follows; when you access the website from your browser, it takes a picture, saves it to the microSD card, and then sends it to your browser. A basic version of the website is attached (index.txt). The website needs to be placed on the microSD card. Once the code is uploaded, check to ensure everything is connecting properly by opening the serial monitor and reading the initalization messages. A clip of the serial monitor at startup is attached. It shows that the camera, microSD card reader, and ESP8266 are connected, that the ESP8266 is connected to the WIFI, and an IP address is assigned.
Step 5: Running the Image Webserver
To run the webserver the first time, run the Arduino IDE and set the COM port to the one that the Mega is connected to. Open the serial monitor, and set the baud rate to what the Mega is set to. As soon as you open the serial monitor it will print out some initialization information, then print out the IP that the ESP8266 is assigned (this is underlined in blue in the first image). At this point, I logged into my router and preassigned the IP address that the ESP8266 was connected to permanently, so that the ESP8266 would always be assigned that address. For example, to view images from my webserver I always use 192.168.1.135 in my web browser. I can do this on any device connected to my LAN/WLAN. Attached is a sample image, and is probably about as good as it gets for a 2 megapixel camera. It often takes a few iterations to properly focus the image. An auto-focusing camera would be nice, maybe that will be my future upgrade.
Participated in the
Electronics Tips & Tricks Challenge