How To Build a Cloud Security Camera with ESP32-CAM

  • by

In the category of security products, you will see cameras known as ip cameras, which actually deliver the received images to the user through the cloud from anywhere in the world. In this tutorial, we are going to use ESP32-CAM boards and Cloud ngrok to build such a device with the ability to send images to different places without any restrictions. In fact, once the project is completed and launched, you will only be able to access it with a single link. Visit CiferTech for more tutorials, and be sure to follow my Instagram page to support me.

 


What is ngrok ?!


ngrok is a cross-platform application that enables developers to expose a local development server to the Internet with minimal effort. This software allows your local web server to be hosted under the ngrok.com domain, meaning that no IP or public domain name is required on the local device. Similar performance can be achieved with Reverse SSH Tunneling, but this requires more configuration as well as hosting from your remote server.

ngrok can circumvent NAT and firewall mapping restrictions by creating a TCP tunnel from a randomly created subdomain at ngrok.com (e.g. 3gf892ks.ngrok.com) to the local machine. After specifying the port that your web server is listening to, the client program starts connecting by connecting the server, and then anyone can request a unique address from their local server.

 


ESP-32 chip


ESP32 is the advanced generation of ESP8266. One of the differences is its built-in Bluetooth. It also has a 2.4 GHz WiFi core and built-in Bluetooth with TSMC 40-nanometer technology. This module has the best performance in energy consumption, that is, it brings the best results for us with the lowest energy consumption. If we want to take a closer look at this board, we must say that this is a chip in which the NodeMCU platform is implemented, which is also called System on a chip microcontrollers. Other features of ESP32-cam module  We can mention the OV2640 camera with the ability to record images in JPEG, BMP and grayscale formats. You will also be able to shoot in dark places with the LED flash mounted on this module. One of the useful features of this micro SD input module is the ability to upgrade to 4GB, which also allows the user to store images.

 


FTDI programmer module


To program  ESP32-cam,  because the internal programmer is not included, we use this module. In fact, this module is a USB to TTL converter that uses Rx and Tx with ESP-CAM board and via USB connection to the system used. We communicate. In this module, there are two levels of 3.3 and 5 volts, which can be useful in different projects.

 


How the project works


This project works in such a way that by using the ngrok cloud, after registering and receiving the required code and then running the ESP32-CAM web server on the local network with the help of the ngrok cloud, the data is transferred to the cloud and received on the side We will do it again. This process is done using a cmd in your Windows machine, but of course there are other versions for the Linux machine that allow us to use Raspberry Pi to be able to run the server part of the project.

 


Items needed


  1. ESP32-CAM module
  2. FT232 converter module for program

 


Install ESP32 plugin


To get started, the library for this module must be installed in the Arduino IDE software. First, the following link must be  copied and pasted to  File >  Preferences .

Then you will be able to download the relevant library by going to the Boards section in  Tools  >  Board  >  Boards Manager   and ESP32 Search.

 

 


Programming ESP32-cam


To program this board, use the following schematic and make the connections according to the following schematic according to the USB TO TTL used. Note that when programming code, ie after compiling the code, the two pins GPIO 0 and GND are connected to each other, and after successfully compiling the code, you must disconnect this connection to run the project.

  • The connections are as follows.

 

 


Ngrok SettingUp


In the first step to implement this project on ngrok.com site, we will create an account. We will first enter the ngrok.com site , and using the SignUp option we will enter the page shown below.

 

 

After entering this page, we can register on the site in two ways. First, using the complete information and entering it manually as shown in the image below.

 

In the second case, it is possible to register using a Github or Gmail account in the shortest time. In the image below, by clicking on the images related to Gmail or Github, you will be able to create an automatic account on the site thanks to these accounts that you have already created.

 

After registering on the site, you will see a window on the first page of the registration window, using which you can download the ngrok terminal for the relevant operating system.

 

After downloading the specified file and executing it, you will encounter such an environment. In the next steps, we will review the understandable commands of this terminal.

 


Get IP Local


To receive a local IP from the ESP32-CAM board, we must first upload the code on the chip. The code we use for this section is a simplified example. The following code requires a few small changes, the first of which is the SSID settings and password of your modem that you must enter in the specified fields.

 

This code works well for Wrover / Ai Thinker chips, change it because of the configuration for the associated pins if you are using miscellaneous chips.


 

Finally, using the existing schemas and previous tutorials, upload the code to the ESP32 chip.

After uploading the code on the chip, by selecting the Serial Monitor option in the Arduino IDE, you will be able to get the created ip ledcal, which we will need in the next steps.

Note : If the ip is not displayed once, reset the board using the microswitch on the board.

 


Launch the project and transfer the images


After completing the previous steps, such as uploading the code and receiving the local ip, we must go to the startup of ngrok prerequisites and send the images to the cloud using the relevant commands. First, from the left tab on the ngrok site, click on Your Authtoken option.

 

In this section, you will encounter a multi-character code that consists of a sum of several letters and numbers. This code is for your account only and should not be passed on to anyone else, in which case you can reset it from the settings.

 

In the next step, run the terminal that we downloaded and enter the following command along with the Authtoken that you received.

Then in the next line, enter the following command with the local ip that you received, in the part that is written ip_of_esp32 then press enter.

In the following, you will encounter the following information with a new window that gives you links to access the web server via the cloud. You will be able to access your web server by searching for the link specified in the image from anywhere and with any device.

 

Finally, by searching for the link in the browser, you will receive the image instantly.

 


The last word with Cifer


In this project, as before, we created a simple web server to stream images and access it locally, and using the ngrok service, we sent the information of this web server to the cloud and received it with a specific link, which allowed us to Be able to connect to it anytime and anywhere. This project can be seen in many examples of security and surveillance products, for example security cameras known as ip cameras or child care products that provide you with a surveillance system.

 

If you encounter any problems during the setup and implementation of this project, do not hesitate to submit your question at the end of this post. I will answer your problem as soon as possible. Also, if there is a problem in the code or the execution steps, you can inform through this way.

Leave a Reply

Your email address will not be published. Required fields are marked *