0% found this document useful (0 votes)
40 views16 pages

Solar Wireless Electric Vehicle Charging

This project presents an IoT-enabled smart electric vehicle charging station that integrates vehicle detection, power monitoring, and automated billing. Utilizing an ESP32 microcontroller, the system features real-time web monitoring, automatic cost calculation, and a user-friendly interface. The expected outcome is a cost-effective solution for enhancing EV charging infrastructure in public and commercial settings.
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)
40 views16 pages

Solar Wireless Electric Vehicle Charging

This project presents an IoT-enabled smart electric vehicle charging station that integrates vehicle detection, power monitoring, and automated billing. Utilizing an ESP32 microcontroller, the system features real-time web monitoring, automatic cost calculation, and a user-friendly interface. The expected outcome is a cost-effective solution for enhancing EV charging infrastructure in public and commercial settings.
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
You are on page 1/ 16

1.

Abstract

This project develops an IoT-enabled smart electric vehicle charging station


with automated billing capabilities. The system addresses the growing need
for efficient EV charging infrastructure by integrating vehicle detection,
power monitoring, and cost calculation in a single solution. Using an ESP32
microcontroller with WiFi connectivity, the station employs ultrasonic sensors
for vehicle presence detection, voltage/current sensors for power
measurement, and a relay-based control system. Key features include real-
time web-based monitoring, automatic billing calculation, and LCD display for
local status updates. The expected outcome is a cost-effective charging
solution that enhances user convenience while providing accurate energy
consumption data, with potential applications in public charging networks
and commercial parking facilities.
2. Introduction

The rapid adoption of electric vehicles has created an urgent need for
intelligent charging solutions that go beyond simple power delivery. Current
charging stations often lack real-time monitoring, accurate billing
mechanisms, and vehicle detection capabilities. This project bridges these
gaps by creating a comprehensive charging management system.

Key challenges addressed:

 Precise vehicle detection for automatic charging initiation


 Accurate power measurement for fair billing
 User-friendly interfaces (both local and remote)
 Secure power control mechanisms

The system implements:

 Ultrasonic distance measurement for vehicle presence detection


 Voltage divider circuit for high-voltage monitoring
 Current sensing for real-time power calculation
 Web-based dashboard for remote monitoring
 LCD display for local status information
 Automatic cost calculation based on energy consumption
3. Hardware Components

Control Unit:

 ESP32 Development Board

Sensing Modules:

 HC-SR04 Ultrasonic Sensor


 Voltage Divider Circuit (3kΩ + 7.5kΩ)
 Current Sensor Module

User Interface:

 I2C LCD Display (16x2)


 WiFi Antenna (ESP32 integrated)

Power Control:

 SPDT Relay Module


 Circuit Protection Components

Power Supply:

 5V DC Power Source
 Voltage Regulation Circuitry
4. Circuit Connections

Step-by-Step Wiring Guide:

1. Ultrasonic Sensor:

o VCC → 5V
o GND → Common Ground
o TRIG → GPIO14
o ECHO → GPIO12
2. LCD Display (I2C):

o SDA → GPIO21
o SCL → GPIO22
o VCC → 5V
o GND → Common Ground
3. Voltage Measurement:

o Voltage Divider Output → GPIO35 (ADC1_CH7)


4. Current Sensor:

o Output → GPIO32 (ADC1_CH4)


o VCC → 3.3V
o GND → Common Ground
5. Relay Control:

o IN → GPIO27
o VCC → 5V
o GND → Common Ground
o NO → Charging Cable Positive
o COM → Power Source Positive
// Include necessary libraries
#include <Wire.h> // For I2C communication
#include <LiquidCrystal_I2C.h> // For I2C LCD display
#include <WiFi.h> // For WiFi connectivity
#include <WebServer.h> // For web server functionality
#include <HTTPClient.h> // For HTTP requests (not used in this
code)
#include <ArduinoJson.h> // For JSON data handling

// Initialize I2C LCD with address 0x27, 16 columns and 2 rows


LiquidCrystal_I2C lcd(0x27, 16, 2);

// Ultrasonic Sensor Pins


const int trigPin = 14; // Trigger pin for HC-SR04 ultrasonic sensor
const int echoPin = 12; // Echo pin for HC-SR04 ultrasonic sensor

// Relay control pin


const int relayPin = 27; // GPIO pin connected to relay control

// Sensor pins
#define ANALOG_IN_PIN 35 // Analog pin for voltage measurement
#define CURRENT_SENSOR_PIN 32 // Analog pin for current measurement

// Voltage divider constants


float R1 = 3000.0; // Resistor R1 value in ohms (voltage divider top
resistor)
float R2 = 7500.0; // Resistor R2 value in ohms (voltage divider bottom
resistor)
float ref_voltage = 5.0; // Reference voltage for ADC calculations
float adc_voltage = 0.0; // Measured voltage from ADC
float in_voltage = 0.0; // Calculated input voltage after voltage
divider
float current_value = 0.0; // Measured current value

// Billing variables
unsigned long startTime = 0; // Timestamp when charging starts
(millis())
unsigned long chargingTime = 0; // Total charging duration in
milliseconds
bool isCharging = false; // Flag to track charging state
float costPerKWh = 13.03; // Cost per kilowatt-hour in rupees
int personCount = 0; // Counter for number of charging
sessions

// WiFi credentials
const char* ssid = "BATCH3"; // WiFi network name
const char* password = "123456789@Batch3"; // WiFi password

// Web server on port 80


WebServer server(80);

// Project title for web interface


const String projectTitle = "Smart EV Charging Station";

// Data structure to hold all charging information


struct ChargingData {
float distance = 0; // Distance from ultrasonic sensor in cm
float voltage = 0; // Measured voltage in volts
float current = 0; // Measured current in amps
String relayStatus = "OFF"; // Relay state ("ON"/"OFF")
String chargingTime = "00:00:00"; // Formatted charging duration
float cost = 0; // Calculated cost in rupees
int personCount = 0; // Number of charging sessions
String status = "Waiting..."; // System status message
} currentData;

// CSS styling for web interface


const String htmlStyle = R"(
<style>
/* CSS styles for the web interface */
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 0;
padding: 0;
background-color: #f0f2f5;
color: #333;
}
/* Container styling */
.container {
max-width: 800px;
margin: 30px auto;
background-color: white;
padding: 30px;
border-radius: 12px;
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
/* Header styling */
h1 {
color: #2c3e50;
text-align: center;
margin-bottom: 30px;
font-size: 28px;
padding-bottom: 15px;
border-bottom: 1px solid #eee;
}
/* Sensor container layout */
.sensor-container {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 20px;
margin-bottom: 25px;
}
/* Individual sensor box styling */
.sensor-box {
width: 30%;
min-width: 250px;
padding: 20px;
border-radius: 8px;
background-color: white;
box-shadow: 0 2px 8px rgba(0,0,0,0.08);
border: 1px solid #e0e0e0;
transition: transform 0.2s, box-shadow 0.2s;
}
/* Hover effects */
.sensor-box:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
/* Sensor title styling */
.sensor-title {
font-weight: 600;
margin-bottom: 15px;
font-size: 18px;
color: #3498db;
display: flex;
align-items: center;
gap: 8px;
}
/* Decorative element before title */
.sensor-title:before {
content: "";
display: inline-block;
width: 6px;
height: 20px;
background-color: #3498db;
border-radius: 3px;
}
/* Sensor value display */
.sensor-value {
font-size: 28px;
text-align: center;
margin: 20px 0;
font-weight: 300;
}
/* Alert status styling */
.alert {
color: #e74c3c;
font-weight: bold;
}
/* Normal status styling */
.normal {
color: #27ae60;
}
/* Timestamp styling */
.timestamp {
text-align: center;
color: #7f8c8d;
font-size: 14px;
margin-top: 30px;
padding-top: 15px;
border-top: 1px solid #eee;
}
/* Status indicator styling */
.status {
text-align: center;
font-weight: bold;
padding: 8px;
border-radius: 6px;
margin-top: 10px;
}
/* Charging state colors */
.charging {
background-color: #27ae60;
color: white;
}
.not-charging {
background-color: #e74c3c;
color: white;
}
.waiting {
background-color: #f39c12;
color: white;
}
.active {
background-color: #3498db;
color: white;
}
/* Responsive design for smaller screens */
@media (max-width: 700px) {
.container {
margin: 15px;
padding: 20px;
}
.sensor-box {
width: 100%;
min-width: auto;
}
}
</style>
)";

// Handle root web request


void handleRoot() {
String html = "<!DOCTYPE html><html><head>";
html += "<title>" + projectTitle + "</title>";
html += "<meta http-equiv='refresh' content='5'>"; // Auto-refresh
every 5 seconds
html += htmlStyle;
html += "</head><body><div class='container'>";
html += "<h1>" + projectTitle + "</h1>";

html += "<div class='sensor-container'>";

// Distance display box


html += "<div class='sensor-box'>";
html += "<div class='sensor-title'>Distance</div>";
html += "<div class='sensor-value'>" + String(currentData.distance, 1)
+ " cm</div>";
if (currentData.distance < 10.0) {
html += "<div class='status active'>VEHICLE DETECTED</div>";
} else {
html += "<div class='status waiting'>NO VEHICLE</div>";
}
html += "</div>";
// Voltage display box
html += "<div class='sensor-box'>";
html += "<div class='sensor-title'>Voltage</div>";
html += "<div class='sensor-value'>" + String(currentData.voltage, 1) +
" V</div>";
if (currentData.voltage > 4.0) {
html += "<div class='status normal'>NORMAL</div>";
} else {
html += "<div class='status alert'>LOW VOLTAGE</div>";
}
html += "</div>";

// Current display box


html += "<div class='sensor-box'>";
html += "<div class='sensor-title'>Current</div>";
html += "<div class='sensor-value'>" + String(currentData.current, 2) +
" A</div>";
if (currentData.current > 0.1) {
html += "<div class='status normal'>CHARGING</div>";
} else {
html += "<div class='status waiting'>NO CURRENT</div>";
}
html += "</div>";

// Relay status box


html += "<div class='sensor-box'>";
html += "<div class='sensor-title'>Charger Status</div>";
html += "<div class='sensor-value'>" + currentData.relayStatus +
"</div>";
if (currentData.relayStatus == "ON") {
html += "<div class='status charging'>ACTIVE</div>";
} else {
html += "<div class='status not-charging'>INACTIVE</div>";
}
html += "</div>";

// Charging time box


html += "<div class='sensor-box'>";
html += "<div class='sensor-title'>Charging Time</div>";
html += "<div class='sensor-value'>" + currentData.chargingTime +
"</div>";
if (currentData.relayStatus == "ON") {
html += "<div class='status active'>IN PROGRESS</div>";
} else {
html += "<div class='status waiting'>NOT CHARGING</div>";
}
html += "</div>";

// Cost display box


html += "<div class='sensor-box'>";
html += "<div class='sensor-title'>Cost</div>";
html += "<div class='sensor-value'>" + String(currentData.cost, 2) + "
INR</div>";
if (currentData.cost > 0) {
html += "<div class='status normal'>CHARGED</div>";
} else {
html += "<div class='status waiting'>NO CHARGE</div>";
}
html += "</div>";

html += "</div>"; // Close sensor container

// Footer with status information


html += "<div class='timestamp'>Persons charged: " +
String(currentData.personCount) + " | Status: " + currentData.status +
"</div>";
html += "</div></body></html>";

server.send(200, "text/html", html);


}

// API endpoint to get JSON data


void handleAPI() {
StaticJsonDocument<200> jsonDocument;
// Populate JSON document with current data
jsonDocument["distance"] = currentData.distance;
jsonDocument["voltage"] = currentData.voltage;
jsonDocument["current"] = currentData.current;
jsonDocument["relayStatus"] = currentData.relayStatus;
jsonDocument["chargingTime"] = currentData.chargingTime;
jsonDocument["cost"] = currentData.cost;
jsonDocument["personCount"] = currentData.personCount;
jsonDocument["status"] = currentData.status;

String response;
serializeJson(jsonDocument, response);
server.send(200, "application/json", response);
}
// Measure distance using ultrasonic sensor
float measureDistance() {
// Send 10us pulse to trigger pin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

// Measure pulse duration on echo pin


long duration = pulseIn(echoPin, HIGH);

// Calculate distance in cm (speed of sound is 343 m/s or 0.0343 cm/µs)


float distance = (duration * 0.0343) / 2;
return distance;
}

// Read and calculate input voltage


void readVoltage() {
int adc_value = analogRead(ANALOG_IN_PIN); // Read analog value (0-
4095)
adc_voltage = (adc_value * ref_voltage) / 4095.0; // Convert to voltage
in_voltage = adc_voltage / (R2 / (R1 + R2)); // Calculate input voltage
using voltage divider
}

// Read and calculate current


void readCurrent() {
int current_adc_value = analogRead(CURRENT_SENSOR_PIN); // Read analog
value
float sensor_voltage = (current_adc_value * ref_voltage) / 4095.0; //
Convert to voltage

// Simplified current calculation (adjust based on your current sensor)


current_value = sensor_voltage * 1.0;

// Predefined conditions for demonstration


if (in_voltage == 0.0) {
current_value = 0.0; // No voltage means no current
} else if (in_voltage >= 4.5 && in_voltage < 5.6) {
current_value = 0.24; // Example current value for specific voltage
range
}
}
// Display billing information on LCD
void displayBill() {
// Calculate power (P = V*I) and energy (E = P*t)
float power = in_voltage * current_value; // Power in watts
float energy = power * (chargingTime / 3600000.0); // Energy in kWh
(convert ms to hours)

// Calculate cost (energy * rate)


float cost = energy * costPerKWh; // Cost in rupees

// Convert charging time to hh:mm:ss format


unsigned long totalSeconds = chargingTime / 1000;
unsigned long hours = totalSeconds / 3600;
unsigned long minutes = (totalSeconds % 3600) / 60;
unsigned long seconds = totalSeconds % 60;

// Format time string


char timeStr[9];
sprintf(timeStr, "%02d:%02d:%02d", hours, minutes, seconds);

// Update current data structure


currentData.cost = cost;
currentData.chargingTime = String(timeStr);
currentData.personCount = personCount;

// Display on LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Time: ");
lcd.print(hours);
lcd.print(":");
if (minutes < 10) lcd.print("0"); // Leading zero for minutes
lcd.print(minutes);
lcd.print(":");
if (seconds < 10) lcd.print("0"); // Leading zero for seconds
lcd.print(seconds);

lcd.setCursor(0, 1);
lcd.print("Cost: ");
lcd.print(cost, 2); // Display cost with 2 decimal places
lcd.print(" INR");

delay(5000); // Show bill for 5 seconds


lcd.clear();
}
// Setup function - runs once at startup
void setup() {
// Initialize serial communication for debugging
Serial.begin(115200);

// Initialize LCD
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("EV Charging");
delay(2000);
lcd.clear();

// Configure pins
pinMode(trigPin, OUTPUT); // Ultrasonic trigger pin as output
pinMode(echoPin, INPUT); // Ultrasonic echo pin as input
pinMode(relayPin, OUTPUT); // Relay control pin as output

// Initialize relay to OFF state (active-low)


digitalWrite(relayPin, HIGH);
lcd.clear();

// Connect to WiFi
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());

// Configure web server routes


server.on("/", handleRoot); // Root page handler
server.on("/api", handleAPI); // API endpoint handler
server.begin();
Serial.println("HTTP server started");
}

// Main program loop


void loop() {
server.handleClient(); // Handle incoming web requests

// Measure distance to detect vehicle


float distance = measureDistance();
currentData.distance = distance;

// Read voltage and current


readVoltage();
currentData.voltage = in_voltage;

readCurrent();
currentData.current = current_value;

// Display sensor readings on LCD


lcd.clear();
lcd.setCursor(0, 0);
lcd.print("V:");
lcd.print(in_voltage, 1);
lcd.print("V ");
lcd.print("I:");
lcd.print(current_value, 2);
lcd.print("A");

lcd.setCursor(0, 1);
lcd.print("D:");
lcd.print(distance, 1);
lcd.print("CM ");

// Control relay based on distance and voltage


if (distance < 10.0) { // Vehicle detected within 10cm
if (!isCharging) {
// Start new charging session
startTime = millis();
isCharging = true;
personCount++;
currentData.personCount = personCount;
currentData.status = "Charging Started";
}
digitalWrite(relayPin, LOW); // Turn relay ON
currentData.relayStatus = "ON";
lcd.print("ON ");
} else {
if (isCharging) {
// Check if vehicle has left for 2 seconds
unsigned long currentTime = millis();
if (currentTime - startTime >= 2000) {
chargingTime = currentTime - startTime;
isCharging = false;
currentData.status = "Charging Completed";
displayBill(); // Show charging summary
}
}
digitalWrite(relayPin, HIGH); // Turn relay OFF
currentData.relayStatus = "OFF";
lcd.print("OFF ");
}

delay(1000); // Main loop delay


}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy