Hi,
I am new to arduino so if this is a newbie question please excuse me. I have a project where I need to set an alarm and I am using the time and timealarms libraries found here https://www.pjrc.com/teensy/td_libs_TimeAlarms.html and in particular Alarm.timerRepeat(60, SendEmail); which should trigger every 60 seconds but it will trigger four to five times in a row and then trigger again in 60 seconds again 4-5 times. Below is the sketch that I am using. The sketch is not fully done but I was testing the library to see if it would suit my needs. Any help will be greatly welcome. Thanks again.
/*
Holding Tank Alarm v0.01
Reads an analog input on pin 0, converts it to voltage. If voltage is above 0 volts it sends a text that the
tank needs to be pumped. Connects wirelessly to WiFi in the house. If connection is lost program will continue to try to reconnect to WiFi and sends a text that it has reestablished connection. Program checks RTC on startup and once a month afterwards to set the time.
*/
// add libraries
#include <Time.h>
#include <TimeAlarms.h>
void setup()
{
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
setTime(22,00,0,1,30,15);
SendEmail();
}
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1023.0);
// print out the value you read:
Serial.println(voltage);
//display time
digitalClockDisplay();
// wait one second between clock display
Alarm.delay(1000);
// timer for every 60 seconds
Alarm.timerRepeat(60, SendEmail);
}
void digitalClockDisplay()
{
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.println();
}
void printDigits(int digits)
{
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}
void SendEmail()
{
Serial.println("Email sent");
}