Street Light Automation
Street Light Automation
0
STREETLIGHT AUTOMATION
1
STREETLIGHT AUTOMATION
2
INDUSTRIAL IoT & INDUSTRY 4.0
Prepared by:
M.Kalaiyarasi- 420422106029
J.Lathika - 420422106033
K.Jeevitha - 420422106027
S.Deepa - 420422106010
Guided by:
Ramkumar
Unity Developer
3
TABLE OF CONTENTS:
S.NO: CONTENTS:
1.
INTRODUCTION
2.
PROJECT DESCRITION
3.
REQUIREMENT NEEDED
4.
WOKWI
5.
THINKSPEAK
6.
UNITY
7.
AR FOUNDATION
8.
POWER BI
9.
OUTPUT
10.
CONCLUSION
4
TRAINING OBJECTIVES:
• Understand the concept of IoT, AR, & Cloud principles.
• Identify the requirements and use cases for Implementation.
• Implement the concepts using different tools and techniques (Wokwi,
ThingSpeak, PowerBI, and Unity3D).
• Develop the Projects and Implementation/Execution.
PROJECT DESCRIPTION:
PROBLEM:
Smart street lights face technical, hardware, and software issues. Connectivity
problems, sensor malfunctions, and LED lamp failures occur. Weather-related
damage, pollution, and cybersecurity vulnerabilities also impact performance.
Maintenance logistics, energy efficiency optimization, and data privacy concerns add
complexity. Additionally, integration challenges, user interface issues, and
scalability limitations hinder efficiency.
PROBLEM SOLUTION:
Smart street lights can be optimized using Wokwi's simulation tools to design and
test IoT systems. ThingSpeak's IoT platform enables real-time data collection and
analysis. Unity's 3D visualization enhances public engagement and awareness.
Power BI's data analytics and visualization capabilities provide insights into energy
efficiency, maintenance, and usage patterns. Integration of these tools enables:
✓ Real-time monitoring and control.
✓ Energy efficiency optimization.
✓ Predictive maintenance.
✓ Data-driven decision-making.
✓ Enhanced public engagement and safety.
REQUIREMENT NEEDED:
Software Names:
• Wokwi.
• Thingspeak.
• Unity3D.
• Power BI.
5
WOKWI:
➢ Wokwi is an online platform for simulating electronics, robotics, and IoT
projects.
➢ It allows users to design, test, and collaborate on projects virtually.
➢ No physical components or hardware needed.
➢ Supports various programming languages like C++, Python, and Arduino.
➢ Ideal for students, professionals, and hobbyists in electronics and robotics.
IN OUR PROJECT,
We used these components in Wokwi:
1. ESP32
2. Wokwi - Ultrasonic Sensor, LED & Connecting Wires.
CONNECTIONS:
WORKING:
➢ Streetlight automation utilizes an ultrasonic sensor and microcontroller to
detect objects within a set range, automatically controlling the streetlight's
ON/OFF status.
➢ The sensor emits high-frequency sound waves, measuring the Time-of-Flight
to calculate distance. When an object is detected within the range (e.g., 50 cm),
the microcontroller turns the streetlight on; otherwise, it remains off.
➢ Adjustable threshold values allow customized sensitivity. Operating modes
include automatic sensor-based control, manual override, and timed
scheduling.
➢ Benefits include energy efficiency, automated control, increased safety, and
reduced maintenance. Suitable applications range from public streetlights to
parking lots, building corridors, and security lighting.
6
CODE:
#include <WiFi.h>
#include <ThingSpeak.h>
const int ledPin= 15;
const int trig = 5;
const int echo = 18;
float distance;
long duration;
char ssid[] = "Wokwi-GUEST";
char pass [] = "";
WiFiClient client;
unsigned long myChannelNumber = 2041273;
const char * myWriteAPIKey = "GDBPDYHKD1GGL8DT";
int statusCode;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
WiFi.mode(WIFI_STA);
ThingSpeak.begin(client);
delay(1500);
pinMode(ledPin, OUTPUT);
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
}
long getdistance(){
digitalWrite(trig, LOW);
delayMicroseconds(2);
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);
duration = pulseIn(echo, HIGH);
return(duration*0.034/2);
Serial.println(duration);
7
}
void loop() {
if(WiFi.status() != WL_CONNECTED)
{
Serial.print("Attempting to connect");
while(WiFi.status() != WL_CONNECTED)
{
WiFi.begin(ssid, pass);
Serial.print(".");
delay(5000);
}
Serial.println("\nConnected");
}
if(getdistance()>200)
{
analogWrite(ledPin,50);
ThingSpeak.setField(2, 0);
Serial.println(0);
}
else
{
analogWrite(ledPin,255);
ThingSpeak.setField(2, 1);
Serial.println(1);
}
delay(10); // this speeds up the simulation
Serial.println(getdistance());
ThingSpeak.setField(1, getdistance());
statusCode = ThingSpeak.writeFields(myChannelNumber,myWriteAPIKey);
https://wokwi.com/projects/357273387246800897
CODE EXPLANATION:
How it works:
This is an Arduino-based project that uses the ESP32 board to connect to Wi-Fi and
send data to ThingSpeak, a popular IoT platform. The project also uses an ultrasonic
sensor (HC-SR04) to measure distance and control an LED accordingly.
1. The code initializes the Wi-Fi connection using the WiFi library and connects to
the specified network (Wokwi-GUEST).
2. It sets up the ThingSpeak connection using the ThingSpeak library and the
provided API key and channel number.
3. The code defines two functions: getdistance() to measure the distance using the
ultrasonic sensor, and loop() to execute the main logic.
4. In the loop() function, the code checks the Wi-Fi connection status and attempts
to reconnect if necessary.
5. It then measures the distance using the getdistance() function and checks if it's
greater than 200 units.
6. Based on the distance, the code sets the LED brightness using analogWrite() and
updates the ThingSpeak channel with the distance value and a binary value (0 or
1) indicating the LED status.
7. The code waits for 15 seconds before repeating the loop.
9
PURPOSE:
The purpose of this project is to:
1. Measure the distance using an ultrasonic sensor.
2. Control an LED based on the measured distance.
3. Send the distance value and LED status to ThingSpeak for IoT monitoring and
analysis.
EXAMPLE OUTPUT:
➢ Distance values measured by the ultrasonic sensor, printed to the serial console.
➢ LED brightness changes based on the measured distance.
➢ ThingSpeak channel updates with the distance value and LED status (0 or 1).
WOKWI OUTPUT:
10
THINKSPEAK:
THINKSPEAK OUTPUT:
11
THINKSPEAK FIELD CHART:
12
THINKSPEAK INTEGRATION:
We utilized ThingSpeak's IoT platform to monitor and analyze sensor data.
Two Fields Configuration
✓ Field 1: Humidity.
✓ Field 2: Temperature.
1. Log in to ThingSpeak.
2. Create a new channel.
3. Add fields for your sensor data (e.g., X, Y, Z axes).
Step 4:
13
UNITY:
➢ Unity is a leading cross-platform game engine and development environment.
➢ Supports 2D/3D game creation, simulations, and interactive experiences.
➢ Deploy on multiple platforms: PC, consoles, mobile, web, and VR/AR.
➢ Popular among indie devs and AAA game studios, with a vast asset store.
➢ Ideal for game development, architecture, product design, and more.
UNITY SNAPSHOT:
14
CREATING AN ENVIRONMENT IN UNITY:
Step 1:
1. Create a New Project.
2. Open Unity Hub.
3. Click "New" to create a project.
4. Choose project name, template (e.g., 3D), and location.
Step 2:
1. Set Up the Scene.
1. Create a new scene (File > New Scene).
2. Add a 3D object (e.g., cube) to the scene (GameObject > 3D Object > Cube).
3. Customize the environment by adding textures, lights, and other objects.
15
AR FOUNDATION:
AR CONVERSION STEPS UP TO APK GENERATION IN UNITY:
16
AR FOUNDATIOM OUTPUT SNAPSHOT:
17
POWER BI:
➢ Power BI is a business analytics service by Microsoft.
➢ It enables users to visualize and analyze data from various sources.
➢ Create interactive dashboards, reports, and data models.
➢ Enhance decision-making with real-time insights and trends.
➢ Transform data into actionable business intelligence.
18
Step 6: Visualize and Analyze
1. Create reports and dashboards.
2. Use visualizations (e.g., charts, tables).
3. Analyze data trends and insights.
POWER BI SNAPSHOT:
19
APK OUTPUT SNAPSHOT:
20
CONCLUSION:
The Streetlight Automation System using Ultrasonic Sensor with ESP32
successfully demonstrates a cost-effective and efficient solution for smart streetlight
management. By leveraging the ESP32 microcontroller and ultrasonic sensor, the
system detects pedestrian presence and adjusts streetlight brightness accordingly.
This results in significant energy savings, improved public safety, and enhanced user
experience. The system's scalability, reliability, and ease of implementation make it
an attractive solution for smart city initiatives.
With its potential to reduce energy consumption, decrease maintenance costs, and
improve public safety, this system can play a vital role in creating sustainable and
livable urban environments. Furthermore, the system's flexibility and adaptability
enable it to be integrated with other smart city systems, making it a valuable
contribution to the development of smart cities. The use of IoT technology and real-
time data analysis enables the system to respond dynamically to changing
environmental conditions, optimizing energy efficiency and public safety.
21