|
Autodesk Fusion 360Autodesk
|
|
|
arduino IDEArduino
|
DIY Security CAM
Hey guys and welcome back
This is my DIY Security Cam which is made from an ESP32 connected with a 5V Charger circuit that converts 240V AC into 5V DC for ESP32 to run.
The goal for making this project was to make a cheaper alternative to the existing WIFI Security Camera.
Also, huge thanks to PCBWay for Supporting this project, Check out PCBWay for getting great PCB Service at a relatively less cost.
Getting Started
Now, a few weeks ago I a post about the ESP32 CAM which you can check out,
https://www.hackster.io/Arnov_Sharma_makes/esp32-cam-web-server-and-getting-started-guide-f1a04a
In that post, we learn how to control the ESP32 CAM and flash it with a UART Module.
Flashing this esp32 is a pretty easy process, we first connect the module in the right writing order and then connect this with Arduino IDE and follow some basic guidelines like we need to press the Reset button once while uploading the sketch and our esp32 cam will flash like a normal esp32.
Here we have an ESP32 that contains the CAM webserver sketch that enables us to connect this it with the internet and see the live camera footage.
doesn't that sound like a security camera?
yes it does, the wifi security cam do exactly this but they provide more features that are mostly software-based so what I'm gonna do here is, I will provide this esp32 power with a charger circuit, I will use a custom PCB in this project which will contain the esp32 and charger circuit and then I will put that custom PCB in a 3D Printed enclosure.
this is the plan
well, it will work electronically but I'm not pretty sure that the PLA can withstand being outside for this kind of project.
Circuitry
Anyways, to get started with this project, I first designed a charger circuit by replicating and reverse engineering an existing 5V 1A Charger circuit that I found in an existing commercial mobile phone charger.
Now, this project involves working with the AC supply which is pretty lethal so I don't recommend you guys to replicate this project as I did, instead of making an SMPS CIrcuit, you can use an isolated power supply module to power this board. it's still dangerous but it will decrease the chances of getting elecuted by this project.
To use the isolated power supply, I have already added its Pads on the PCB so we can just solder this onto the circuit or use an extremely dangerous non-isolated charger circuit.
I designed this whole project in my OrCAD software, I wanted to add a custom silkscreen to this board so I prepared this image in GIMP and then exported the PNG image.
then I converted the PNG file into a BMP (because the OrCAD only imports BMP Images) and then added this image onto my PCB design and this was the result!
note- this method will be different for every PCB Designing suit so just follow your PCB Cad software image importing process and you'll be good.
Getting PCB Made from PCBWay
After finalizing the PCB, I exported its Gerber data ad send that to PCBWay for samples,
I received the PCBs in a week, PCB quilty was pretty great and I'm happy with it.
PCBWay you guys rock, Check out PCBWay for getting great PCB Service at less cost!
Assembly Process
After receiving the PCBs, I started the assembly process of this board.
- We first add solder paste to each component's pad one by one. (a better alternative is to use a stencil which I didn't get because I'm such a genius ??)
- After this, I added components to their assigned place one by one in the right order and then after doing that, I verify the board one last time, and then I put the whole circuit onto my DIY SMT Hotplate for the reflow process.
- Solder paste will melt as soon as the reflow surface hit the solder paste melting temp and then we carefully remove the PCB from the hotplate and let it cool down for a little bit.
- after checking the PCB solder joints and making sure that we didn't short any components, we then move on to the next step which is to add THT components like the capacitors, fuse, MOV, and transformer.
- After adding these components, I added a female header pin to connect esp32 with this board, and our circuit is finally ready for its first test.
but before that, I added the circuit on ts 3D Printed body and then added an AC Cord to the input of the PCB to supply 240V AC to this setup.
Flashing ESP32 CAM Quick Look
Check out the previous Post for a full walkthrough.
https://www.hackster.io/Arnov_Sharma_makes/esp32-cam-web-server-and-getting-started-guide-f1a04a
ESP32 CAM doesn't have an onboard programming chip which is a bummer, because of this we have to add an external USB to the Serial Programming module.
For That, I will be using an FTDI USB to Serial module.
Follow the following Wiring arrangement to hook FTDI Module with ESP32 CAM.
- Set FTDI output to 5V
- Connect the FTDI's VCC (which is 5V) to 5V of ESP32 CAM
- GND to GND
- RX to U0T
- TX to U0R
- GPIO0 which is IO0 to GND (this will put the ESP32 CAM in Flash Mode)
Before Flashing Process, you need to change few things in the example sketch.
- Go to Example> ESP32> Camera and open the CameraWebServer sketch
- Input your SSID and password
- Change the camera module from #define CAMERA_MODEL_WROVER_KIT to #define CAMERA_MODEL_AI_THINKERNow,
- Go to Tools and select the right board which is in our case AI-Thinker ESP32-CAM.
- Select the right port and hit upload.
Now, when the ESP32 Starts its uploading process you will see the connecting message with dots and dashes. press the reset button on the bottom side of the board when dots and dashes start.
If you have encountered an error during this setup that says unable to connect, this means your timing was not good, try again and when the first dot appears in the debugging menu, long-press the reset button for at least 1 second. After few seconds, your sketch will be uploaded.
now plug out the USB from FTDI Module and remove the jumper between GPIO0 and GND.
plug in the USB and open up the serial monitor.
ESP32 will get connected with WIFI (which would take 1min) and you will see the IP address of the ESP32 CAM.
3D Printed Enclosure
I prepared its body in fusion 360 and then 3D Printed it with PLA, yes I know, I should've used a better material that can withstand the outside heat as PLA will start deforming at 160°C, and here at my place, the outside temp is around 35-40 outside so the PLA might melt and that's one flaw.
well, that's a gamble that I took so maybe it will not melt, we will see how that goes.
I've already flashed the ESP32 with the ESP32 CAM webserver sketch and I already have its IP address.
https://www.hackster.io/Arnov_Sharma_makes/esp32-cam-web-server-and-getting-started-guide-f1a04a
so we just need to make sure first that the ESP32 is fed with a 5V supply and for that, I checked the Voltage on ESP32's VCC and GND Port.
Now, at last, I added this acrylic transparent sheet on the first side of the enclosure with screws and hot glue, hot glue will create a gasket in between the acrylic transparent sheet and 3D Printed Body which will hopefully protect the inside from moisture content.
RESULT
After finalizing this whole project, I placed oy outside my room and plugged the AC Supply into it.
To monitor the live feed, we can just go to the ESP32 CAM IP address and view the live feed.
And that is how you can save so many bucks or rupees in my case by not purchase an actual security cam and DIY this whole thing for less than 15$ or 1100 Rupees.
Leave a comment if you need any help with this project!
#include "esp_camera.h"
#include <WiFi.h>
#include "esp_timer.h"
#include "img_converters.h"
#include "Arduino.h"
#include "fb_gfx.h"
#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"
#include "esp_http_server.h"
const char* ssid = "ENTER YOUR SSID";
const char* password = "PASSWORD";
#define PART_BOUNDARY "123456789000000000000987654321"
#define CAMERA_MODEL_AI_THINKER
#if defined(CAMERA_MODEL_WROVER_KIT)
#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 21
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27
#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 19
#define Y4_GPIO_NUM 18
#define Y3_GPIO_NUM 5
#define Y2_GPIO_NUM 4
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 23
#define PCLK_GPIO_NUM 22
#elif defined(CAMERA_MODEL_M5STACK_PSRAM)
#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM 15
#define XCLK_GPIO_NUM 27
#define SIOD_GPIO_NUM 25
#define SIOC_GPIO_NUM 23
#define Y9_GPIO_NUM 19
#define Y8_GPIO_NUM 36
#define Y7_GPIO_NUM 18
#define Y6_GPIO_NUM 39
#define Y5_GPIO_NUM 5
#define Y4_GPIO_NUM 34
#define Y3_GPIO_NUM 35
#define Y2_GPIO_NUM 32
#define VSYNC_GPIO_NUM 22
#define HREF_GPIO_NUM 26
#define PCLK_GPIO_NUM 21
#elif defined(CAMERA_MODEL_M5STACK_WITHOUT_PSRAM)
#define PWDN_GPIO_NUM -1
#define RESET_GPIO_NUM 15
#define XCLK_GPIO_NUM 27
#define SIOD_GPIO_NUM 25
#define SIOC_GPIO_NUM 23
#define Y9_GPIO_NUM 19
#define Y8_GPIO_NUM 36
#define Y7_GPIO_NUM 18
#define Y6_GPIO_NUM 39
#define Y5_GPIO_NUM 5
#define Y4_GPIO_NUM 34
#define Y3_GPIO_NUM 35
#define Y2_GPIO_NUM 17
#define VSYNC_GPIO_NUM 22
#define HREF_GPIO_NUM 26
#define PCLK_GPIO_NUM 21
#elif defined(CAMERA_MODEL_AI_THINKER)
#define PWDN_GPIO_NUM 32
#define RESET_GPIO_NUM -1
#define XCLK_GPIO_NUM 0
#define SIOD_GPIO_NUM 26
#define SIOC_GPIO_NUM 27
#define Y9_GPIO_NUM 35
#define Y8_GPIO_NUM 34
#define Y7_GPIO_NUM 39
#define Y6_GPIO_NUM 36
#define Y5_GPIO_NUM 21
#define Y4_GPIO_NUM 19
#define Y3_GPIO_NUM 18
#define Y2_GPIO_NUM 5
#define VSYNC_GPIO_NUM 25
#define HREF_GPIO_NUM 23
#define PCLK_GPIO_NUM 22
#else
#error "Camera model not selected"
#endif
static const char* _STREAM_CONTENT_TYPE = "multipart/x-mixed-replace;boundary=" PART_BOUNDARY;
static const char* _STREAM_BOUNDARY = "\r\n--" PART_BOUNDARY "\r\n";
static const char* _STREAM_PART = "Content-Type: image/jpeg\r\nContent-Length: %u\r\n\r\n";
httpd_handle_t stream_httpd = NULL;
static esp_err_t stream_handler(httpd_req_t *req){
camera_fb_t * fb = NULL;
esp_err_t res = ESP_OK;
size_t _jpg_buf_len = 0;
uint8_t * _jpg_buf = NULL;
char * part_buf[64];
res = httpd_resp_set_type(req, _STREAM_CONTENT_TYPE);
if(res != ESP_OK){
return res;
}
while(true){
fb = esp_camera_fb_get();
if (!fb) {
Serial.println("Camera capture failed");
res = ESP_FAIL;
} else {
if(fb->width > 400){
if(fb->format != PIXFORMAT_JPEG){
bool jpeg_converted = frame2jpg(fb, 80, &_jpg_buf, &_jpg_buf_len);
esp_camera_fb_return(fb);
fb = NULL;
if(!jpeg_converted){
Serial.println("JPEG compression failed");
res = ESP_FAIL;
}
} else {
_jpg_buf_len = fb->len;
_jpg_buf = fb->buf;
}
}
}
if(res == ESP_OK){
size_t hlen = snprintf((char *)part_buf, 64, _STREAM_PART, _jpg_buf_len);
res = httpd_resp_send_chunk(req, (const char *)part_buf, hlen);
}
if(res == ESP_OK){
res = httpd_resp_send_chunk(req, (const char *)_jpg_buf, _jpg_buf_len);
}
if(res == ESP_OK){
res = httpd_resp_send_chunk(req, _STREAM_BOUNDARY, strlen(_STREAM_BOUNDARY));
}
if(fb){
esp_camera_fb_return(fb);
fb = NULL;
_jpg_buf = NULL;
} else if(_jpg_buf){
free(_jpg_buf);
_jpg_buf = NULL;
}
if(res != ESP_OK){
break;
}
//Serial.printf("MJPG: %uB\n",(uint32_t)(_jpg_buf_len));
}
return res;
}
void startCameraServer(){
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
config.server_port = 80;
httpd_uri_t index_uri = {
.uri = "/",
.method = HTTP_GET,
.handler = stream_handler,
.user_ctx = NULL
};
//Serial.printf("Starting web server on port: '%d'\n", config.server_port);
if (httpd_start(&stream_httpd, &config) == ESP_OK) {
httpd_register_uri_handler(stream_httpd, &index_uri);
}
}
void setup() {
WRITE_PERI_REG(RTC_CNTL_BROWN_OUT_REG, 0); //disable brownout detector
Serial.begin(115200);
Serial.setDebugOutput(false);
camera_config_t config;
config.ledc_channel = LEDC_CHANNEL_0;
config.ledc_timer = LEDC_TIMER_0;
config.pin_d0 = Y2_GPIO_NUM;
config.pin_d1 = Y3_GPIO_NUM;
config.pin_d2 = Y4_GPIO_NUM;
config.pin_d3 = Y5_GPIO_NUM;
config.pin_d4 = Y6_GPIO_NUM;
config.pin_d5 = Y7_GPIO_NUM;
config.pin_d6 = Y8_GPIO_NUM;
config.pin_d7 = Y9_GPIO_NUM;
config.pin_xclk = XCLK_GPIO_NUM;
config.pin_pclk = PCLK_GPIO_NUM;
config.pin_vsync = VSYNC_GPIO_NUM;
config.pin_href = HREF_GPIO_NUM;
config.pin_sscb_sda = SIOD_GPIO_NUM;
config.pin_sscb_scl = SIOC_GPIO_NUM;
config.pin_pwdn = PWDN_GPIO_NUM;
config.pin_reset = RESET_GPIO_NUM;
config.xclk_freq_hz = 20000000;
config.pixel_format = PIXFORMAT_JPEG;
if(psramFound()){
config.frame_size = FRAMESIZE_UXGA;
config.jpeg_quality = 10;
config.fb_count = 2;
} else {
config.frame_size = FRAMESIZE_SVGA;
config.jpeg_quality = 12;
config.fb_count = 1;
}
// Camera init
esp_err_t err = esp_camera_init(&config);
if (err != ESP_OK) {
Serial.printf("Camera init failed with error 0x%x", err);
return;
}
// Wi-Fi connection
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("Camera Stream Ready! Go to: http://");
Serial.print(WiFi.localIP());
// Start streaming web server
startCameraServer();
}
void loop() {
delay(1);
}
DIY Security CAM
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
- Comments(0)
- Likes(5)
- Matthew Beatty Sep 10,2024
- J_spec6 Dec 28,2023
- Engineer Jul 17,2023
- Andrew Taylor Nov 24,2022
- Engineer Aug 24,2022
- 1 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
-
1design
-
10usability
-
10creativity
-
10content
More by Arnov Arnov sharma
- WALKPi PCB Version Greetings everyone and welcome back, This is the WalkPi, a homebrew audio player that plays music fr...
- Delete Button XL Greetings everyone and welcome back, and here's something fun and useful.In essence, the Delete Butt...
- Arduino Retro Game Controller Greetings everyone and welcome back. Here's something fun.The Arduino Retro Game Controller was buil...
- Super Power Buck Converter Greetings everyone and welcome back!Here's something powerful, The SUPER POWER BUCK CONVERTER BOARD ...
- Pocket Temp Meter Greetings and welcome back.So here's something portable and useful: the Pocket TEMP Meter project.As...
- Pico Powered DC Fan Driver Hello everyone and welcome back.So here's something cool: a 5V to 12V DC motor driver based around a...
- Mini Solar Light Project with a Twist Greetings.This is the Cube Light, a Small and compact cube-shaped emergency solar light that boasts ...
- PALPi V5 Handheld Retro Game Console Hey, Guys what's up?So this is PALPi which is a Raspberry Pi Zero W Based Handheld Retro Game Consol...
- DIY Thermometer with TTGO T Display and DS18B20 Greetings.So this is the DIY Thermometer made entirely from scratch using a TTGO T display board and...
- Motion Trigger Circuit with and without Microcontroller GreetingsHere's a tutorial on how to use an HC-SR505 PIR Module with and without a microcontroller t...
- Motor Driver Board Atmega328PU and HC01 Hey, what's up folks here's something super cool and useful if you're making a basic Robot Setup, A ...
- Power Block Hey Everyone what's up!So this is Power block, a DIY UPS that can be used to power a bunch of 5V Ope...
- Goku PCB Badge V2 Hey everyone what's up!So here's something SUPER cool, A PCB Board themed after Goku from Dragon Bal...
- RGB Mixinator V2 Hey Everyone how you doin!So here's a fun little project that utilizes an Arduino Nano, THE MIXINATO...
- Gengar PCB Art Hey guys and how you doing!So this is the GENGAR PCB Badge or a Blinky Board which is based around 5...
- R2D2 Mini Edition So here's something special, A Mini R2D2 PCB that speaks ASTROMECH.Astromech is a fictional language...
- C-3PO Blinky Board Hey guys and how you doing!So this is the C3P0 PCB Badge or a Blinky Board which is based around 555...
- WALKPi Breadboard Version Greetings everyone and welcome back, Here's something loud and musical.Similar to a traditional walk...
-
-
-
-
-
-
X-mas ball, Now with ANIMATED LIGHTS!
108 4 7 -
-
-
-
RC radial engine spark plug heater
29 0 0 -
-