You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 29, 2023. It is now read-only.
2. Fix compatibility issue causing compiler error while using Arduino IDEs before 1.8.10 and ESP8266 cores 2.5.2 and before
19
+
3. More hardware-initiated software-enabled timers
20
+
4. Longer time interval
21
+
22
+
## Features
23
+
9
24
This library enables you to use Interrupt from Hardware Timers on an ESP8266-based board.
10
25
11
-
Why do we need this Hardware Timer Interrupt?
26
+
#### Why do we need this Hardware Timer Interrupt?
12
27
13
-
Imagine you have a system with a mission-critical function, measuring water level and control the sump pump or doing something much more important. You normally use a software timer to poll, or even place the function in loop(). But what if another function is blocking the loop() or setup().
28
+
Imagine you have a system with a ***mission-critical*** function, measuring water level and control the sump pump or doing something much more important. You normally use a software timer to poll, or even place the function in loop(). But what if another function is ***blocking*** the loop() or setup().
14
29
15
-
So your function might not be executed, and the result would be disastrous.
30
+
So your function ***might not be executed, and the result would be disastrous.***
16
31
17
32
You'd prefer to have your function called, no matter what happening with other functions (busy loop, bug, etc.).
18
33
19
-
The correct choice is to use a Hardware Timer with Interrupt to call your function.
34
+
The correct choice is to use a Hardware Timer with ***Interrupt*** to call your function.
20
35
21
-
These hardware timers, using interrupt, still work even if other functions are blocking. Moreover, they are much more precise (certainly depending on clock frequency accuracy) than other software timers using millis() or micros(). That's necessary if you need to measure some data requiring better accuracy.
36
+
These hardware timers, using interrupt, still work even if other functions are blocking. Moreover, they are much more ***precise*** (certainly depending on clock frequency accuracy) than other software timers using millis() or micros(). That's necessary if you need to measure some data requiring better accuracy.
22
37
23
38
Functions using normal software timers, relying on loop() and calling millis(), won't work if the loop() or setup() is blocked by certain operation. For example, certain function is blocking while it's connecting to WiFi or some services.
24
39
25
-
The catch is your function is now part of an ISR (Interrupt Service Routine), and must be lean / mean, and follow certain rules. More to read on:
40
+
The catch is ***your function is now part of an ISR (Interrupt Service Routine), and must be lean / mean, and follow certain rules.*** More to read on:
1. Inside the attached function, delay() won’t work and the value returned by millis() will not increment. Serial data received while in the function may be lost. You should declare as volatile any variables that you modify within the attached function.
44
+
#### Important Notes:
45
+
46
+
1. Inside the attached function, ***delay() won’t work and the value returned by millis() will not increment.*** Serial data received while in the function may be lost. You should declare as ***volatile any variables that you modify within the attached function.***
31
47
32
48
2. Typically global variables are used to pass data between an ISR and the main program. To make sure variables shared between an ISR and the main program are updated correctly, declare them as volatile.
33
49
50
+
## Prerequisite
51
+
1.[`Arduino IDE 1.8.12 or later` for Arduino](https://www.arduino.cc/en/Main/Software)
52
+
2.[`ESP8266 core 2.6.3 or later` for Arduino](https://github.com/esp8266/Arduino#installing-with-boards-manager) for ESP8266 boards.
53
+
34
54
### Installation
35
55
56
+
The suggested way to install is to:
57
+
36
58
#### Use Arduino Library Manager
37
59
38
-
The suggested and easiest way is to use `Arduino Library Manager`. Search for `ESP8266TimerInterrupt`, then select / install the latest version.
60
+
The best way is to use `Arduino Library Manager`. Search for `ESP8266TimerInterrupt`, then select / install the latest version. You can also use this link [](https://www.ardu-badge.com/ESP8266TimerInterrupt) for more detailed instructions.
39
61
40
62
#### Manual Install
41
-
1. Navigate to [ESP8266TimerInterrupt](https://github.com/khoih-prog/ESP8266TimerInterrupt).
63
+
64
+
1. Navigate to [ESP8266TimerInterrupt](https://github.com/khoih-prog/ESP8266TimerInterrupt) page.
42
65
2. Download the latest release `ESP8266TimerInterrupt-master.zip`.
43
66
3. Extract the zip file to `ESP8266TimerInterrupt-master` directory
44
-
4. Copy whole folder to Arduino libraries' directory such as `.Arduino/libraries/ESP8266TimerInterrupt-master`.
67
+
4. Copy whole
68
+
-`ESP8266TimerInterrupt-master/src` folder to Arduino libraries' directory such as `~/Arduino/libraries/`.
69
+
45
70
46
71
## More useful Information
47
72
48
-
The ESP8266 timers are badly designed, using only 23-bit counter along with maximum 256 prescaler. They're only better than UNO / Mega.
73
+
The ESP8266 timers are ***badly designed***, using only 23-bit counter along with maximum 256 prescaler. They're only better than UNO / Mega.
49
74
The ESP8266 has two hardware timers, but timer0 has been used for WiFi and it's not advisable to use. Only timer1 is available.
50
75
The timer1's 23-bit counter terribly can count only up to 8,388,607. So the timer1 maximum interval is very short.
51
-
Using 256 prescaler, maximum timer1 interval is only 26.843542 seconds !!!
76
+
Using 256 prescaler, maximum timer1 interval is only ***26.843542 seconds !!!***
52
77
53
78
The timer1 counters can be configured to support automatic reload.
54
79
55
80
## New from v1.0.2
56
81
57
-
Now with these new `16 ISR-based timers`, the maximum interval is practically unlimited (limited only by unsigned long miliseconds)
58
-
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers
59
-
Therefore, their executions are not blocked by bad-behaving functions / tasks.
82
+
Now with these new ***`16 ISR-based timers`***, the maximum interval is ***practically unlimited*** (limited only by unsigned long miliseconds).
83
+
84
+
The accuracy is nearly perfect compared to software timers. The most important feature is they're ISR-based timers. Therefore, their executions are not blocked by bad-behaving functions / tasks.
85
+
60
86
This important feature is absolutely necessary for mission-critical tasks.
61
87
62
-
The `ISR_Timer_Complex` example will demonstrate the nearly perfect accuracy compared to software timers by printing the actual
63
-
elapsed millisecs of each type of timers.
64
-
Being ISR-based timers, their executions are not blocked by bad-behaving functions / tasks, such as connecting to WiFi, Internet
65
-
and Blynk services. You can also have many `(up to 16)` timers to use.
66
-
This non-being-blocked important feature is absolutely necessary for mission-critical tasks.
67
-
You'll see blynkTimer Software is blocked while system is connecting to WiFi / Internet / Blynk, as well as by blocking task
68
-
in loop(), using delay() function as an example. The elapsed time then is very unaccurate
88
+
The [ISR_Timer_Complex example](examples/ISR_Timer_Complex) will demonstrate the nearly perfect accuracy compared to software timers by printing the actual elapsed millisecs of each type of timers.
89
+
90
+
Being ISR-based timers, their executions are not blocked by bad-behaving functions / tasks, such as connecting to WiFi, Internet and Blynk services. You can also have many `(up to 16)` timers to use. This non-being-blocked important feature is absolutely necessary for mission-critical tasks.
91
+
92
+
You'll see blynkTimer Software is blocked while system is connecting to WiFi / Internet / Blynk, as well as by blocking task in loop(), using delay() function as an example. The elapsed time then is very unaccurate
0 commit comments