Before starting, install the required Python packages:
pip install -r requirements.txt
This project implements circadian lighting using a sophisticated color temperature conversion process:
-
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
-
Color Temperature to RGB Conversion
- The conversion process follows multiple steps to ensure accuracy:
- Use Planck's laws to convert color temperatures to wavelengths
- Filter through L, M, and S cone responses
- Convert to CIE 1931 color space using color matching functions
- Transform CIE 1931 values to RGB using a conversion matrix
- The conversion process follows multiple steps to ensure accuracy:
-
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.
Use any available sources to obtain color temperature data throughout the day. This step can be skipped as default values are provided.
- 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.
- Power the ESP32
- Connect 5V and GND to NeoPixel
- Connect NeoPixel ground to ESP32 ground (ensures common ground level)
- Connect ESP32's GPIO 13 to NeoPixel's DI pin
-
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.
-
On the Python server:
- Update
master.py
with ESP32's IP address - Run
master.py
withpython master.py
- Now ensure both Python server and ESP are on the same WiFi.
- Update
- 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
Arduino and Simulation modes are planned for future releases.
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
- 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.