Automatically adjust monitor brightness based on ambient light on a Windows PC or laptop using inexpensive hardware that you'll be building yourself!
- No coding or programming skills required
- No soldering
- Plug-n-play hardware
- Adafruit MCP2221A
USB to I2C Converter
- Adafruit TSL2591
Ambient Light Sensor
- STEMMA QT 50mm cable
Cable to connect above boards together
- USB Type-C cable
Cable to connect everything to computer
- Black Nylon Machine Screw and Stand-off Set – M2.5 Thread
optional
- Monitor with DDC/CI capabilities (most modern monitors)
It would be a good idea to search for above items and buy from a local supplier if applicable in your region.
- screen_brightness_control
- setuptools
- hidapi
- adafruit-blinka
- adafruit_tsl2591
pip3 install --upgrade screen_brightness_control
pip3 install --upgrade setuptools
pip3 install --upgrade hidapi
pip3 install --upgrade adafruit-blinka
pip3 install --upgrade adafruit_tsl2591
A simple way to get the script is to right click
on following link and select Save Link As
Download and save monitor_brightness_manager.py file if you haven't done yet and edit it in a notepad or editor of your choice editing following as you see fit and save the file:
config = {
"BLINKA_MCP2221": "1",
"BLINKA_MCP2221_RESET_DELAY": "-1",
"lux_range": {
range(0, 25, 1): 10,
range(25, 50, 1): 20,
range(50, 100, 1): 30,
range(100, 150, 1): 40,
range(150, 200, 1): 50,
range(200, 250, 1): 60,
range(250, 300, 1): 70,
range(300, 350, 1): 80,
range(350, 400, 1): 90,
range(400, 5500, 1): 100
},
"average_lux_count": 10,
"display_id": 0
}
BLINKA_MCP2221
needs to be1
, this is required by BLINKA libraryBLINKA_MCP2221_RESET_DELAY
value should be-1
for Windows 11, you can try0.5
or higher if getting errorslux_range
this is where you can configure what brightness should your monitor use based on what ambient light condition, values are: (lux_start
,lux_end
,increament_by
):brightness
. For example, first one defines for ambient light value (lux) between 0 and 25, set brightness to 10%.average_lux_count
is amount of seconds to hold lux values before taking average of, if your monitor's brightness is changing too slow or too rapidly, adjust this value. Lower value will cause brightness to change more rapidly, higher value will make it slower.display_id
is your monitor's ID, primary monitor is 0 and it is set by default
After downloading and saving the monitor_brightness_manager.py file, to run the script, in command prompt enter:
python monitor_brightness_manager.py
python C:\monitor_brightness_manager.py
- Setting up MCP2221A
- Screen brightness control library used in this script
- C++ based monitor configuration utility, for example you can also change contrast
- On an older monitor that I tested (Dell U2312HM which is more than 10 years old), changing contrast has a better effect than changing brightness
- Script will restart itself after 5 seconds if it encounters any issues