ESP-32 Cam + Arduino IDE = IOT Surveillance Car Arduino Projects For Beginners







The AI-Thinker ESP32-CAM module comes with an ESP32-S chip, a very small size OV2640 camera and a microSD card slot. MicroSD card slot can be used to store images taken from the camera. Here HTTP communication protocol will be used to receive video streaming from the OV2640 camera over the web browser. 


Components Required

  • ESP32-CAM
  • 4WD CAR Chasis
  • FTDI Programmer
  • DC Motors (4)
  • Jumper Wires
  • Wifi Antenna
  • Motor Driver (L298N)
  • Battery 


Installing ESP32 Board on Arduino IDE

We will program the ESP32-CAM using Arduino IDE. For that, we have to install the ESP32 add-on on Arduino IDE.
To install the ESP32 board in your Arduino IDE, go to File> Preferences

Now copy the below link and paste it into the “Additional Board Manager URLs” field, as shown in the image below. Then, click the “OK” button:

Now go to Tools > Board > Boards Manager
In Boards Manager search for ESP32 and install the “ESP32 by Espressif Systems“.

Code Explanation

This ESP32 Surveillance Camera has a total of four code files that are attached at the end of the project and also can be downloaded from here. One is the main code file for camera and motors, and the other three codes are for web page, camera index, and camera pins.
Begin the program by including header files and selecting the right camera model. In the code, three camera models are defined. Uncomment the camera model that you are using. Here we have used the AI Thinker camera model that comes with ESP32.
#include "esp_camera.h"
#include <WiFi.h>
#include "camera_pins.h"
// Select camera model
//#define CAMERA_MODEL_WROVER_KIT
//#define CAMERA_MODEL_M5STACK_PSRAM
#define CAMERA_MODEL_AI_THINKER

Enter the Wi-Fi name and password of the network.
const char* ssid = "WiFi Name";
const char* password = "Password";

The four pins 4, 2, 14, and 15 of the ESP32 are used to control the DC motors.
extern int leftmotor1 =  4;
extern int leftmotor2 = 2;
extern int rightmotor1 = 14;
extern int rightmotor2 = 15;

Inside the void setup loop, begin the serial monitor and set the DC motors initially low.
void setup() {
  Serial.begin(115200);
  Serial.setDebugOutput(true);
  Serial.println();
  digitalWrite(leftmotor1, LOW);
  digitalWrite(leftmotor2, LOW);
  digitalWrite(rightmotor1, LOW);
  digitalWrite(rightmotor2, LOW)
Define the Pins of DC motors as Output.
pinMode(leftmotor1, OUTPUT);
pinMode(leftmotor2, OUTPUT);
pinMode(rightmotor1, OUTPUT);
pinMode(rightmotor2, OUTPUT);

Connect to the Wi-Fi using the given credentials and wait for the confirmation
WiFi.begin(ssid, password);
 while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");

 

Programming ESP32 for Surveillance Robot

To upload the code, connect the FDTI board to your laptop and select the ‘ESP32 Wrover Module’ as your board. Also, change the other settings according to this picture:
Programming ESP32 for Surveillance Robot

Before uploading the code, press the ESP32 reset button and then click on the upload button.
Note: If you get errors while uploading the code, check that IO0 is connected to GND, and you have selected the right settings in the Tools menu.
After uploading the code, disconnect the IO0 and GND pin. Then open the serial monitor and change the baud rate to 115200. After that press the ESP32 reset button, it will print the ESP IP address and port no on the serial monitor.
ESP32 CAM- Surveillance Robot IP Address

Now to access the Webpage for ESP32 video streaming and car controls, navigate to your browser and enter the ESP IP address. It will take you to the web page.
ESP32 CAM- Surveillance Robot Controllers


Comments

  1. A very Simple Arduino 12 Hours Clock... Easy to build...
    Please like, share and subscribe
    http://bit.ly/2H9n6Aa
    #HobbyElectronicsPAK

    ReplyDelete
  2. Thanks for this keep Working Stay Blessed

    ReplyDelete
  3. Thanks for sharing about wall clock. Your Blog Content is realy informative for Us...........


    vintage wall clocks
    pendulum wall clocks
    Study Table Lamps
    DIY Wall Clock
    Wedding Anniversary Gifts

    ReplyDelete

Post a Comment

Popular posts from this blog

32 Inch DIY Arduino RTC Wall Clock

DIY Arduino CNC [Updated]