khoih
February 27, 2020, 10:54pm
14
If the switch operation is so critical for you that you can’t wait in max (yet configurable) 30s, the best way to do is to use ISR (directly or via Hardware Timer Interrupt).
There are so many discussions in the forum about this issue, you can just do some searching and will find them.
For example:
You don’t need a full-fledge Debouncing library as it might be not written to use in ISR.
You can just use some simple debouncing way using millis() inside ISR. For example
#define DEBOUNCE_TIME 200 // the debounce time in msec; increase if the output flickers
volatile unsigned long lastDebounceTime = 0;
volatile bool currentState = LOW;
void ICACHE_RAM_ATTR Falling()
{
unsigned long currentTime = millis();
if (currentTime > lastDebounceTime + DEBOUNCE_TI…
This project is not very simple, just to demonstrate the use of ISR-based Timers of TimerInterrupt library v1.0.2 on Arduino Mega/UNO/Nano, etc.
The design principles are as follows:
Fire or Smoke measurement and alarm activation are considered mission-critical, and must not be interfered or blocked by any other bad tasks, intentionally or unintentionally. This principle can be applied to any of your project. Please check the way ISR-based are designed ( very lean and mean ), no delay()…
This project is not very simple, just to demonstrate the use of ISR-based Timers of ESP8266TimerInterrupt library v1.0.2 (Hardware Timer Interrupt )
The design principles are as follows:
Fire or Smoke measurement and alarm activation are considered mission-critical, and must not be interfered or blocked by any other bad tasks, intentionally or unintentionally. This principle can be applied to any of your project. Please check the way ISR-based are designed (very lean and mean), no delay() a…
Brand new Hardware Timer Interrupt library for ESP8266
From README.md
## More useful Information
The ESP8266 timers are badly designed, using only 23-bit counter along with maximum 256 prescaler. They're only better than UNO / Mega.
The ESP8266 has two hardware timers, but timer0 has been used for WiFi and it's not advisable to use. Only timer1 is available. The timer1's 23-bit counter terribly can count only up to 8,388,607. So the timer1 maximum interval is very short. Using 256 prescaler…
I’ve seen this thread yesterday.
Unfortunately I still can’t understand why both Bynk.connect(1000) and Bynk.connect(3000) blocks code execution for 15 sec.
Moreover, I believe “unsigned long timeout = BLYNK_TIMEOUT_MS*3” does not relate to the case with the passed timeout. I mean connect(3000) should be 3 sec, not 9. But I have 15.
But using ISR correctly is not a simple task, you have to spend some time to study and use it correctly or the percentage of crashing is 100%.
1 Like