vitormhenrique / OctoPrint-Enclosure

OctoPrint Enclosure Plugin
GNU General Public License v3.0
395 stars 201 forks source link

Light sensor to pwm output #256

Open huskyte opened 4 years ago

huskyte commented 4 years ago

A constant lightning of an enclosure would probably be wanted by some users to record proper timelapses and ensure a real time camera to deliver constant picture quality. A light sensor, like an BH1750 or similar, could be deployed, but is currently not within the hardware database. Additionally, pwm pins cannot be controlled in such an extent that this would be doable.

A light sensor would need to be implemented as input device, such as a BH1750. The readings would be in LUX. A PWM pin as output would need to be programmed with a counterproportional bevaviour. Hence, the brighter the light sensor reading the less pwm duty cycles. Most preferable with a hysteresis. Some choosable mathematical function would be prefered with some parameters to set freely (see for example http://esp8266-projects.blogspot.com/2016/07/ac-pwm-dimmer-with-light-sensor.html): min Lux/pwm 0, max Lux/pwm 100, hysteresis, steps, linear/log behaviour, time for adjustment step. A stepwise algorithm would then bring the light level to the required amount (too dark, increase pwm cycle by x, wait, check again. if within hysteresis do nothing for a defined duration) .

Additionally, (but I can't think of any practical use right now) a check mark to invert the functionality.

Sembazuru commented 4 years ago

Inverting the functionality might be useful if the PWM output is controlling an inverting driver.