Here’s a structured and detailed step-by-step guide, including components and source code, specifically based on Favoriot for the Smart Street Lighting System utilizing IoT.
✅ Project Objective
Create an energy-efficient street lighting system that automatically adjusts brightness based on pedestrian and vehicle movement, reducing energy consumption and maintenance costs.
🛠️ Step-by-Step Guide
Step 1: Project Overview
Build an IoT-based smart lighting system using Favoriot that automatically adjusts brightness levels based on detected motion from pedestrians and vehicles, ensuring efficient energy usage.
Step 2: Components Required
Hardware:
- Microcontroller: NodeMCU ESP8266 or ESP32 (Wi-Fi Enabled)
- Sensors:
- PIR Motion Sensor (HC-SR501): For detecting pedestrian/vehicle movement.
- Light Dependent Resistor (LDR): Measuring ambient brightness.
- Lighting:
- High-Power LED or Street Lamp: Controlled via relay or MOSFET.
- Relay Module or MOSFET Module: To control high-power LED.
- Power Supply: 5V for NodeMCU and 12V DC power for LED street lights.
- Connecting wires and breadboard: For circuit assembly.
Software:
- Favoriot IoT Platform (https://platform.favoriot.com/)
- Arduino IDE
Step 3: Circuit Connection
- Connect PIR Motion Sensor:
- VCC → 5V NodeMCU
- GND → GND NodeMCU
- OUT → NodeMCU Pin D2 (GPIO4)
- Connect LDR (with resistor as a voltage divider):
- One leg to 3.3V, another leg connected to NodeMCU A0 analog input pin through a 10kΩ resistor, then to GND.
- Connect Relay Module:
- VCC → 5V
- GND → GND
- IN Signal → NodeMCU Pin D1 (GPIO5)
- Connect LED street light positive line through relay normally-open terminals.
Step 4: Favoriot Setup
- Create Account at Favoriot
- Create a New Project: “Smart Street Lighting”
- Add Device: e.g.,
streetlamp1 - Copy your device’s API Key and Device Developer ID from Favoriot.
📌 Step 5: Software Implementation (Code)
Upload this code using Arduino IDE to NodeMCU:
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
const char* ssid = "YOUR_WIFI_SSID";
const char* password = "YOUR_WIFI_PASSWORD";
const char* favoriotUrl= "http://api.favoriot.com/v2/streams";
const String apiKey = "YOUR_FAVORIOT_API_KEY";
const String deviceId = "streetlamp1";
#define PIR_PIN D2
#define RELAY_PIN D1
#define LDR_PIN A0
void setup() {
Serial.begin(115200);
pinMode(PIR_PIN, INPUT);
pinMode(RELAY_PIN, OUTPUT);
WiFi.begin(ssid, password);
Serial.print("Connecting WiFi");
while(WiFi.status() != WL_CONNECTED){
delay(500);
Serial.print(".");
}
Serial.println("Connected!");
}
void loop() {
int motionDetected = digitalRead(PIR_PIN);
int ambientLight = analogRead(LDR_PIN);
Serial.print("Motion: ");
Serial.print(motionDetected);
Serial.print(" | Ambient Light: ");
Serial.println(ambientLight);
if(motionDetected == HIGH && ambientLight > 300){
digitalWrite(RELAY_PIN, HIGH); // Bright when motion detected
}else if(ambientLight < 300){
digitalWrite(RELAY_PIN, LOW); // Turn off during daytime
}else{
digitalWrite(RELAY_PIN, LOW); // Dim/off if no motion
}
sendDataToFavoriot(motionDetected, ambientLight);
delay(30000); // Send data every 30 seconds
}
void sendDataToFavoriot(int motion, int light) {
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
http.begin(favoriotUrl);
http.addHeader("Content-Type", "application/json");
http.addHeader("apikey", apiKey);
String payload = "{\"device_developer_id\":\"" + deviceId + "\",\"data\":{\"motion\":" + String(motion) + ",\"ambient_light\":" + String(light) + "}}";
int httpResponseCode = http.POST(payload);
if(httpResponseCode>0){
String response = http.getString();
Serial.print("Response: ");
Serial.println(response);
}else{
Serial.print("Error sending data: ");
Serial.println(httpResponseCode);
}
http.end();
} else {
Serial.println("WiFi disconnected!");
}
}
Important:
Replace YOUR_WIFI_SSID, YOUR_WIFI_PASSWORD, YOUR_FAVORIOT_API_KEY, and streetlamp1 with your details.
📊 Step 6: Monitoring via FAVORIOT Dashboard
- Log in to your Favoriot Dashboard.
- View live-stream data from sensors.
- Create visual graphs for real-time monitoring.
- Configure alerts for maintenance notifications or abnormal readings.
⚙️ Step 7: Testing & Validation
- Install the setup in real-world environments.
- Ensure streetlights activate fully upon detection of motion.
- Confirm lights remain dim/off when no movement or during daylight.
- Check sensor data transmission to Favoriot regularly.
🔄 Step 8: Maintenance & Future Improvements
- Monitor system performance on the Favoriot platform regularly.
- Conduct sensor and hardware inspections monthly.
- Potential enhancements:
- Integrate additional environmental sensors (air quality, noise levels).
- Advanced analytics with other smart city components.
References
- Favoriot Platform Registration (FREE and Paid)
- Favoriot Full Documentation (Official)
- Favoriot Github
- How-To Use Favoriot Platform Video Playlist
Disclaimer
This article provides a step-by-step guide and only serves as a guideline. The source code may need adjustments to fit the final project design.
![[Tutorial] : Smart Street Lighting System Utilizing IoT and FAVORIOT](https://iotworld.co/wp-content/uploads/2025/03/DALL·E-2025-03-24-15.55.46-A-minimalist-serene-landscape-at-twilight-showcasing-a-gentle-gradient-of-magenta-transitioning-into-deep-violet-hues.-Simple-modern-streetlights-s.webp)





Leave a Reply