Projects Hub, lesson 43 of 81

Human Presence Detection and Lighting Control with LCD Output

intermediate3 min read

Introduction

In today's world, energy conservation is a paramount concern, and one of the simplest ways to achieve this is through intelligent lighting control systems. Human presence detection is a key component of such systems. By integrating human presence sensors with an Arduino microcontroller and an LCD display, we can create a sophisticated yet energy-efficient lighting control system that automatically adjusts lighting based on occupancy. In this article, we will explore the working principle, components needed, circuit diagram, and provide the Arduino code to build such a system.

Working Principle

The working principle behind this human presence detection and lighting control system is straightforward. It uses a passive infrared (PIR) motion sensor to detect human presence within its range. When the sensor detects motion, it sends a signal to the Arduino, which then processes the information and controls the lighting accordingly. The LCD display provides real-time feedback on the status of the system, indicating whether the lights are on or off.

Things We Need

To build this system, you will need the following components:

  1. Arduino Uno or compatible microcontroller board.
  2. Passive Infrared (PIR) motion sensor.
  3. LCD display (16x2 or similar).
  4. Relay module (to control the lights).
  5. Breadboard and jumper wires.
  6. Power supply for Arduino (USB or external).
  7. Light source (e.g., an LED bulb or a lamp).

Circuit Diagram

Here is a basic circuit diagram to help you connect the components:

[Insert Circuit Diagram]

Working of the System with Arduino

  1. Connect the PIR motion sensor to the Arduino as per the datasheet or pinout instructions.
  2. Wire the LCD display to the Arduino using appropriate connections.
  3. Connect the relay module to control the lighting.
  4. Write and upload the Arduino code for this project.
Loading the circuit…Arduino Uno
Press Run to upload the code to the Arduino.

Arduino Code

#include <LiquidCrystal.h>
 
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // Initialize the LCD library with the pins
 
const int pirPin = 6; // PIR sensor input pin
const int relayPin = 7; // Relay control pin
int pirState = LOW; // Initialize PIR state to LOW (no motion)
int lastPirState = LOW; // Store the previous PIR state
 
void setup() {
  pinMode(pirPin, INPUT);
  pinMode(relayPin, OUTPUT);
  lcd.begin(16, 2); // Set up the LCD's number of columns and rows
  lcd.print("Light Control"); // Display initial message
}
 
void loop() {
  pirState = digitalRead(pirPin); // Read PIR sensor state
 
  if (pirState == HIGH && lastPirState == LOW) {
    // Motion detected, turn on the lights
    digitalWrite(relayPin, HIGH);
    lcd.setCursor(0, 1);
    lcd.print("Lights: ON ");
  } else if (pirState == LOW && lastPirState == HIGH) {
    // No motion, turn off the lights
    digitalWrite(relayPin, LOW);
    lcd.setCursor(0, 1);
    lcd.print("Lights: OFF");
  }
 
  lastPirState = pirState; // Store current PIR state
 
  delay(500); // Adjust the delay as needed for your application
}

Conclusion

With this human presence detection and lighting control system, you can create an energy-efficient and convenient lighting solution for your home, office, or any space. The system detects human presence using a PIR sensor and uses an Arduino to control the lights via a relay module. The LCD display provides real-time feedback on the lighting status. This project not only saves energy but also adds a touch of automation to your environment, making it both eco-friendly and user-friendly.