I use a BH1750 light sensor, HC-SR501 PIR Motion Sensor, a KY-040 Rotary encoder with a Wemos D1 mini (esp8266 wifi chip) board to control some LEDs. By default, they turn on an off automatically (or rather with the PIR sensor) and their brightness is calculated based on the Light Sensor’s readings. Clicking the Rotary Encoder switches it to manual mode where I control the brightness manually. The LEDs fade in and out as they turn on and off and their brightness depends on the ambient light.
I use Blynk to monitor the following:
- Light levels from the BH1750 sensor
- motion detected
- Rotary Encoder is on “Manual Mode”
- brightness level whilst in “manual mode”
Apart from the light levels and brightness values, all these states are Bool values, I assumed it would be pretty straightforward to set up considering it’s either true or false, but apparently this isn’t the case.
Currently, the only things I can monitor is the light level and whether or not Manual Mode is enabled. Anything else seems to cause the fade-in function to slow down dramatically. I solved this by using BlynkTimer and creating functions to specifically check for the Bool states, but while this fixes the fade issues, the LEDs flicker every second.
To do this, I’ve staggered the timers like so:
timer.setTimeout(100, []() {
timer.setInterval(1000L, luxMonitoring);
});
timer.setTimeout(200, []() {
timer.setInterval(1000L, motionMonitoring);
});
…and so on.
I’ve tried eliminating issues and found that it was both “Motion Detected” and the Brightness levels that causes it. I’m not sure it’s the actual functions that are causing the issue or the fact that I’m trying to monitor so many things. I tried putting it all into a single function to eliminate the fact that I was staggering the timers, but to no avail.
Has anyone else had similar issues?