IOT — Getting Started #06 (Smart Street Lights)

Aditya Narain Gupta
3 min readJan 15, 2018

--

In the previous blog we have covered project on Agriculture sector: Automatic Irrigation System. Let’s now move towards one more important sector i.e. Smart Cities. In this blog we will be covering a project on Smart Street Light.

Smart Street Lights:

So let us first know why is this system is needed. I expect everyone knows that in municipal corporation a person is needed to be assigned who has to switch on and off the lights everyday. At the same time lights are being opened even when not needed which leads to the lots of wastage of energy. So here we build up a system which is smart enough to switch on when the natural light intensity is low and the object is near a particular street light.

Hardware Needed:

  1. Arduino Uno
  2. LDR sensor
  3. IR Sensor
  4. 10k Resistor
  5. Connecting wires
  6. LED

Before building it lets first learn about the two sensors used in the system.

  • LDR (Light Depended Resistor): It is a special type of resistor which allows higher voltages to pass through it (i.e. offer low resistance) whenever there is a high intensity of light, and passes a low voltage (i.e.offer high resistance) whenever it is dark. We can take advantage of this LDR property in our system.
  • IR Sensor(Infrared Sensor): An infrared sensor is an electronic device, that emits infrared rays in order to sense some aspects of the surroundings. An IR sensor can measure the heat of an object as well as detects the motion. In this project we will be using it to detect the motion of object.

Schematics and hardware connections are shown in image:

Schematic for Street Light

The LDR gives out an analog voltage when connected to Vcc (5V), which varies in magnitude in direct proportion to the input light intensity on it. That is, the greater the intensity of light, the greater the corresponding voltage from the LDR will be. Since the LDR gives out an analog voltage, it is connected to the analog input pin A0 on the Arduino.
Similarly input from IR Sensor is connected to A1.

Remember we have used LED for our project just for prototype, in order to connect AC source we can simply use a 5V-10A relay module at pin 13 and connect it to street light.

Code Snippet:

//initializing variables to pin

int ldr = A0;
int ir = A1;
int LDRValue = 0;
int IRValue = 0;
int led = 3;

// Setup function executed only once. Setting up baud rate to 9600, LED to output as its going to give output and ir and ldr pin to input as they are taking input from environment.

void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(ir, INPUT);
pinMode(ldr,INPUT);

}

//This code is main application code which executes infinetly. It reads LDR value and IR value from respective sensors and switches on light during darkness in presence of object only.

void loop(){
LDRValue = analogRead(ldr);
IRValue = analogRead(ir);
while (LDRValue < 100 && IRValue>25) {
digitalWrite(led,HIGH);
delay(1000);
LDRValue = analogRead(ldr);
IRValue = analogRead(ir);
}
digitalWrite(led,LOW);
}

Here in this sketch, I have set a threshold ldr light value as 100, but it can vary for your projects. You will need to find out the particular value which the light should turn on. This needs to be done after testing it empirically. You can print the values on serial monitor using Serial.println(LDRValue). So basically, the Arduino turns on the light whenever the light intensity falls below 100 and IR sensor detects object near it. When ldr value is above 100 , it turns off the light since it is not dark.

Apart from street lights the project can be implemented in homes.
Also it can be used in emergency lighting system which becomes active in case of bulb fuse or in any other situation.

Later in the series we will be transforming this project into IOT where remote/cloud monitoring and power consumption features will be added.

If you have any doubts/queries do mention them in comments. If you have want to follow the series, make sure to follow this account for regular updates.

Link to previous blog: Automatic Irrigation System
Link to next blog: Use push buttons without resistors

--

--