Project tutorial
IoT-Based Smart Street Light System

IoT-Based Smart Street Light System © GPL3+

A smart city is an urban area that uses different types of electronic data collection sensors to supply information used to manage assets.

  • 30 respects

Components and supplies

Necessary tools and machines

Apps and online services

About this project

Problem Definition

As it was stated earlier, it is seen in a number of cities that the street light is one of the huge expenses in a city. The cost spent is huge that all the sodium vapor lamps consume more power. The expense spent on the street light can be used for other development of the nation.Currently a manual system is used where the light will be made to switched ON/OFF i.e the light will be made to switch ON in the evening and switched OFF in the morning. Hence there is a lot of wastage of energy between the ON/OFF. This is one of the major causes of shifting to the automatic system, since there is less wastage of power and thus saving a lot of monetary expenses. Apart from this, the other disadvantages of the existing system are described below.

Disadvantagesof Existing System

  • Manual switching off/on of street lights
  • More energy consumption
  • High expense
  • More manpower

Now moving to the proposed system automated with the use of light sensors, not just the saving of energy and ensuring safety, we can also see a few more advantages following.

Advantagesof the Proposed System

  • Automatic switching of street lights
  • Maintenance cost reduction
  • Reduction in CO₂ emission
  • Reduction of light pollution
  • Wireless communication
  • Energy saving
  • Reduction of manpower

A.LDR Input

A Light dependent resistor (LDR) alsotermed as a photoresistor is adevice whose resistivity factor is a function of the electromagnetic radiation.Hence, they are light sensitive devices which are similar to that of humaneyes. They are also named as photoconductors, conductive cells or simply photocells. They are made up of semiconductor materials with high resistance A LDR works onthe principle of photo conductivity. Photo conductivity is an opticalphenomenon in which the materials conductivity gets reduced when light isactually absorbed by the material. However, when light shines onto the LDR itsresistance falls and current flows into the base of the first transistor andthen the second transistor. The preset resistor can be turned up or down toincrease or decrease resistance, in this way it can make the circuit more orless sensitive. LDR send response to Arduino.

B.IR Sensor

Aninfrared sensor is an electronic instrument that is used to sense certaincharacteristics of its surroundings by either emitting and/or detectinginfrared radiation. It is also capable of measuring heat of an object anddetecting motion. Infrared waves are not visible to the human eye. In theelectromagnetic spectrum, infrared radiation is the region having wavelengthslonger than visible light wavelengths, but shorter than microwaves. Theinfrared region is approximately demarcated from 0.75 to 1000µm. IR (infrared)sensors detect infrared light. The IR light is transformed into an electriccurrent, and this is detected by a voltage or amperage detector. IR Sensorsends response to arduino.


Alight-emitting diode (LED) is a junction diode, which emits light when activated. When we apply voltage across its leads, electrons are able torecombine with holes within the LED, releasing energy in the form of photonswhich gives the light. Hence, it is a two-lead semiconductor light source.

Light emitting diodes represents ourlighting system and the amount of light emitted by it is directly related tothe amount of light in the environment that is when outside light is less thanthe light given by LEDS is at its full intensity and visa-versa.

D. ESP8266

ESP8266 is Wi-Fi enabled system on chip (SoC) module developedby Espressif system. It is mostly used for development of IoT (Internet of Things) embedded applications.

ESP8266 comes with capabilities of

  • 2.4 GHz Wi-Fi (802.11 b/g/n, supporting WPA/WPA2)
  • General purpose input/output (16 GPIO)
  • Inter-itegrated circuit (I²C) serial communication protocol
  • Analog-to-digital conversion (10-bit ADC)
  • Serial peripheral interface (SPI) serial communication protocol
  • I²S (inter-IC sound) interfaces with DMA (direct memory access) (sharing pins with GPIO)
  • UART (on dedicated pins, plus a transmit-only UART can be enabled on GPIO2)
  • Pulse-width modulation (PWM)

It employs a 32-bit RISC CPU based on the Tensilica Xtensa L106 running at 80 MHz (oroverclocked to 160 MHz). It has a 64 KB boot ROM, 64 KB instructionRAM and 96 KB data RAM. External flash memory can be accessed through SPI.

ESP8266 module is low cost standalone wireless transceiver that can be used forend-point IoT developments.

Tocommunicate with the ESP8266 module, microcontroller needs to use set of ATcommands. Microcontroller communicates with ESP8266-01 module using UART having specified Baud rate.

There aremany third-party manufacturers that produce different modules based on thischip. So, the module comes with different pin availability options like:

  • ESP-01 comes with 8 pins (2 GPIO pins) – PCB trace antenna. (shown in above figure)
  • ESP-02 comes with 8 pins, (3 GPIO pins) – U-FL antenna connector.
  • ESP-03 comes with 14 pins, (7 GPIO pins) – Ceramic antenna.
  • ESP-04 comes with 14 pins, (7 GPIO pins) – No ant.


For example, the figure below shows ESP-01 module pins.

ESP8266-01 Module Pin Description

3V3: - 3.3 V Power Pin.

GND: - Ground Pin.

RST: - Active Low Reset Pin.

EN: - Active High Enable Pin.

TX: - Serial Transmit Pin of UART.

RX: - Serial Receive Pin of UART.


IOT smart lightArduino
int  smooth;
int LDR;
int threshold = 40;//sun's intensity
int brightness = 0;
int ledState = 0;

int sensor1 = 11;
int sensor2 = 8;
int sensor3 = 9;

int led1=5;
int led = 6;
int led2=2;

int carPresent = 0;
int carPresent1 = 0;

float beta = 0.65;
void setup() {
  // put your setup code here, to run once:
  pinMode(sensor1, INPUT);
  pinMode(sensor2, INPUT);
  pinMode(sensor3, INPUT);

void loop() {
  smooth = smooth - (beta * (smooth -  analogRead(A0)));
  LDR = round(((float)smooth / 1023) * 100);
  if (LDR <= 40)
    brightness = map(LDR, 40, 100, 0, 255);
  if (carPresent == 1)
      ledState = 1;
   else if (carPresent == 0)
      ledState = 0;
     if(carPresent1 == 1)
      ledState = 1;
      if(ledState == 1)
     else if (carPresent1 == 0)
      ledState = 0;
String data = (String)ledState+","+(String)brightness+";";
//  Serial.print(digitalRead(sensor1));
//  Serial.print("\t");
//  Serial.print(digitalRead(sensor2));
//  Serial.print("\t");
//  Serial.print(ledState);
//  Serial.print("\t");
//  Serial.println(brightness);

void checkSensors()
  if (digitalRead(sensor1) == 0)//Car captured in 1st sensor
   if (digitalRead(sensor2) == 1)//Car still didnt reach the 2nd sensor
      carPresent = 1;

  else if (digitalRead(sensor2) == 0)//Car reached the 2nd sensor
  { //No cars detected behind the first car
    if (digitalRead(sensor1) == 1)
      carPresent = 0;
     carPresent1 = 1;

    else if (digitalRead(sensor1) == 0 )

  else if(digitalRead(sensor3) == 0)//car reached the 3rd sensor
    //No cars detected behind the first car 
     if (digitalRead(sensor2) == 1)
      carPresent = 0;
    carPresent1 = 0;
     else if (digitalRead(sensor2) == 0 )
       carPresent = 0;
       carPresent1 = 1;
Code part 2Arduino
#include <ESP8266WiFi.h>

// Network Information
const char* ssid     = "ardent";
const char* password = "12345678";

String ledState = "";
String brightness = "";

char thingSpeakAddress[] = "";
String writeAPIKey = "NUEBLW9OA58DLL4N";          // Be sure to change this to your channel Write API key
WiFiClient client;

void setup()
  Serial.begin( 115200 );   // You may need to adjust the speed depending on your hardware.
void loop()
  HTTPPost( );
  delay( 15000 );
  // If you remove the sleep, be sure to add more delay so you don't post to ThingSpeak too often.


int connectWifi()
  WiFi.begin( ssid , password );
  while (WiFi.status() != WL_CONNECTED) {
    //Serial.println( "Connecting to WiFi" );
    delay( 2500 );
  //Serial.println( "Connected" );  // Inform the serial monitor

void HTTPPost() {

  // This function builds the data string for posting to ThingSpeak and provides the correct format for the wifi client to communicate with ThingSpeak.
  // It will post "numFields" worth of data entries, and take the data from the fieldData parameter passed to it.
  // Be sure to increase numFields to the number of fields you need, and activate the fields in your channel view.

  if (client.connect( thingSpeakAddress , 80 )) {

    // Build the Posting data string.  If you have multiple fields, make sure the sting does not exceed 1440 characters.
    String PostData = "api_key=" + writeAPIKey ;

    PostData += "&field1=" + ledState;
    PostData += "&field2=" + brightness;

    // POST data via HTTP
    client.println( "POST /update HTTP/1.1" );
    client.println( "Host:" );
    client.println( "Connection: close" );
    client.println( "Content-Type: application/x-www-form-urlencoded" );
   client.println( "Content-Length: " + String( PostData.length() ) );
    client.println( PostData );

void filterData() {
  if (Serial.available())
    String buffer = "";
    buffer = Serial.readStringUntil(';');
    int i1 = buffer.indexOf(',');
    ledState = buffer[0];
    buffer.remove(0, i1 + 1);
    brightness = buffer;


Smart iot street light
Smart iot street light uhild56ou7


Similar projects you might like

Control your Light System Using Smart Phone

Project tutorial by Ahmed Yassin

  • 71 respects

Arduino-Powered Smart Light (Works with Amazon Echo)

Project tutorial by Tinker Project

  • 51 respects

Smart Garbage Monitoring System Using Arduino 101

Project tutorial by Technovation

  • 78 respects

Arduino Controlled Smart Hydroponic Modular System

Project in progress by Luis Antonio Martin Nuez

  • 155 respects

Traffic Light Information System

Project tutorial by Pieter Luyten and Joppe Smeets

  • 54 respects

Alexa Based Smart Home Monitoring

Project tutorial by Adithya TG

  • 96 respects
Add projectSign up / Login