I am trying to make a call only once. But it is calling over and over. Code is If(t>20){ Sim800l.println(ATD +phone number)} How can I make it to call me once only? I just need to inform me if temperature is over 20°C. Using dht11, arduino uno and sim800l.
Asked
Active
Viewed 164 times
1 Answers
0
You could use a flag like so. Everytime the temperature drops below/equal to 20 the flag hasChanged
will be set to true
. And when the temperature rises above 20, the message will be printed once, and the flag will be toggled off until the next time the temperature drops.
// you'll have to adjust the syntax to meet your language needs
bool hasChanged = true;
if (t>20 && hasChanged) {
// this block happens once everytime the temperature surpasses 20
Sim800l.println(ATD +phone number);
hasChanged = false;
} else {
hasChanged = true;
}

Keegan Teetaert
- 643
- 6
- 22