[tech] DIY Photo frame with light sensor
After the setup of the DIY Photo frame based on raspberry pi hardware, a major limitation was that the monitor would remain ON throughout the night. This was also a problem when watching TV late at night with the lights off. Physical computing by adding sensors is a selling point for Raspberry Pi so that is exactly what I ended up doing.
To solve the automated display control I used the BH1750 ambient light sensor. This sensor is connected via a few wires and just taped (serious engineering) on top of the pi case. Using the python libraries blinka and circuitpython I was able to add software support for reading the current light value as from the sensor.
With a basic mechanism to read the light lux value, the next step is to write a script that turns the monitor on and off based on xrandr commands. This was described online. A simple python script that looped to read the current status of the light value and turned on or off the display and photo service did the trick. The last step was just wrapping the script as a systemd service. With basic linux administration we have a very workable solution… which works great.