One of my main concerns about placing a new display in the bedroom was light contamination. The same rule applies both to clean interfaces and when going to sleep: no distractions. Luckily, handling the screen brightness of my ANAVI Thermometer was easier and more straightforward than I imagined
The first step was getting a light detector, so we can discern when the room goes dark. I just noticed the BH1750 light sensor is recommended in ANAVI’s web. And, as I mentioned about my surprise on the availability of cheap components, I could find it easily and very cheap.
Plugging it into my ANAVI Thermometer couldn’t be more straightforward. Leon’s firmware is prepared to detect it and include the readings both in the OLED display and in its own MQTT topic.
Adding it to the thermometer case was surprisingly easy as well. The case I 3D printed already had a slot in one side that I could file down a bit. The light detector bulb just made a perfect fit!
And finally, there was the job of adapting ANAVI Thermometer’s firmware to program the display fade according to the light detected in the room. Arduino’s libraries like U8g2 already come with a
setContrast API call to reduce the screen light. But it is not enough. Luckily, there is a thread on Arduino’s forum on how you can also play with the OLED display precharge registry to reduce the brightness even more. I had to do some calibration work, trying several values with both the smaller and the right-size OLED displays. Behavior with different values might vary a lot, but I found a setup where I can do a decent fade out depending on the values measured by the light detector.
Finally, using the U8g2
setPowerSave call, I turn off the display when there is no light.
You can find all these changes to in my
screen-fade branch of ANAVI’s Thermometer firmware.
And this way we get a quiet environment for sleeping!