ESP8266 – CCTV still camera
When I saw this cheap Serial JPEG Camera I got the idea to convert a Fake CCTV camera into a “real” CCTV. Well, not a fully functional CCTV, because the serial camera is too slow to be able to stream video (and so is the ESP8266). But at least to get pictures from it.
The idea is to trigger the camera by motion detection, capture one image and store it in the internal memory. Then the image is transferred to a FTP server from where it can be accessed by a PC or Android phone or tablet.
The serial connection between the camera module and the ESP8266 is very simple. I used a NodeMCU ESP8266 module. There is only one serial port and it is occupied by the USB connection. So I decided to go for a software serial solution. The camera RX pin is connected to GPIO14 and the camera TX pin is connected to GPIO12.
Important here is to check the voltage level of the TX and RX lines of the camera. The GPIO’s of the ESP8266 are only compatible to 3.3V max. If you feed them with 5V or more, you will most likely fry your board.
I was lucky with the camera module I bought. Even the module is powered by 5V, the TX line showed only 3.3V level. So I was able to connect the camera directly to the ESP8266 without the need of a level shifter. As the connection between the ESP and the camera is really very simple (only 4 wires), I never made a schematic for it. So I will skip here the hardware details.
Trigger the camera
To trigger the camera I found three possibilities:
- Motion detection by the camera module
- Motion sensor connected to the ESP8266
- Trigger over WiFi by another device
I tested the motion detection of the camera itself and I found it over sensitive. It basically triggers on every small change in the view of the camera. And there was no possibility to change the sensitivity.
So I looked into the other two possibilities. I would have gone for #2 and attached one of these PIR sensors to the ESP8266 for a stand-alone system. But as I had already a DIY security alert systems build and installed, the solution #3 is the one I implemented. The details of this security alert system will be covered by another post here. As a summary, it is an ESP8266 with a light sensor to detect day/night, a PIR sensor to detect movements in my front yard, a siren for audible alarm and a relay to automatically switch on the lights in the front yard. The security alert system is part of my home control system. I use the capabilities of the system to communicate directly to each other device to trigger the camera whenever a movement in the front yard is detected.
On the next pages I will go into details of the software. The next page will cover the setup and initialization of the different functions.