Skip to content

KacperStib/LedDriver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intelligent LED Lighting Controller

Microcontroller-based smart LED controller for 12V–24V DC lighting systems.

The device enables manual, automatic and semi-automatic brightness control based on:

  • Ambient light intensity (lux)
  • Human presence (PIR sensor)
  • Energy consumption monitoring
  • Temperature and humidity measurement

Control is performed via a built-in HTTP web interface.


Features

  • Manual brightness control (0–100%)
  • Automatic brightness control (0–1000 lux setpoint)
  • Semi-automatic modes
  • PID light intensity regulation
  • Motion detection with configurable hold time
  • Power, current and energy monitoring
  • Temperature and humidity measurement
  • EEPROM settings persistence
  • Fully web-based configuration (responsive UI)
  • Designed for 12V / 24V LED installations
  • Compact PCB (40x40 mm)
  • Fits into Ø60 mm flush-mounted wall box

Hardware

Main Controller

  • ESP32-C3 SuperMini
  • Framework: ESP-IDF

Sensors (I²C)

Device Function I2C Address
INA219 Current / Power 0x40
BH1750 Light (lux) 0x23
SHT40 Temperature / Humidity 0x44
M24C08 EEPROM 0x50–0x53

Motion Sensor

  • SR602 (3.3V compatible PIR)

LED Control

  • MOSFET (Logic Level) – IRLZ34N
  • 8-bit PWM (0–255)
  • Controlled using ESP32 LEDC API

Power Section

  • Input: 12–24V DC
  • DC/DC: R-78K3.3-1.0 (RECOM)
  • π-filter for EMC compliance

Operating Modes

1. Manual Mode

User sets LED brightness (0–100%).

2. Automatic Mode

  • User sets target lux value.
  • PID controller adjusts PWM to maintain constant light intensity.

3. Semi-Automatic Mode

Combination of:

  • Manual brightness
  • Motion sensor
  • Or automatic lux regulation

Motion Sensor Logic

  • PIR can be enabled/disabled.
  • Adjustable hold time (seconds).
  • When no motion is detected → light turns off after delay.

Energy Monitoring

Using INA219:

  • Voltage measurement
  • Current measurement
  • Power calculation
  • Energy integration:
    E = P × t

Energy usage stored periodically in EEPROM.


Web Interface

  • Built-in HTTP server
  • Responsive layout (mobile compatible)
  • GET/POST handlers
  • Real-time sensor data
  • Mode selection
  • Brightness configuration
  • Motion settings
  • Lux setpoint configuration

Software Architecture

Tasks handled by FreeRTOS:

  • Sensor measurement task
  • PWM control task
  • PID regulation task
  • Web server task
  • EEPROM storage task

Custom I2C driver implemented using:

driver/i2c.h

No Arduino libraries used.
Fully implemented in ESP-IDF.


Installation

The controller is connected in series between:

Power Supply → Controller → LED Strip

Designed for:

  • LED strips
  • 12V LED bulbs
  • Decorative lighting
  • Garden lighting systems

Future Improvements

  • Scheduled lighting scenes
  • Sunrise / sunset automatic mode
  • RGB / multi-channel expansion
  • Logarithmic dimming curves
  • Smooth fading via LEDC API
  • External wireless sensor modules
  • Multi-channel LED support (up to 6 PWM channels)

About

Smart Led Driver based on PWM control

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors