0% found this document useful (0 votes)
17 views

Street Light Automation

The document presents a project on Streetlight Automation utilizing IoT and Industry 4.0 principles, focusing on optimizing smart streetlights using tools like Wokwi, ThingSpeak, Unity, and Power BI. It outlines the project's objectives, problem description, solutions, and implementation details, including the use of an ultrasonic sensor and ESP32 microcontroller for real-time monitoring and control. The conclusion emphasizes the project's potential to enhance energy efficiency, public safety, and integration with smart city initiatives.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Street Light Automation

The document presents a project on Streetlight Automation utilizing IoT and Industry 4.0 principles, focusing on optimizing smart streetlights using tools like Wokwi, ThingSpeak, Unity, and Power BI. It outlines the project's objectives, problem description, solutions, and implementation details, including the use of an ultrasonic sensor and ESP32 microcontroller for real-time monitoring and control. The conclusion emphasizes the project's potential to enhance energy efficiency, public safety, and integration with smart city initiatives.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

INDUSTRIAL IoT & INDUSTRY 4.

0
STREETLIGHT AUTOMATION

ADHIPARASAKTHI ENGINEERING COLLEGE


MELMARUVATHUR - 603 319

Project Created by :M.Kalaiyarasi - 420422106029,


J.Lathika - 420422106033,
K.Jeevitha - 420422106027,
S.Deepa - 420422106010
Project Guided by :J.Jenisha AP/ECE
Project Created Date :23/10/2024
College Code :4204

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:

✓ VCC - esp 3V3


✓ Trig - esp D5
✓ Echo - esp D18
✓ GND - gnd

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);

if(statusCode == 200) { //successful writing code


Serial.println("Channel update successful.");
}
else {
8
Serial.println("Problem Writing data. HTTP error code :" +
String(statusCode));
}
delay(15000);
}

WOKWI PROJECT LINK:

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:

➢ ThingSpeak is an open-source Internet of Things (IoT) platform.


➢ It enables users to collect, analyze, and visualize sensor data.
➢ Developed by MathWorks, ThingSpeak supports various hardware platforms.
Including Arduino, Raspberry Pi, and ESP32 / ESP8266.
➢ The platform offers real-time data visualization and analysis.
➢ ThingSpeak supports multiple sensor types, including temperature, humidity, and
GPS.
➢ ThingSpeak integrates with MATLAB, Simulink, and other programming
languages.
➢ Ideal for IoT projects, prototyping, and data-driven decision-making.

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.

HOW WE CONNECTED WOKWI TO THINGSPEAK:


Step 1: Create a ThingSpeak Channel.

1. Log in to ThingSpeak.
2. Create a new channel.
3. Add fields for your sensor data (e.g., X, Y, Z axes).

Step 2: Get ThingSpeak API Key and Channel ID.


1. Go to your ThingSpeak channel.
2. Click "API Keys" tab.
3. Note the "Write API Key" and "Channel ID".

Step 3: Write Code to Send Data to ThingSpeak.

1. In Wokwi, write code to read sensor data.


2. Use the ThingSpeak API to send data to your channel.

Step 4:

1. Add Libraries of Wi-Fi & Thingspeak.


2. Also Write Codes of Wi-Fi 7 Thingspeak.

Step 5: Run Simulation and Send Data.


1. Run your Wokwi simulation.
1. 2. Verify data is sent to ThingSpeak.

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.

Step 3: Add Components


1. Add Components from Asset Store.
2. Use Unity's built-in components (e.g., Rigidbody, Collider).

RETRIEVING VALUES FROM THINGSPEAK IN UNITY:

Step 1: Add Canvas:


It used to screen the values to display.
Step 2: Import Jason Dot Net & Getdata.
Step 3: Modified the Program by Adding Fields.
Step 4: Added our Thingspeak. Read a Channel Feed link to unity program.

15
AR FOUNDATION:
AR CONVERSION STEPS UP TO APK GENERATION IN UNITY:

Step 1: Set up Unity for AR.


1. Install Unity's AR Foundation package (Window > Package Manager > AR
Foundation).

Step 2: Configure AR Session.


1. Create an AR Session (GameObject > 3D Object > AR Session).
2. Set AR Session Origin (e.g., Camera).
3. Configure AR Session Settings (e.g., plane detection, light estimation).

Step 3: Add AR Features.


1. Add AR Plane Detector (GameObject > 3D Object > AR Plane Detector).
2. Add AR Object Scanner (GameObject > 3D Object > AR Object Scanner).
3. Add AR Interaction (e.g., tap, pinch, rotate).

Step 4: Build and Export Android Project.


1. Go to File > Build Settings > Android.
2. Set Target Device (e.g., Android 8.0 or later).
3. Set Package Name and Minimum API Level.
4. Build and export project.

Step 5: Generate APK.


1. Open exported project in Android Studio.
2. Configure AndroidManifest.xml (e.g., permissions).
3. Build and generate APK (Build > Generate Signed Bundle/APK).

Step 6: Test and Distribute.


1. Install APK on Android device.
2. Test AR functionality.
3. Distribute APK through Google Play Store or other channels.

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.

STEPS TO EXTRACT DATA FROM THINGSPEAK FOR


POWERBI:
Step 1: Get ThingSpeak Data.
1. Log in to ThingSpeak.
2. Go to your channel.
3. Click "Data" tab.
4. Select "Feeds" or "All Feeds".
Step 2: Export Data as CSV
1. Click "Export" button.
2. Choose "CSV" format.
3. Select date range and fields.
4. Download the CSV file (e.g., feeds.csv).
Step 3: Prepare CSV for Power BI
1. Open feeds.csv in Excel or text editor.
2. Ensure data is in table format.
3. Remove unnecessary columns.
Step 4: Import CSV into Power BI
1. Open Power BI Desktop.
2. Click "Get Data" > "Text/CSV".
3. Select feeds.csv.
4. Click "Load".
Step 5: Transform and Model Data
1. Use Power Query Editor to transform data.
2. Convert data types (e.g., date, numeric).
3. Create data models.

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

You might also like