Final Project View
Final Project View
AND RTC
A PROJECT REPORT
Submitted by
VINOTHIN T 211414104308
YENUGU VENKATESH 211414104313
RITESH ASWIN RAAM S G 211414104221
Of
BACHELOR OF ENGINEERING
in
APRIL 2018
i
ANNA UNIVERSITY: CHENNAI 600 025
BONAFIDE CERTIFICATE
SIGNATURE SIGNATURE
Dr. S. MURUGAVALLI, M.E., Ph.D., Mr. S.A.K. JAINULABUDEEN, M.Tech.,
PROFESSOR SUPERVISOR
HEAD OF THE DEPARTMENT ASSISTANT PROFESSOR
DEPARTMENT OF CSE, DEPARTMENT OF CSE
PANIMALAR ENGINEERING COLLEGE, PANIMALAR ENGINEERING COLLEGE,
NASARATHPETTAI, NASARATHPETTAI,
POONAMALLEE, POONAMALLEE,
CHENNAI-600 123. CHENNAI-600 123.
Certified that the above candidate(s) was examined in the Anna University
ii
My sincere, humble and heartfelt thanks and praises to our honorable Founder
and Chairman Late Dr. JEPPIAAR, M.A., B.L., Ph.D., for his sincere
Endeavor in educating us in his reputed institution.
We would like to express our deep gratitude to our respected Secretary and
Correspondent Dr. P. CHINNADURAI, M.A., Ph.D. for his kind words and
enthusiastic motivation, which inspired us a lot in completing this project.
We also express our gratitude to our Principal Dr. K. MANI, M.E., Ph.D.,
who helped us in completing the project.
We take this opportunity to thank our beloved parents, friends and teachers for
their constant support and encouragement.
VINOTHIN T
YENUGU VENKATESH
RITESH ASWIN RAAM S G
iii
ABSTRACT
governance, safety and security, smart lighting system, etc. The main focus of
reduction in the required budget of electricity for street lights. Reducing power
as adaptive street lighting. The main focus of this work is to present a design of
electricity for street lights. The complete system will work on RTC (Real Time
Clock) where lights will be running at 100 % intensity in peak traffic time and
with reduced intensity after peak traffic time. Lights will be obscured when no
action is detected and will light up when some movement is detected using PIR
(Passive Infrared Sensor).During day time the LDR (Light Dependent Resistor)
checks the atmospheric brightness and if it is low it makes the lights glow with
full intensity.
In case of any failures on street lamps GSM (Global System for Mobile
iv
TABLE OF CONTENTS
ACKNOWLEDGEMENT iii
ABSTRACT iv
1. INTRODUCTION 1
1.4.1 LDR 5
1.4.2 PIR 6
1.4.3 RTC 7
1.4.4 Arduino 8
2. LITERATURE SURVEY 21
3. SYSTEM ANALYSIS 31
v
3.5 Software Requirement 33
4. SYSTEM ARCHITECTURE 34
4.2 Algorithm 35
4.3 Pseudocode 36
5. CONCLUSION 37
5.1 Conclusion 38
6. APPENDICES 39
A1 Coding 40
A2 Screenshots 54
7. REFERENCES 57
vi
LIST OF FIGURES
FIGURE PAGE
TITLE
NO. NO.
1.3 Flowchart 4
1.4.3.1 RTC 8
1.4.4.1 Arduino 10
vii
LIST OF TABLES
FIGURE PAGE
TITLE
NO. NO.
LIST OF ABBREVIATIONS
SYMBOL DESCRIPTION
viii
CHAPTER 1
INTRODUCTION
ix
x
xi
CHAPTER 1
INTRODUCTION
Automatic Street Light Control System is a simple yet powerful concept.
By using this system manual works are 100% removed. It automatically
switches ON lights when the sunlight goes below the visible region of our eyes.
This is done by a sensor called Light Dependant Resistor (LDR) which senses
the light actually like our eyes. It automatically switches OFF lights whenever
the sunlight comes, visible to our eyes. By using this system energy
consumption is also reduced because nowadays the manually operated street
lights are not switched off even the sunlight comes and also switched on earlier
before sunset. The working of relay is also known. Street light controllers are
smarter versions of the mechanical or electronic timers previously used for
street light ON-OFF operation. They come with energy conservation options
like twilight saving, staggering or dimming. Also many street light controllers
come with an real time clock to give the best ON-OFF time and energy saving.
Automatic Street Light Control System is a simple and powerful concept, which
uses sensors as a switch to switch ON and OFF the street light automatically.
By using this system manual works are removed. It automatically switches
ON lights when the sunlight goes below the visible region of our eyes. It
automatically switches OFF lights under illumination by sunlight. This is done
by a sensor called Light Dependant Resistor (LDR) which senses the light
actually like our eyes .By using this system energy consumption is also reduced
because now-a-days the manually operated street lights are not switched
off properly even the sunlight comes and also not switched on earlier
before sunset. In sunny and rainy days, ON time and OFF time differ
significantly which is one of the major disadvantage of using timer circuits
or manual .
1
A street light, lamppost, street lamp, light standard, or lamp standard
is a raised source of light on the edge of a road or walkway, which is turned on
or lit at a certain time every night. Modern lamps may also have light-sensitive
photocells to turn them on at dusk, off at dawn, or activate automatically in dark
weather. In older lighting this function would have been performed with the aid
of a solar dial. It is not uncommon for street lights to be on poles which have
wires strung between them, or mounted on utility poles The complete system
will work on RTC (Real Time Clock) where lights will be running at 100 %
intensity in peak traffic time and with reduced intensity after peak traffic
time.Lights will be obscured when no action is detected and will light up when
some movement is detected using PIR (Passive Infrared Sensor).In case of any
failures on street lamps GSM (Global System for Mobile Communications )
automatically sends the message to the service department using a mobile
network.Automatic Streetlight needs no manual operation of switching ON
and OFF. The system itself detects whether there is need for light or not. When
darkness rises to a certain.
Power Supply
GSM
PIR Sensor
2
1.2 LIST OF COMPONENTS
1. LDR 4
2. PIR 4
3. RTC 1
4. GSM MODULE 1
5. ARDUINO BOARD 1
6. RESISTORS 1K ohm 4
7. LED 8
8. POWER SUPPLY 5V 1
3
1.3FLOWCHART RTC
if lamp doesn"t
glows
Lamp glows on partia
Lamp does not glows
lamp glows on full lamp glows on 20% intensty
intensity intensity
A message is send
using GSM module
Type : Passive
Working Principle : Photoconductivity
Electronic Symbol
4
A photoresistor is made of a high resistance semiconductor. In the dark, a
photoresistor can have a resistance as high as several megaohms (MΩ), while in
the light, a photoresistor can have a resistance as low as a few hundred ohms. If
incident light on a photoresistor exceeds a certain frequency, photons absorbed
by the semiconductor give bound electrons enough energy to jump into
the conduction band. The resulting free electrons (and their hole partners)
conduct electricity, thereby lowering resistance. The resistance range and
sensitivity of a photoresistor can substantially differ among dissimilar devices.
Moreover, unique photoresistors may react substantially differently to photons
within certain wavelength bands.
LDR 1.4.1.1
1.4.2 PIR
5
a human, passes in front of the background, such as a wall, the temperature at
that point in the sensor's field of view will rise from room temperature to body
temperature, and then back again. The sensor converts the resulting change in
the incoming infrared radiation into a change in the output voltage, and this
triggers the detection. Objects of similar temperature but different surface
characteristics may also have a different infrared emission pattern, and thus
moving them with respect to the background may trigger the detector as well.
PIR 1.4.2.1
1.4.3 RTC
RTCs often have an alternate source of power, so they can continue to keep
time while the primary source of power is off or unavailable. This alternate
source of power is normally a lithium battery in older systems, but some newer
6
systems use a supercapacitor, because they are rechargeable and can
be soldered. The alternate power source can also supply power to battery
backed RAM.
Most RTCs use a crystal oscillator, but some use the power line frequency. In
many cases, the oscillator's frequency is 32.768 kHz. This is the same frequency
used in quartz clocks and watches, and for the same reasons, namely that the
frequency is exactly 215 cycles per second, is a convenient rate to use with
simple binary counter circuits.
Many commercial RTC ICs are accurate to less than 5 parts per million. [10] In
practical terms, this is good enough to perform celestial navigation, the classic
task of a chronometer. In 2011, Chip-scale atomic clocks were invented.
Although more expensive, they keep time within 100 nanoseconds.
RTC 1.4.3.1
1.4.4 ARDUINO
7
A microcontroller often serves as the “brain” of a mechatronic
system. Like a mini, self-contained computer, it can be programmed to interact
with connected hardware and/or a user, much like a PC connected to a small
network of hardware. As the computer industry has evolved, so has the
technology associated with microcontrollers. Every year microcontrollers
become much faster, have more memory, and extend their input and output
feature sets, all the while becoming even cheaper and easier to use.
The development board used in this course is called the Arduino. The name
Arduino is used to denote the hardware board, the software development
environment, its library of easy-to-use software functions, and/or the layout
standard of the original version's connection headers, depending on the context.
The name “Arduino” is a copyright held by the original team based in Italy that
originally built the hardware, the IDE (integrated development environment)
and the software libraries. It was designed to be a platform for physical
computing usable primarily by non-programmers (artists, hobbyists, teachers,
students, etc.). Another goal of the project was that all of the hardware designs
(except those for the chips themselves) as well as the software tools are open-
source – free to copy and distribute without any licensing restrictions. By
making an easy-to-use, easy-to-make platform, they hoped that it would enable
a wide variety of interactive and creative uses by an even greater variety of
users. Its popularity and use has spread much wider than originally anticipated.
8
Arduino programs are called sketches, reflecting the vocabulary of the artist
community. You will still often hear them called programs (including here)
and not sketches, but at least now when you hear “sketches
Besides its ease-of-use, the Arduino was one of the first complete development
systems to cost around $30. The current, standard Arduino is still priced around
$30, but small, barebones Arduino-compatible boards can be purchased for $11.
In fact, the hardware platform is simple enough that even cheaper, barebones
versions can be handmade using a variety of construction methods.
The Arduino boards that we are using are from the group of “standard”
Arduinos, in particular, the Arduino Duemilanove and the current Arduino
Uno.
What characterizes this class of Arduino boards is the layout of the four rows
of female headers across the top and bottom, and the single 2x3 header along
the right edge. Any Arduino following this standard layout can connect to a
large number of expansion PCBs (printed circuit boards) that plug on top of the
Arduino called shields. Most Arduino-family boards follow this classic layout,
but some do not, mostly for size or cost reasons.
The analog output pins are located on the bottom-right six-pin female
The Arduino board comes with a single LED, often called the Pin 13 LED
because it is electrically connected to Digital Pin 13. This LED is the board's
only built-in indicator accessible to programs. As you will soon see, you may
bring more of your own input and output devices to the party and connect them
yourself. A virgin Arduino board comes pre-programmed with a sample sketch
called Blink that flashes the Pin 13 LED once per second. This feature is handy
because you can easily check the general health of your new board simply by
plugging it into USB, and the flashing LED demonstrates that the board is
mostly working.On the board is also a single reset button that causes the
program to restart when pressed, and two more LEDs that flash as data is passed
back-and-forth over the USB connection.
General precautions
As with any piece of non-consumer-grade electronics equipment, you have to be
somewhat careful to avoid frying electronic components. Some types of
components, mostly semiconductor ICs (integrated circuits) can be delicate and
easily damaged by electrical shorts and static discharges. In general, before
touching any circuit board with integrated circuits (ICs), make sure that you
have dissipated any static charge that you may have accumulated on your body.
The best way to do this is by using an ESD wrist strap that has been connected
to a good earth ground and by placing your circuit board on a grounded ESD
mat.
If you don’t have this or similar ESD equipment (we don't), it's generally
sufficient to touch a grounded metal surface like the metal frame of the lab
bench before you handle the circuit board. Static charge is especially easy to
accumulate during the dry winter months, simply by walking across the floor.
10
Handle all PCBs by their edges, not by grasping the faces of the printed
circuit board or its components. Finally, always wash your hands after handling
electronics because lead and other heavy metals in the components and solder
connecting them are hazardous in sufficient quantities.
Note that different drivers are required for the most recent Arduino Uno
versus the ArduinoDuemilanove, so if you're planning on using both on one
computer, both driver installation procedures will have to be performed.
11
At this point you should connect the Arduino to the computer with the USB
cable. After initial set-up, the computer should issue its ascending-beep to
acknowledge that the board has been connected. After launching the Arduino
IDE,
Now you have to configure the IDE so that it can communicate with the
Arduino board.
Please note that every time that you connect an Arduino over USB, you may
have to go through the same configuration procedure (at least with pre-Uno
boards). Additionally, if you cause the Arduino to hard-reset (for instance,
because you created a temporary short), that will also reset the USB connection.
Hard resets are functionally equivalent to disconnecting and reconnecting the
cable or board. Fortunately, pressing the reset button on the Arduino board (or
shields) will not reset the USB connection.
There are only two settings that need to be configured, and one of them rarely
changes. The first setting is the board type. If you are using an Uno board,
12
under Tools->Board select Arduino Uno. This option is probably already the
default, and this setting is retained from the last time the Arduino IDE was run.
The other option, under Tools->Serial Port, specifies the COM port that the
USB driver should use to communicate with the Arduino. This one is annoying
because every time that your USB configuration changes, your Arduino board
may move to another COM port. There are three ways to figure out which
COM port to use:
You should see the following two areas in the bottom part of the IDE window, a
blue-gray status message section, and a detailed message/log section:
13
(b) After successful compilation, the logged message “Binary sketch size: ...”
(c) During upload, the status message “Uploading to I/O Board...” followed
by a few-seconds-long flashing of the TX/RX LEDs on the Arduino (next to the
Pin 13 LED). If either your COM port or board selection is incorrect, the
upload will time-out, and you will likely see an error from the “avrdude”
program in the logged messages window.
SUMMARY
Microcontroller ATmega328
Operating Voltage 5V
InputVoltage
7-12V
(recommended)
14
Analog Input Pins 6
SRAM 2 KB (ATmega328)
EEPROM 1 KB (ATmega328)
POWER
The Arduino Uno can be powered via the USB connection or with an external
power supply. The power source is selected automatically.
External (non-USB) power can come either from an AC-to-DC adapter (wall-
wart) or battery. The adapter can be connected by plugging a 2.1mm center-
positive plug into the board's power jack. Leads from a battery can be inserted
in the Gnd and Vin pin headers of the POWER connector.
15
MEMORY
The ATmega328 has 32 KB (with 0.5 KB used for the bootloader). It also has 2
KB of SRAM and 1 KB of EEPROM (which can be read and written with the
EEPROM library).
COMMUNICATION
The Arduino Uno has a number of facilities for communicating with a
computer, another Arduino, or other microcontrollers. The ATmega328
provides UART TTL (5V) serial communication, which is available on digital
pins 0 (RX) and 1 (TX). An ATmega8U2 on the board channels this serial
communication over USB and appears as a virtual com port to software on the
computer.
The '8U2 firmware uses the standard USB COM drivers, and no external driver
is needed. However, on Windows, a .inf file is required. The Arduino software
includes a serial monitor which allows simple textual data to be sent to and from
the Arduino board.
The RX and TX LEDs on the board will flash when data is being transmitted
via the USB-to-serial chip and USB connection to the computer (but not for
serial communication on pins 0 and 1).
16
The ATmega328 also supports I2C (TWI) and SPI communication. The
Arduino software includes a Wire library to simplify use of the I2C bus; see the
documentation for details. For SPI communication, use the SPI library.
This GSM Modem can accept any GSM network operator SIM card and act just
like a mobile phone with its own unique phone number. Advantage of using this
modem will be that you can use its RS232 port to communicate and develop
embedded applications. Applications like SMS Control, data transfer, remote
control and logging can be developed easily.
GSM/GPRS MODEM is a class of wireless MODEM devices that are designed
for communication of a computer with the GSM and GPRS network. It requires
a SIM (Subscriber Identity Module) card just like mobile phones to activate
communication with the network. Also they have IMEI(International Mobile
Equipment Identity) number similar to mobile phones for their identification. A
GSM/GPRS MODEM can perform the following operations:
17
Booting the GSM Module!
3. Now wait for some time (say 1 minute) and see the blinking rate of ‘status
LED’ or ‘network LED’ (GSM module will take some time to establish
connection with mobile network)
There are two ways of connecting GSM module to arduino. In any case, the
communication between Arduino and GSM module is serial. So we are
supposed to use serial pins of Arduino (Rx and Tx). So if you are going with
this method, you may connect the Tx pin of GSM module to Rx pin of Arduino
and Rx pin of GSM module to Tx pin of Arduino. You read it right ? GSM Tx
–> Arduino Rx and GSM Rx –> Arduino Tx. Now connect the ground pin of
arduino to ground pin of gsm module! So that’s all! You made 3 connections
and the wiring is over! Now you can load different programs to communicate
with gsm module and make it work.
The problem with this connection is that, while programming Arduino uses
serial ports to load program from the Arduino IDE. If these pins are used in
wiring, the program will not be loaded successfully to Arduino. So you have to
18
disconnect wiring in Rx and Tx each time you burn the program to arduino.
Once the program is loaded successfully, you can reconnect these pins and have
the system working!
I hope you understood so far! Lets get to the circuit diagram! So given below is
the circuit diagram to connect gsm module to arduino – and hence use the
circuit to send sms and receive sms using arduino and gsm modem.
19
GSM MODULE 1.4.5.1
CHAPTER 2
20
LITERATURE SURVEY
CHAPTER 2
LITERATURE SURVEY
S.No Authors Name Description
1. Noriaki Yoshiura Smart street light In this case light turns on
Yusaku Fujii system looking like when its needed otherwise
Naoya Ohta usual street lights
not Whenever someone
based on sensor
networks see street lights, they turn
on whenever no one see
street light turned off. The
lights turn on before
pedestrians and vehicles
come and turn off or
reduce brightness when
21
there is no one. It will be
difficult for pedestrians
and drivers of vehicles to
distinguish our smart
street lights and the
conventional street lights
because our street lights
all turn on before they
come.
22
efficient It can extend the
lifetime of the lamps and
warn the maintenance
traffic authority upon failure
detection in any place of the
streets.
23
System project can be implemented
in a large scale in many big
cities,where most of the
street lights consuming
useful power, It is a step
forward to allot the power
generated in a much better
fashion.
24
properly.
25
fully adaptable user needs in
rural and urban areas.
10. Amul A Survey on The system used here is a
Shravan kumar Automatic Street closed loop on-off system.
Jalan Lightning System on Controlling lighting system
Indian Streets Using by means of LDR and
Arduino Arduino together on Indian
streets is relatively a new
concept. Still today research
has been done only on street
light system based on
Passive Infrared receiver and
few are LDR based but they
are controlled by means of
timers and analog circuits.
Some were controlled by
wireless GSM/GUI networks
which are too costly and not
affordable..
26
found to be very efficient
and the maintenance cost is
very less. The circuit
controls the turning ON or
OFF the street light. The
street lights have been
successfully controlled by
microcontroller. With
commands from the
controller the lights will be
ON when it's dark.
Furthermore the drawback
of the street light system by
just using timer controller
has been overcome, where
the system depends on both
timer and LDR sensor.
12. Abdul Latif Street Light Author proposed a technique
Saleem, Raja Monitoring and in which 2- way
Sagar R, Control System communication can be
Sachin Datta N possible. Technical solution
S,Sachin H S, for implementation of
Usha M S wireless intelligent smart
street lighting system is
made easier. It provides a
low cost infrastructure for
managing street lighting
system. Single point
controlling of street lights is
27
made possible. Energy
consumption can be
controlled making it eco-
friendly in usage.
13. Sindhu.A.M, Smart Streetlight By using Smart Street light,
Jerin George, Using IR Sensors one can save surplus amount
Sumit Roy, of energy which is done by
Chandra J replacing sodium vapor
lamps by LED and adding
an additional feature for
security purposes. It
prevents unnecessary
wastage of electricity,
caused due to manual
switching of streetlights
when it’s not required. It
provides an efficient and
smart automatic streetlight
control system with the help
of IR sensors. It can reduce
the energy consumption and
maintains the cost. The
system is versatile,
extendable and totally
adjustable to user needs
14. Mr. A. Syed Automatic street Light This project is aimed at
Noor-ul-Hassan ControlSystem using designing and
Bukhari,
LDR and IC555 implementation ofan
Syed Zulfiqar sensor automatic system in the
28
Haider Bukhari, streets. This project can
needs.
29
CHAPTER 3
30
SYSTEM ANALYSIS
CHAPTER 3
SYSTEM ANALYSIS
31
3.3 PROPOSED SYSTEM
In this model we have adapted many advanced methods. Here we have
used PIR sensor instead of piezoelectric sensor so that even if there are road
maintance it doesn’t bring damage to the sensors since we have mounted the
sensors on the lamp post instead of keeping it in the road. Even if there is low
light in day time due to cloudy weather or rainy atmosphere the LDR detects the
intensity of the surrounding and make the street lights to glow also we have
used RTC so that the street lights are completely automatic and so human
efforts are reduced. We have also used GSM module so that in case of any
failures of lamp it automatically generates a message and sends to service
authority.
32
33
CHAPTER 4
SYSTEM ARCHITECTURE
CHAPTER 4
SYSTEM ARCHITECTURE
34
Power Supply
GSM
PIR Sensor
LDR Sensor
Arduino Mobile network
4.2 ALGORITHM
4.3 PSEUDOCODE
35
Step 3: If the time is between 22 and 06, the lights are made to glow at full
intensity if any vehicle is detected, else the lights are made to glow at 20%
intensity.
Step 4: If the time is between 06 and 18, then the lights made to glow only if
the atmospheric brightness is dark because of dark cloudy weather.
Step 5: And if the lights does not get ON between 18 and 22 , then an alert
message is send to Service Authority using an GSM module.
36
CHAPTER 5
CONCLUSION
CHAPTER 5
CONCLUSION
37
automatically it reduces human effort. In case of any failure of the lights a
message which include the number of the particular street lamp will be send to
the service authority.
FUTURE ENHANCEMENT
Adaptive, interoperable lighting solutions are needed to bring savings
to the next level, facilitated by connecting LED bulbs with a central
management system (CMS) over the internet. These networked streetlighting
systems allow operators to monitor and regulate light levels in unprecedented
ways, resulting in increased energy savings and lower operational costs. The
50% energy savings that are realised by switching to LEDs increase to 80%
when connectivity and a central management system (CMS) are added. With a
proven business case, a number of vendors are entering the market and many of
the world’s largest cities including London, New York, Hong Kong and Sydney
are already implementing these connected street lighting systems. While the
energy and cost saving benefits are driving adoption, cities are increasingly
seeing infrastructure. With an even and widespread distribution across urban
areas, readily available power and integrated connectivity, smart street lighting
is being used to form the technology foundation of a city.
38
APPENDICES
APPENDIX A
CODING
A1 CODING
/* Induino R3 User Guide - Program 11.0 - Interfacing with the Simple Labs
DS1307 RTC Module */
char *dow[] = {
" ", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"
}; // An Array to store the DAY text to match with the DAY parameter of the
RTC
char *mode[] = {
"HR", "AM", "PM"
}; // An Array to store the time mode
int dd, mm, yy, day, hh, mins, ss, mde; // Variables to store the retrieved time
value
unsigned long interval1 = 15000;
unsigned long previousMillis1 = 0;
unsigned long currentMillis1;
unsigned long interval2 = 15000;
unsigned long previousMillis2 = 0;
unsigned long currentMillis2;
unsigned long interval3 = 15000;
unsigned long previousMillis3 = 0;
unsigned long currentMillis3;
unsigned long interval4 = 15000;
unsigned long previousMillis4 = 0;
unsigned long currentMillis4;
SoftwareSerial gsm(12,13);
void setup()
{
40
Serial.begin(9600); // Initialise Serial Communication
Wire.begin(); // Initialise Wire Communication - Join the I2C Bus
delay(500);
set_time(3, 4, 18, 19, 20, 11, 50, 0); // Call the set_time function to set the
intial time.
41
Serial.print(mm);
Serial.print("/");
Serial.print(yy);
Serial.print(" ");
Serial.print(dow[day]);
Serial.print(" ");
Serial.print(hh);
Serial.print(":");
Serial.print(mins);
Serial.print(":");
Serial.print(ss);
Serial.print(" ");
Serial.print(mode[mde]);
Serial.println();
delay(1000);
int w = digitalRead(2);
Serial.println(w);
if (w == 1)
{
Serial.println("vehicle detected");
analogWrite(6, 255);
previousMillis1 = millis();
}
currentMillis1 = millis();
42
if ((unsigned long)(currentMillis1 - previousMillis1) >= interval1)
{
analogWrite(6,20);
previousMillis1 = millis();
}}
int x = digitalRead(3);
43
Serial.println(x);
if (x == 1)
{
Serial.print("vehile detected");
analogWrite(9, 255);
previousMillis2 = millis();
}
currentMillis2 = millis();
44
}
}
45
}
if ((hh >= 22) || (hh < 6)) //lamp post 3
{
int y = digitalRead(4);
Serial.println(y);
if (y == 1)
{
Serial.println("vehicle detected");
analogWrite(10, 255);
previousMillis3 = millis();
}
currentMillis3 = millis();
46
analogWrite(10,150);
}
else
{
analogWrite(10,0);
}
}
47
gsm.write(0x1A);
delay(1000);
gsm.println("");
delay(15000);
}
}
if ((hh >= 22) || (hh < 6)) //lamp post 4
{
int z = digitalRead(5);
Serial.println(z);
if (z == 1)
{
Serial.println("vehicle detected");
analogWrite(11, 255);
previousMillis4 = millis();
}
currentMillis4 = millis();
48
float l;
l=analogRead(A3);
Serial.println(l);
if(l<=50)
{
analogWrite(11,150);
}
else
{
analogWrite(11,0);
}
}
}
// The set_time function takes parameters in the order of date, month, year, day
of week, hours, minutes, seconds & mode
// the mode can have 3 possible values (0=>24HR, 1=> AM, 2 => PM)
void set_time(int sdd, int smm, int syy, int sday, int shr, int smin, int ssec, int
smode)
{
Wire.beginTransmission(myrtc); // Initialise transmission to the myrtc I2C
address
Wire.write(0x00); // Write the value of the register to start with, 0 in this case
represented in BCD format
Wire.write(dec_to_bcd(ssec)); // convert the seconds value from decimal to
bcd and write it to the seconds register
// after the write operation the register pointer will be at the next register, so we
do not have to set the value of the register again
49
Wire.write(dec_to_bcd(smin)); // convert the minutes value from decimal to
bcd and write it to the minutes register
if (smode == 0) // Check if the mode is 24hrs mode
{
Wire.write(dec_to_bcd(shr)); // if 24 hours mode is on then convert the hours
value from decimal to bcd and write it to the hours register
}
else // if the mode is 12 hr mode
{
// If 12 hour mode is selected then the 12 Hour mode bit (the 6th bit) has to be
set to 1
// convert the hour value to bcd first and then adding 64(2^6) to the converted
hrs value will set the 6th bit HIGH
if (smode == 1) // check if it is AM
Wire.write(shr); // if it is AM we can directly write the value of the above
modified hours values to the hours register
if (smode == 2) // check if it is PM
Wire.write(shr + 32); // If it is PM, then adding 32 (2^5) sets the 5th bit (the
PM indication bit) HIGH, the calculated value is written to the hours register
}
Wire.write(dec_to_bcd(sday)); // convert the day value from decimal to bcd
and write it to the day register
Wire.write(dec_to_bcd(sdd)); // convert the date value from decimal to bcd
and write it to the date register
Wire.write(dec_to_bcd(smm)); // convert the month value from decimal to
bcd and write it to the month register
50
Wire.write(dec_to_bcd(syy));// convert the year value from decimal to bcd and
write it to the year register
Wire.endTransmission(); // end the transmission with the I2C device
// the get_time() function will retrieve the current time from the RTC and store
it in the Global Variables declared
void get_time()
{
Wire.beginTransmission(myrtc); // Initialise transmission to the myrtc I2C
address
Wire.write(0x00); // Write the value of the register to start with, 0 in this case
represented in BCD format
Wire.endTransmission(); // end the transmission with the I2C device
Wire.requestFrom(myrtc, 7); // Now ask the I2C device for 7 Bytes of Data //
This corresponds to the values of the 7 registers starting with the 0th register
ss = bcd_to_dec(Wire.read()); // The first read will retrieve the value from the
register address 0x00 or the seconds register, this is in the BCD format, convert
this back to decimal
mins = bcd_to_dec(Wire.read());// The second read will retrieve the value
from the register address 0x01 or the minutes register, this is in the BCD format,
convert this back to decimal
hh = Wire.read();// The third read will retrieve the value from the hours
register, this value needs to be processed for the 24/12 hr mode
51
// Check of if the BCD hours value retrieved is greater than 35 (this indicates
that the hours is in 12 hour mode
// 35 is the maximum BCD value possible in the 24hr mode
if (hh > 35)
{
hh = hh - 64; // in the 12 Hours Mode the 12 hour mode bit (6th bit) is set to
high, so we need to subtract 2^6 from our hours value
if (hh > 32) // Now check if the hour value is greater than 32 (2^5 = 32) (this
indicates that PM bit (5th bit) is high)
{
mde = 2; // Set the mde variable to indicate PM
hh = hh - 32; // subtract 32 from the hours value
}
else // if the hour value is less than 32 it means that its in the AM mode
{
mde = 1; // Set the mde variable to indicate AM
}
}
else // if the 12 hour mode bit was not set, then the hour is in the 24 hour mode
{
mde = 0; // Set the mde variable to indicate 24 Hours
}
hh = bcd_to_dec(hh); // Convert the final hour value from BCD to decimal and
store it back into the same variable
day = bcd_to_dec(Wire.read());// The fourth read will retrieve the value from
the register address 0x03 or the day register, this is in the BCD format, convert
this back to decimal
52
dd = bcd_to_dec(Wire.read());// The fifthread will retrieve the value from the
register address 0x04 or the date register, this is in the BCD format, convert this
back to decimal
mm = bcd_to_dec(Wire.read());// The sixth read will retrieve the value from
the register address 0x05 or the month register, this is in the BCD format,
convert this back to decimal
yy = bcd_to_dec(Wire.read());// The seventh read will retrieve the value from
the register address 0x06 or the year register, this is in the BCD format, convert
this back to decimal
53
APPENDIX B
SCREENSHOTS
A2 SCREENSHOT
54
A4 Lamp status between 18 and 22
55
A6 Lamp status between 06 and 18
56
REFERENCES
57
[9]. P Kavita A. Bajaj , Tushar S. Mote, Design and Implementation of CPLD
based Solar Power Saving System for Street Lights and Automatic Traffic
Controller, International Journal of Scientific and Research Publications.
[10]. Amul Shravan kumar Jala, Electric Energy Savings and Light Guides,
Energy& Environment, 3 rd IASME/WSEAS International Conference on,
Cambridge, UK, February 2008, pp.470-474.
[11]. Gouthami. C , Santosh. C ,A. Pavan Kumar, Karthik. A, Ramya.K.R,”
Intelligent Lighting System Using Wireless Sensor Networks”, International
Journal of Ad hoc, Sensor & Ubiquitous Computing (IJASUC) Vol.1, No.4,
December 2010, pp 17-27
[12]. Abdul Latif Saleem, Raja Sagar R, Sachin Datta N S,Sachin H S,Usha M
S,” Smart Personal Sensor Network Control for Energy Saving in DC Grid
Powered LED Lighting System”, IEEE Trans. Smart Grid
[13] Sindhu.A.M, Jerin George, Sumit Roy, Chandra J “Automatic Street Light
Control System Using Microcontroller” Department of Control Engineering
College of Electronic Technology/ Baniwalid Baniwalid- Libya LIBYA,
Mathematical Methods and Optimization Techniques in engineering
58
[17] R. Priyasree, R. Kauser, E. Vinitha and N. Gangatharan, Automatic Street
Light Intensity Control and Road Safety Module Using Embedded System,
International Conference on Computing and Control Engineering, April 2012.
59