Skip to content

This project implements circadian lighting using an ESP32 and NeoPixel LEDs, with a Gaussian-based color temperature model for natural day-night transitions. Features include automatic lighting adjustments based on location, manual and auto modes via a Flask web interface, and real-time color temperature correction for comfortable lighting.

Notifications You must be signed in to change notification settings

prakrititz/CircidianLightning-Eyantra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌈 RGB Simulator for Circadian Lighting 🌙

🛠️ Installation

Before starting, install the required Python packages:

pip install -r requirements.txt

🌟 Technical Overview

This project implements circadian lighting using a sophisticated color temperature conversion process:

  1. Color Temperature Distribution

    • We model the daily color temperature variation using a Gaussian (normal) distribution
    • The distribution is optimized to fit the given color temperature and time data
    • This ensures smooth transitions throughout the day
  2. Color Temperature to RGB Conversion

    • The conversion process follows multiple steps to ensure accuracy:
      1. Use Planck's laws to convert color temperatures to wavelengths
      2. Filter through L, M, and S cone responses
      3. Convert to CIE 1931 color space using color matching functions
      4. Transform CIE 1931 values to RGB using a conversion matrix
  3. Color Correction

    • Due to known limitations in the CIE 1931 color space (which tends to produce bluish values)
    • We implement a "warmness" correction using a custom matrix in step2.py
    • This correction helps achieve more natural and comfortable lighting

Note: While this implementation provides a close approximation of natural color temperatures, small margins of error may exist due to inherent limitations in color space conversions.

🚀 How this works

📊 Step 1: Get the color temperature data (Optional)

Use any available sources to obtain color temperature data throughout the day. This step can be skipped as default values are provided.

💡 Step 2: Hardware Implementation with ESP32 + NeoPixel

Hardware Requirements

  • ESP32 development board
  • NeoPixel LED ring
  • Common WiFi network
  • Computer to run the Python server

Important: Both the ESP32 and the computer running the Python server must be connected to the same WiFi network.

Hardware Connections

  1. Power the ESP32
  2. Connect 5V and GND to NeoPixel
  3. Connect NeoPixel ground to ESP32 ground (ensures common ground level)
  4. Connect ESP32's GPIO 13 to NeoPixel's DI pin

Software Setup

  1. In esp_integration folder, modify the ESP32 code:

    • Enter your WiFi SSID and password
    • Upload to ESP32
    • Note down the ESP32's IP address
    • After modifying the code, upload it to the ESP32.
  2. On the Python server:

    • Update master.py with ESP32's IP address
    • Run master.py with python master.py
    • Now ensure both Python server and ESP are on the same WiFi.

Features

  • Flask web interface for:
    • Manual RGB value control
    • Circadian rhythm simulation control
    • Return to automatic mode
  • Automatic circadian rhythm when left unattended
  • Location based Circadian Lighting
  • image

Other Implementation Options

Arduino and Simulation modes are planned for future releases.

Demo

This demo was run by clicking the Test_CSV button in the website, which rapidly goes through lighting over the course of the day.

lighting_demo.mp4

🔜 Next Steps

  • Integration with sunset/sunrise by location API to automatically configure circadian lighting for any location/timezone [DONE].
  • Introduction of various color specific matrices to offer color-targeted Circadian Lighting for different rooms. For example, green-ish circadian lighting in hospital operating rooms, warm or natural in cosy areas, blue-ish in areas which need more productivity.
  • Deployment on Docker or Creation of a Mobile App.

About

This project implements circadian lighting using an ESP32 and NeoPixel LEDs, with a Gaussian-based color temperature model for natural day-night transitions. Features include automatic lighting adjustments based on location, manual and auto modes via a Flask web interface, and real-time color temperature correction for comfortable lighting.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published