0% found this document useful (0 votes)
145 views9 pages

A Brief Blog For Smart Parking Using ESP32 With Camera Module and Some Recommended A Devices That Makes Easy To Make The Smart Parking System

The document describes how to build a smart parking system using an ESP32, camera module, proximity sensor, servo motor and LCD display. It provides instructions on connecting the components, setting up the Google Drive API and includes sample code to take photos of vehicles, check for available spaces and upload photos to a Google Drive folder.

Uploaded by

esayas080808
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
145 views9 pages

A Brief Blog For Smart Parking Using ESP32 With Camera Module and Some Recommended A Devices That Makes Easy To Make The Smart Parking System

The document describes how to build a smart parking system using an ESP32, camera module, proximity sensor, servo motor and LCD display. It provides instructions on connecting the components, setting up the Google Drive API and includes sample code to take photos of vehicles, check for available spaces and upload photos to a Google Drive folder.

Uploaded by

esayas080808
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

A brief blog for smart parking using ESP32 with camera module and some recommended a devices

that makes easy to make the smart parking system.

Shahnawaz Alam

·Apr 16, 2023·

5 min read

Table of contents

Query

Process

Components

Connection

Drive API Setup

o
Code

Final Instruction

Search Quotes

Query

Setup the code and connection for the smart parking system with esp32 with the camera module,
proximity sensor, and servo sensor taking the picture of the vehicle send it to the cloud google drive and
display the left slot on the LCD

Process

To set up a smart parking system using ESP32 with a camera module, proximity sensor, servo sensor, and
display, which takes a picture of the vehicle and sends it to Google Drive and displays the available slots
on the LCD, you will need to follow these steps:

Components

1. Gather the required components:

 ESP32 board

 Camera module (such as the OV7670 camera module)

 Proximity sensor (such as the HC-SR04 ultrasonic sensor)

 Servo motor

 Breadboard

 Jumper wires

 Power supply (such as a USB cable and power bank)

 LCD display module

 Google Drive API credentials

Connection

1. Connect the components:


 Connect the VCC and GND pins of the camera module to the 3.3V and GND pins on the ESP32
board, respectively.

 Connect the SCL and SDA pins of the camera module to the corresponding pins on the ESP32
board (such as pins 22 and 21, respectively).

 Connect the VCC and GND pins of the proximity sensor to the 5V and GND pins on the ESP32
board, respectively.

 Connect the trig and echo pins of the proximity sensor to any two digital pins on the ESP32
board (such as pins 12 and 14).

 Connect the signal pin of the servo motor to any digital pin on the ESP32 board (such as pin 27),
and the VCC and GND pins to the 5V and GND pins on the ESP32 board, respectively.

 Connect the SDA and SCL pins of the LCD display module to the corresponding pins on the ESP32
board (such as pins 4 and 5, respectively), and the VCC and GND pins to the 5V and GND pins on
the ESP32 board, respectively.

Drive API Setup

1. Set up the Google Drive API:

 Go to the Google API Console and create a new project.

 Enable the Google Drive API and create a new OAuth 2.0 client ID.

 Download the JSON file with the API credentials.

1. Write the code: Here's some sample code that you can use as a starting point for your smart
parking system:

Code

COPY

COPY

Explain

#include <Servo.h>

#include <Wire.h>

#include "esp_camera.h"

#include <WiFi.h>

#include <HTTPClient.h>

#include <ArduinoJson.h>

#include <WiFiClientSecure.h>

#include <LiquidCrystal_I2C.h>
#define TRIG_PIN 12

#define ECHO_PIN 14

#define SERVO_PIN 27

#define LCD_ADDR 0x27

#define LCD_COLS 16

#define LCD_ROWS 2

Servo myservo;

int angle = 0;

const char* ssid = "your_SSID";

const char* password = "your_PASSWORD";

const char* gdrive_token = "your_GDRIVE_TOKEN";

WiFiClientSecure client;

HTTPClient http;

LiquidCrystal_I2C lcd(LCD_ADDR, LCD_COLS, LCD_ROWS);

String get_gdrive_folder_id() {

[Link]("Bearer " + String(gdrive_token));

[Link](client, "[Link]
%27+and+mimeType%3D%27application%[Link]
%27&fields=files(id)&key=YOUR_API_KEY");

[Link]("Content-Type", "application/json");

int httpCode = [Link]();

String folder_id = "";

if (httpCode == HTTP_CODE_OK) {
String payload = [Link]();

StaticJsonDocument<512> doc;

DeserializationError error = deserializeJson(doc, payload);

if (!error) {

[Link]();

[Link](request_body.c_str(), request_body.length());

int bytes_sent = 0;

while (bytes_sent < file_size) {

int bytes_to_read = file_size - bytes_sent;

if (bytes_to_read > 1024) { bytes_to_read = 1024; }

uint8_t buffer[bytes_to_read];

int bytes_read = [Link](buffer, bytes_to_read);

[Link](buffer, bytes_read);

bytes_sent += bytes_read;

[Link]();

String response = [Link]();

[Link]();

void setup() {

[Link](115200);

pinMode(TRIG_PIN, OUTPUT);

pinMode(ECHO_PIN, INPUT);

[Link](SERVO_PIN);

[Link]();
[Link]();

[Link]();

[Link](0, 0);

[Link]("Smart Parking");

[Link](0, 1);

[Link]("Initializing...");

[Link](ssid, password);

while ([Link]() != WL_CONNECTED) {

delay(1000);

[Link]("Connecting to WiFi...");

[Link]("Connected to WiFi");

camera_config_t config;

config.ledc_channel = LEDC_CHANNEL_0;

config.ledc_timer = LEDC_TIMER_0;

config.pin_d0 = 5;

config.pin_d1 = 18;

config.pin_d2 = 19;

config.pin_d3 = 21;

config.pin_d4 = 36;

config.pin_d5 = 39;

config.pin_d6 = 34;

config.pin_d7 = 35;

config.pin_xclk = 0;

config.pin_pclk = 22;

config.pin_vsync = 25;

config.pin_href = 23;

config.pin_sscb_sda = 26;

config.pin_sscb_scl = 27;
config.pin_pwdn = -1;

config.pin_reset = -1;

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;

esp_err_t err = esp_camera_init(&config);

if (err != ESP_OK) {

[Link]("Camera init failed with error 0x%x", err);

return;

[Link]();

[Link](0, 0);

[Link]("Smart Parking");

[Link](0, 1);

[Link]("Ready");

delay(2000);

void loop() {

float duration, distance;

digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);

digitalWrite(TRIG_PIN, HIGH);

delayMicroseconds(10);

digitalWrite(TRIG_PIN, LOW);

duration = pulseIn(ECHO_PIN, HIGH);

distance = duration * 0.034 / 2;

int available_slots = distance / 50;

if (available_slots < 0) { available_slots = 0; }

[Link]();

[Link](0, 0);

[Link]("Available slots:");

[Link](0, 1);

[Link](String(available_slots));

if (available_slots > 0) {

float angle = map(available_slots, 0, MAX_SLOTS, 0, 180);

[Link](angle);

delay(500);

camera_fb_t* fb = NULL;

fb = esp_camera_fb_get();

if (!fb) {

[Link]("Failed to capture image");

return;

[Link]("Captured image with size %u\n", fb->len);

uploadToGoogleDrive(fb);

esp_camera_fb_return(fb);

delay(5000);

}
}

Final Instruction

This code calculates the available parking slots based on the distance measured by the proximity sensor,
and then maps this value to an angle to control the servo motor. It then captures an image using the
camera module and uploads it to Google Drive using the uploadToGoogleDrive() function. Finally, it waits
for 5 seconds before repeating the process.

Note that you will need to replace YOUR_ACCESS_TOKEN and YOUR_FOLDER_ID with your own values in
the uploadToGoogleDrive() function, as well as ssid and password with your WiFi credentials in
the setup() function. You will also need to adjust the pin numbers and camera configuration to match
your own hardware setup.

Search Quotes

1. "Discover the Future of Parking: How Smart Parking Systems Are Revolutionizing Urban Mobility.
Learn about the benefits of IoT-enabled solutions for drivers, cities, and businesses."

2. "Say Goodbye to Parking Hassles: How Smart Parking Systems Are Streamlining Parking. Explore
the latest innovations in parking technology, including sensors, data analytics, and mobile apps."

3. "Maximize Your Parking Efficiency: How Smart Parking Systems Can Optimize Your Parking
Operations. Find out how automated parking systems can reduce congestion, increase revenue,
and improve customer satisfaction."

4. "The Ultimate Guide to Smart Parking Systems: How to Choose the Right Solution for Your
Needs. Get expert advice on selecting the best parking technology for your business or
municipality."

5. "From Parking Lots to Smart Cities: How Smart Parking Systems are Driving Sustainable Urban
Development. Discover the role of smart parking in creating more livable, eco-friendly cities for
the future."

You might also like