paulstoffregen / timealarms Goto Github PK
View Code? Open in Web Editor NEWTime library add-on, schedule alarms to occur at specific dates/times
Home Page: http://www.pjrc.com/teensy/td_libs_TimeAlarms.html
Time library add-on, schedule alarms to occur at specific dates/times
Home Page: http://www.pjrc.com/teensy/td_libs_TimeAlarms.html
Alarms The Alarm library is a companion to the Time library that makes it easy to perform tasks at specific times or after specific intervals. Tasks scheduled at a particular time of day are called Alarms, tasks scheduled after an interval of time has elapsed are called Timers. These tasks can be created to continuously repeat or to occur once only. Here is how you create an alarm to trigger a task repeatedly at a particular time of day: Alarm.alarmRepeat(8,30,0, MorningAlarm); This would call the function MorningAlarm() at 8:30 am every day. If you want the alarm to trigger only once you can use the alarmOnce method: Alarm.alarmOnce(8,30,0, MorningAlarm); This calls a MorningAlarm() function in a sketch once only (when the time is next 8:30am) Alarms can be specified to trigger a task repeatedly at a particular day of week and time of day: Alarm.alarmRepeat(dowMonday, 9,15,0, MondayMorningAlarm); This would call the function WeeklyAlarm() at 9:15am every Monday. If you want the alarm to trigger once only on a particular day and time you can do this: Alarm.alarmOnce(dowMonday, 9,15,0, MondayMorningAlarm); This would call the function MondayMorning() Alarm on the next Monday at 9:15am. Timers trigger tasks that occur after a specified interval of time has passed. The timer interval can be specified in seconds, or in hour, minutes and seconds. Alarm.timerRepeat(15, Repeats); // timer task every 15 seconds This calls the Repeats() function in your sketch every 15 seconds. If you want a timer to trigger once only, you can use the timerOnce method: Alarm.timerOnce(10, OnceOnly); // called once after 10 seconds This calls the onceOnly() function in a sketch 10 seconds after the timer is created. If you want to trigger once at a specified date and time you can use the trigger Once() method: Alarm. triggerOnce(time_t value, explicitAlarm); // value specifies a date and time (See the makeTime() method in the Time library to convert dates and times into time_t) Your sketch should call the Alarm.delay() function instead of the Arduino delay() function when using the Alarms library. The timeliness of triggers depends on sketch delays using this function. Alarm.delay( period); // Similar to Arduino delay - pauses the program for the period (in milliseconds). Here is an example sketch: This sketch triggers daily alarms at 8:30 am and 17:45 pm. A Timer is triggered every 15 seconds, another timer triggers once only after 10 seconds. A weekly alarm is triggered every Sunday at 8:30:30 #include <Time.h> #include <TimeAlarms.h> void setup() { Serial.begin(9600); setTime(8,29,0,1,1,11); // set time to Saturday 8:29:00am Jan 1 2011 // create the alarms Alarm.alarmRepeat(8,30,0, MorningAlarm); // 8:30am every day Alarm.alarmRepeat(17,45,0,EveningAlarm); // 5:45pm every day Alarm.alarmRepeat(dowSaturday,8,30,30,WeeklyAlarm); // 8:30:30 every Saturday Alarm.timerRepeat(15, Repeats); // timer for every 15 seconds Alarm.timerOnce(10, OnceOnly); // called once after 10 seconds } void loop(){ digitalClockDisplay(); Alarm.delay(1000); // wait one second between clock display } // functions to be called when an alarm triggers: void MorningAlarm(){ Serial.println("Alarm: - turn lights off"); } void EveningAlarm(){ Serial.println("Alarm: - turn lights on"); } void WeeklyAlarm(){ Serial.println("Alarm: - its Monday Morning"); } void ExplicitAlarm(){ Serial.println("Alarm: - this triggers only at the given date and time"); } void Repeats(){ Serial.println("15 second timer"); } void OnceOnly(){ Serial.println("This timer only triggers once"); } 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); } Note that the loop code calls Alarm.delay(1000) - Alarm.delay must be used instead of the usual arduino delay function because the alarms are serviced in the Alarm.delay method. Failing to regularly call Alarm.delay will result in the alarms not being triggered so always use Alarm.delay instead of delay in sketches that use the Alarms library. Functional reference: // functions to create alarms and timers Alarm.triggerOnce(value, AlarmFunction); Description: Call user provided AlarmFunction once at the date and time of the given value See the Ttime library for more on time_t values Alarm.alarmRepeat(Hour, Minute, Second, AlarmFunction); Description: Calls user provided AlarmFunction every day at the given Hour, Minute and Second. Alarm.alarmRepeat(value, AlarmFunction); Description: Calls user provided AlarmFunction every day at the time indicated by the given value Alarm.alarmRepeat(DayOfWeek, Hour, Minute, Second, AlarmFunction); Description: Calls user provided AlarmFunction every week on the given DayOfWeek, Hour, Minute and Second. Alarm.alarmOnce(Hour, Minute, Second, AlarmFunction); Description: Calls user provided AlarmFunction once when the Arduino time next reaches the given Hour, Minute and Second. Alarm.alarmOnce(value, AlarmFunction); Description: Calls user provided AlarmFunction once at the next time indicated by the given value Alarm.alarmOnce(DayOfWeek, Hour, Minute, Second, AlarmFunction); Description: Calls user provided AlarmFunction once only on the next DayOfWeek, Hour, Minute and Second. Alarm.timerRepeat(Period, TimerFunction); Description: Continuously calls user provided TimerFunction after the given period in seconds has elapsed. Alarm.timerRepeat(Hour, Minute, Second, TimerFunction); Description: As timerRepeat above, but period is the number of seconds in the given Hour, Minute and Second parameters Alarm.timerOnce(Period, TimerFunction); Description: Calls user provided TimerFunction once only after the given period in seconds has elapsed. Alarm.timerOnce(Hour, Minute, Second, TimerFunction); Description: As timerOnce above, but period is the number of seconds in the given Hour, Minute and Second parameters Alarm.delay( period) Description: Similar to Arduino delay - pauses the program for the period (in miliseconds) specified. Call this function rather than the Arduino delay function when using the Alarms library. The timeliness of the triggers depends on sketch delays using this function. Low level functions not usually required for typical applications: disable( ID); - prevent the alarm associated with the given ID from triggering enable(ID); - enable the alarm write(ID, value); - write the value (and enable) the alarm for the given ID read(ID); - return the value for the given ID readType(ID); - return the alarm type for the given alarm ID getTriggeredAlarmId(); - returns the currently triggered alarm id, only valid in an alarm callback FAQ Q: What hardware and software is needed to use this library? A: This library requires the Time library. No internal or external hardware is used by the Alarm library. Q: Why must I use Alarm.delay() instead of delay()? A: Task scheduling is handled in the Alarm.delay function. Tasks are monitored and triggered from within the Alarm.delay call so Alarm.delay should be called whenever a delay is required in your sketch. If your sketch waits on an external event (for example, a sensor change), make sure you repeatedly call Alarm.delay while checking the sensor. You can call Alarm.delay(0) if you need to service the scheduler without a delay. Q: Are there any restrictions on the code in a task handler function? A: No. The scheduler does not use interrupts so your task handling function is no different from other functions you create in your sketch. Q: What are the shortest and longest intervals that can be scheduled? A: Time intervals can range from 1 second to years. (If you need timer intervals shorter than 1 second then the TimedAction library by Alexander Brevig may be more suitable, see: http://www.arduino.cc/playground/Code/TimedAction) Q: How are scheduled tasks affected if the system time is changed? A: Tasks are scheduled for specific times designated by the system clock. If the system time is reset to a later time (for example one hour ahead) then all alarms and timers will occur one hour later. If the system time is set backwards (for example one hour back) then the alarms and timers will occur an hour earlier. If the time is reset before the time a task was scheduled, then the task will be triggered on the next service (the next call to Alarm.delay). This is the expected behaviour for Alarms � tasks scheduled for a specific time of day will trigger at that time, but the affect on timers may not be intuitive. If a timer is scheduled to trigger in 5 minutes time and the clock is set ahead by one hour, that timer will not trigger until one hour and 5 minutes has elapsed. Q: What is the valid range of times supported by these libraries? A: The time library is intended to handle times from Jan 1 1970 through Jan 19 2038. The Alarms library expects dates to be on or after Jan1 1971 so clocks should no be set earlier than this if using Alarms. (The functions to create alarms will return an error if an earlier date is given). Q: How many alarms can be created? A: Up to six alarms can be scheduled. The number of alarms can be changed in the TimeAlarms header file (set by the constant dtNBR_ALARMS, note that the RAM used equals dtNBR_ALARMS * 11) onceOnly Alarms and Timers are freed when they are triggered so another onceOnly alarm can be set to trigger again. There is no limit to the number of times a onceOnly alarm can be reset. The following fragment gives one example of how a timerOnce task can be rescheduled: Alarm.timerOnce(random(10), randomTimer); // trigger after random number of seconds void randomTimer(){ int period = random(2,10); // get a new random period Alarm.timerOnce(period, randomTimer); // trigger for another random period }
Hi. getNextTrigger always returns -1 on Wemos D1 (I have not tested it on another micro). I've noticed that the loop on the allocated alarms starts with nextTrigger = ffffffff, which is -1, so it never updates to a minor value in the inner comparation.
If I put 7ffffff as the maximun value the function returns the right result, but I'm not sure there is another hidden conflict.
Hi! It seems that for some reason my alarms won't set. I changed all the delays to Alarm.delay. Would it be possible that it is due to the scheduled non-busy wait loops?
/******************************************************
De buitenbloem - prototype vs1
Imara
*/
// dfplayer
#include <DFPlayer_Mini_Mp3.h>
#include <SoftwareSerial.h>
// adafruit neopixel
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
// esp
#include <ESP8266WiFi.h>
// json streamer
#include <JsonListener.h>
#include <JsonStreamingParser.h>
// weather client librarier
#include "WundergroundClient.h"
#include "TimeClient.h"
#include <Time.h>
#include <TimeLib.h>
#include <TimeAlarms.h>
#include "ThingspeakClient.h"
// pin definities
// Serial uses UART0, WHICH IS MAPPED TO GPIO1 (TX) and GPIO3 (RX)
#define KNOP D3 // GPIO0
#define KNOPLED D7 // GPIO2 IS alternative TX TODO how to turn of alternative TX??
#define PIR D0 // GPIO
#define NEO D6 // GPIO04
#define BUSY D5 // GPIO05 TODO weghalen?
// GPIO15, GPIO0 en GPIO2 worden gebruikt voor resets
SoftwareSerial mySerial(D1, D2); // RX, TX
// constants
#define NUMPIXELS 39
#define KNOPPIXELS 9
#define LEAFPIXELS 3
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, NEO, NEO_GRB + NEO_KHZ800);
// wifi variables
#define myPeriodic 15 //in sec | Thingspeak pub is 15sec
const char* server = "api.thingspeak.com";
String apiKey = "bla";
const char* MY_SSID = "XperImara";
const char* MY_PWD = "bla";
const float UTC_OFFSET = 2;
const char WEBSITE[] = "api.pushingbox.com"; //pushingbox API server
const String devid = "bla"; //device ID on Pushingbox for our Scenario
// Wunderground Settings
const boolean IS_METRIC = true;
const String WUNDERGRROUND_API_KEY = "88abd7366bd93123";
const String WUNDERGRROUND_LANGUAGE = "NL";
const String WUNDERGROUND_COUNTRY = "NL";
const String WUNDERGROUND_CITY = "Naarden";
int8_t tempint;
int8_t hourint;
TimeClient timeClient(UTC_OFFSET);
// Set to false, if you prefere imperial/inches, Fahrenheit
WundergroundClient wunderground(IS_METRIC);
ThingspeakClient thingspeak;
String lastUpdate = "--";
String verpleeghuis = "Naarden";
uint8_t landscapeSound, triggerSound;
boolean twice = true;
int sent = 0;
// knoppen variables
uint8_t knopState = HIGH;
uint8_t lastKnopState = HIGH;
uint8_t reading = 0;
uint32_t lastDebounceTime = 0;
uint32_t debounceDelay = 50;
uint8_t playMode = 0;
uint8_t prevPlayMode = 0;
#define offMODE 0
#define introMODE 1
#define playMODE 2
#define outroMODE 3
#define mp3delay 1000
// defining tracks
#define MINTRIGGER 1
#define MAXTRIGGER 11
#define MINLAND 52
#define MAXLAND 64
#define MINCELCIUS 95
#define MAXCELCIUS 130
#define GOEDEMO 151
#define GOEDEMI 152
#define GOEDENA 153
#define LVOL 30
#define TVOL 30
#define INTRO 80
#define OUTRO 81
boolean isOff = true;
boolean playState = HIGH;
boolean landState = HIGH;
boolean trigState = LOW;
// knop tijden
uint32_t knopStart = 0;
uint32_t knopTime = 4000;
#define SHORTINTRO 30000
#define LONGINTRO 30000
uint32_t logDelay = 3600000;
uint32_t lastLogTime = 0;
uint16_t peopleDetected = 0;
// play tijden
uint32_t introStart = 0;
uint32_t introTime = 15000; // de tijd van de intro
uint32_t playStart = 0;
uint32_t playTime = 100000;
uint32_t outroStart = 0;
uint32_t outroTime = 20000;
uint8_t readPIR = 0;
uint8_t lastPIRState = LOW;
uint8_t calibrationTime = 30;
uint8_t ledState = LOW;
uint8_t lokState = LOW;
// led counters
uint8_t leafCounter = 0;
uint8_t brightness = 0; // how bright the LED is
uint8_t fadeAmount = 5; // how many points to fade the LED by
uint32_t lastFadeTime = 0;
uint32_t fadeDelay = 30;
uint32_t rainbowDelay = 10;
uint8_t UP = LOW;
uint32_t liveDelay = 50;
#define FADEMIN 30
#define FADEMAX 150
// Color definitions
uint32_t pixelsOff = pixels.Color(0, 0, 0);
#define NUMCOLORS 7
uint32_t leafColor[NUMCOLORS] = { pixels.Color(217, 14, 14),
pixels.Color(24, 250, 35),
pixels.Color(0, 0, 255),
pixels.Color(242, 250, 10),
pixels.Color(240, 0, 230),
pixels.Color(0, 250, 170),
pixels.Color(250, 100, 0)
};
// individual components to fade colors with
uint8_t leafR;
uint8_t leafG;
uint8_t leafB;
tmElements_t tmi;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.setDebugOutput(true);
Serial.println("");
Serial.println(F("Welkom bij de buitenbloem"));
// set up input
pinMode(KNOP, INPUT);
pinMode(PIR, INPUT);
pinMode(BUSY, INPUT);
/*
// calibrate the pir
digitalWrite(PIR, LOW);
//give the sensor some time to calibrate
Serial.print("calibrating sensor ");
for (int i = 0; i < calibrationTime; i++) {
Serial.print(".");
Alarm.delay(1000);
}
Serial.println(" done");
Serial.println("SENSOR ACTIVE");
Alarm.delay(50);
*/
// set up output
pinMode(KNOPLED, OUTPUT);
//analogWrite(KNOPLED, 0);
digitalWrite(KNOPLED, HIGH);
pixels.begin(); // This initializes the NeoPixel library.
setPixels(pixelsOff);
// set up mp3 player
mySerial.begin(9600);
mp3_set_serial (mySerial); //set Serial for DFPlayer-mini mp3 module
mp3_set_volume (LVOL);
Alarm.delay(mp3delay);
mp3_stop();
Alarm.delay(mp3delay); //wait 1ms for mp3 module to set volume
// connect to the wifi
//WiFi.disconnect();
//Alarm.delay(2000);
//connectWifi();
timeClient.updateTime();
Serial.println(timeClient.getFormattedTime());
Serial.println(timeClient.getHours());
updateData();
setTime(timeClient.getHours().toInt(),timeClient.getMinutes().toInt(),timeClient.getSeconds().toInt(),1,1,11);
Alarm.timerRepeat(30, Repeats); // timer for every 15 seconds
Alarm.alarmRepeat(11,48,0, MorningAlarm);
// blink flower green to show its connected
setPixels(pixels.Color(0, 255 , 0));
Alarm.delay(500);
setPixels(pixelsOff);
Alarm.delay(500);
}
void Repeats(){
Serial.println("15 second timer");
}
void MorningAlarm(){
Serial.println("Alarm: - turn lights off");
}
void loop() {
reading = digitalRead(KNOP);
readPIR = digitalRead(PIR);
isOff = digitalRead(BUSY);
if (reading != lastKnopState) {
lastDebounceTime = millis();
}
if ((millis() - lastDebounceTime) > debounceDelay) {
if (reading != knopState) {
knopState = reading;
// button has an internal pull-up
if (knopState == LOW) {
// als hij ingedrukt wordt wanneer hij uit staat
Serial.println("Knop");
// start counting whether the button is a long or short press
knopStart = millis();
if (playMode == playMODE) {
Serial.print(F("speel een trigger geluid: "));
mp3_stop();
Alarm.delay(100);
mp3_set_volume(TVOL);
Alarm.delay(100);
// make sure every trigger is player twice
if (twice == true) {
triggerSound = random(MINTRIGGER, MAXTRIGGER);
}
Serial.println(triggerSound);
mp3_play(triggerSound);
twice = !twice;
Alarm.delay(mp3delay);
// Alarm.delay niet nodig vanwege het versturen van de data
mp3_set_volume(LVOL);
sendValue(HIGH, landscapeSound, triggerSound);
}
}
// if the button is released
else {
if (playMode == offMODE) {
// seed the randomness
randomSeed ( (unsigned int)( millis() + analogRead(A0) ) );
analogWrite(KNOPLED, 255);
setKnopPixels(pixelsOff);
introStart = millis();
// if the button is pressed long enough, do a long intro, else a short one
if (millis() - knopStart > knopTime) {
introTime = LONGINTRO;
playMode = introMODE;
// zet de intro aan
Serial.println(F("intro"));
mp3_play(INTRO);
Alarm.delay(mp3delay);
sendValue(HIGH, 0, 0);
peopleDetected = 0;
// update alle data
updateData();
}
// if it is not supposed to turn on, turn on trigger
else {
// blink flower green to show its connected
setPixels(leafColor[random(0, 7)]);
Serial.print(F("speel een trigger geluid: "));
mp3_stop();
Alarm.delay(100);
if (twice == true) {
triggerSound = random(MINTRIGGER, MAXTRIGGER);
}
Serial.println(triggerSound);
mp3_play(triggerSound);
twice = !twice;
Alarm.delay(mp3delay);
sendValue(HIGH, 0, triggerSound);
setPixels(pixelsOff);
}
}
}
}
}
// log the number of people detected
if (millis() - lastLogTime > logDelay) {
sendValue(LOW, 0, 0);
}
// dynamische acties - faden etc
switch (playMode) {
case offMODE:
// if someone has been detected or has not been detected anymore
if (lastPIRState != readPIR) {
lokState = !lokState;
// er is net iemand gedetecteerd
if (lokState == HIGH) {
peopleDetected++;
Serial.print(F("people detected: "));
Serial.println(peopleDetected);
}
// als er niemand meer gedetecteerd word, zet dan het hart licht uit
if (lokState == LOW) {
Serial.println(F("nobody detected"));
setKnopPixels(pixelsOff);
analogWrite(KNOPLED, 0);
}
}
if (lokState == HIGH) {
lokMensen();
}
break;
case introMODE:
// fade de kleuren lichtjes zoals de intro
intro();
// if intro is done, go to play
if (millis() - introStart > introTime) {
// play a random landscape
landscapeSound = random(MINLAND, MAXLAND);
mp3_play(landscapeSound);
Alarm.delay(mp3delay);
// pick the trigger colors
playMode = playMODE;
uint8_t player = random(NUMCOLORS);
setPixels(leafColor[player]);
Serial.println(leafColor[player], HEX);
// get the chosen color individual elements;
uint32_t color = pixels.getPixelColor(NUMPIXELS - 1);
leafR = (color & 0xFF0000) >> 16;
leafG = (color & 0x00FF00) >> 8;
leafB = (color & 0x0000FF);
leafCounter = 255;
brightness = 255;
playStart = millis();
Serial.printf("playmode: ");
Serial.println(player);
// wacht even en groet dan
Alarm.delay(2000);
if (hourint < 12) {
mp3_play(GOEDEMO);
Alarm.delay(3000);
}
else if (hourint < 18) {
mp3_play(GOEDEMI);
Alarm.delay(3000);
}
else {
mp3_play(GOEDENA);
Alarm.delay(3000);
}
// laat weten hoe warm het is
Serial.println(F("goeden iets"));
mp3_play(100 + tempint);
Alarm.delay(5000);
Serial.println(F("Het is vandaag "));
Serial.print(tempint);
Serial.print(F(" graden"));
}
break;
case playMODE:
// slowly fade the colors in and out
play(leafR, leafG, leafB);
// if song has stopped, play another - check the busy line on DSP
if (isOff) {
// turn on background song
Serial.println("play random");
landscapeSound = random(MINLAND, MAXLAND);
mp3_play(landscapeSound);
Alarm.delay(mp3delay);
}
// if play is done, go to outro
if (millis() - playStart > playTime) {
mp3_play(OUTRO);
Alarm.delay(mp3delay);
analogWrite(KNOPLED, 0);
playMode = outroMODE;
outroStart = millis();
Serial.println(F("outro"));
}
break;
case outroMODE:
// animate outro
outro();
// if outro is done, got back to off
if (millis() - outroStart > outroTime) {
mp3_pause();
brightness = 0;
setPixels(pixelsOff);
playMode = offMODE;
Serial.println("off");
sendValue(LOW, 0, 0);
lokState = LOW;
}
break;
}
lastPIRState = readPIR;
lastKnopState = reading;
prevPlayMode = playMode;
}
void setKnopPixels(uint32_t c) {
for (uint8_t i = 0; i < KNOPPIXELS; i++) {
pixels.setPixelColor(i, c);
}
pixels.show();
}
void setPixels(uint32_t c) {
for (uint8_t i = KNOPPIXELS; i < NUMPIXELS; i++) {
pixels.setPixelColor(i, c);
}
pixels.show();
}
void lokMensen() {
if (millis() - lastFadeTime > fadeDelay) {
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// animeer alleen de pixels in de knop
for (uint8_t i = 0; i < KNOPPIXELS; i++) {
pixels.setPixelColor(i, pixels.Color(brightness, 0, 0));
}
pixels.show();
analogWrite(KNOPLED, brightness);
lastFadeTime = millis();
}
}
void lokAnimatie() {
uint8_t i;
for (i = 2; i < NUMPIXELS; i += 3) {
pixels.setPixelColor(i, pixels.Color(50, 0, 0));
}
pixels.show();
Alarm.delay(100);
for (i = 2; i < NUMPIXELS; i += 3) {
pixels.setPixelColor(i, pixels.Color(0, 0, 0));
}
for (i = 1; i < NUMPIXELS; i += 3) {
pixels.setPixelColor(i, pixels.Color(100, 0, 0));
}
pixels.show();
Alarm.delay(200);
for (i = 1; i < NUMPIXELS; i += 3) {
pixels.setPixelColor(i, pixels.Color(0, 0, 0));
}
for (i = 0; i < NUMPIXELS; i += 3) {
pixels.setPixelColor(i, pixels.Color(255, 0, 0));
}
pixels.show();
Alarm.delay(300);
setPixels(pixelsOff);
Alarm.delay(400);
}
void intro() {
if (millis() - lastFadeTime > rainbowDelay) {
// animeer alleen de pixels in de knop
uint8_t i;
brightness = 255 * (millis() - introStart) / introTime;
for (i = KNOPPIXELS; i < pixels.numPixels(); i += LEAFPIXELS) {
pixels.setPixelColor(i, WheelValue(((i * 256 / pixels.numPixels()) + leafCounter) & 255, brightness));
pixels.setPixelColor(i + 1, WheelValue(((i * 256 / pixels.numPixels()) + leafCounter) & 255, brightness));
pixels.setPixelColor(i + 2, WheelValue(((i * 256 / pixels.numPixels()) + leafCounter) & 255, brightness));
}
leafCounter++;
if (leafCounter > 255) leafCounter = 0;
pixels.show();
lastFadeTime = millis();
}
}
void play(uint8_t c1, uint8_t c2, uint8_t c3) {
if (millis() - lastFadeTime > liveDelay) {
// animeer alleen de pixels in de knop
uint8_t i;
for (i = KNOPPIXELS; i < pixels.numPixels(); i++) {
pixels.setPixelColor(i, pixels.Color(c1 * leafCounter / 255, c2 * leafCounter / 255, c3 * leafCounter / 255));
pixels.show();
}
if (!UP) {
leafCounter--;
}
else {
leafCounter++;
}
if (leafCounter < FADEMIN) {
UP = HIGH;
}
else if (leafCounter > FADEMAX) {
UP = LOW;
}
pixels.show();
lastFadeTime = millis();
}
}
void outro() {
if (millis() - lastFadeTime > rainbowDelay) {
uint8_t i;
// start a little less bright
brightness = 180 * (outroTime - (millis() - outroStart)) / outroTime;
for (i = KNOPPIXELS; i < pixels.numPixels(); i += LEAFPIXELS) {
pixels.setPixelColor(i, WheelValue(((i * 256 / pixels.numPixels()) + leafCounter) & 255, brightness));
pixels.setPixelColor(i + 1, WheelValue(((i * 256 / pixels.numPixels()) + leafCounter) & 255, brightness));
pixels.setPixelColor(i + 2, WheelValue(((i * 256 / pixels.numPixels()) + leafCounter) & 255, brightness));
}
leafCounter++;
if (leafCounter > 255) leafCounter = 0;
pixels.show();
lastFadeTime = millis();
}
}
void connectWifi()
{
Serial.print("Connecting to " + *MY_SSID);
WiFi.begin(MY_SSID, MY_PWD);
while (WiFi.status() != WL_CONNECTED) {
Alarm.delay(1000);
Serial.print(".");
}
// blink flower green to show its connected
setPixels(pixels.Color(0, 0 , 255));
Alarm.delay(500);
setPixels(pixelsOff);
Alarm.delay(500);
Serial.println("");
Serial.println("Connected");
Serial.println("");
}
void sendValue(int pressed, int landscape, int trigger)
{
long timetosend = millis();
Serial.println("\nSending Data to Server...");
// if you get a connection, report back via serial:
WiFiClient client; //Instantiate WiFi object, can scope from here or Globally
//API service using WiFi Client through PushingBox then relayed to Google
if (client.connect(WEBSITE, 80))
{
if (pressed == HIGH) {
client.print("GET /pushingbox?devid=" + devid
+ "&humidityData=" + verpleeghuis
+ "&celData=" + (String) pressed
+ "&fehrData=" + landscape
+ "&hicData=" + trigger
+ "&hifData=" + peopleDetected
);
}
else {
client.print("GET /pushingbox?devid=" + devid
+ "&humidityData=" + verpleeghuis
+ "&celData=" + (String) pressed
+ "&fehrData=" + "--"
+ "&hicData=" + "--"
+ "&hifData=" + peopleDetected
);
peopleDetected = 0;
lastLogTime = millis();
}
// HTTP 1.1 provides a persistent connection, allowing batched requests
// or pipelined to an output buffer
client.println(" HTTP/1.1");
client.print("Host: ");
client.println(WEBSITE);
client.println("User-Agent: ESP8266/1.0");
client.println("Connection: close");
client.println();
}
timetosend = millis() - timetosend;
Serial.println(timetosend);
}
void updateData() {
Serial.println("Updating conditions");
wunderground.updateConditions(WUNDERGRROUND_API_KEY, WUNDERGRROUND_LANGUAGE, WUNDERGROUND_COUNTRY, WUNDERGROUND_CITY);
// update the time in the setup
String hours = timeClient.getHours();
hourint = hours.toInt();
//Serial.println("time is: ");
//Serial.print(hourint);
//Serial.println("");
String temp = wunderground.getCurrentTemp() + "°C";
tempint = temp.toInt();
//Serial.println("temperature is: ");
//Serial.println(tempint);
//Serial.println("");
//Serial.println("done");
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if (WheelPos < 85) {
return pixels.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if (WheelPos < 170) {
WheelPos -= 85;
return pixels.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return pixels.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
uint32_t WheelValue(byte WheelPos, byte Value) {
WheelPos = 255 - WheelPos;
if (WheelPos < 85) {
return pixels.Color((255 - WheelPos * 3) * Value / 255, 0, (WheelPos * 3) * Value / 255);
}
if (WheelPos < 170) {
WheelPos -= 85;
return pixels.Color(0, (WheelPos * 3) * Value / 255, (255 - WheelPos * 3) * Value / 255);
}
WheelPos -= 170;
return pixels.Color((WheelPos * 3) * Value / 255, (255 - WheelPos * 3) * Value / 255, 0);
}
Hi !
I want to set the time just once in the arduino and then just execute the alarm program, how i can do that ?? i tried:
Some help ?? Grettings !
I want to be able to use an Array of Alarms, and that the function inside the alarm can take a data to use in the future, but i just dont know how to make it possible.. something like this..
Alarm Id[5];
Id[0] = Alarm.alarmRepeat(17,0,0, Repeateveryseconds(0));
void Repeateveryseconds(int Data){
Alarm.free(id[Data]);
id[Data] = dtINVALID_ALARM_ID;
id[Data] = Alarm.alarmRepeat(17,0,second()+5,Repeateveryseconds(Data));
Serial.println("It works");
}
is there any possible way to adchieve this?
Hi!
How do I change the time of an Alarm?
Example:
alarm = Alarm.alarmRepeat(8,30,0, MorningAlarm); // 8:30am every day
I'm trying to do something like:
A. alarm = Alarm.alarmRepeat(8,35,0, MorningAlarm); // 8:35am every day
B.
Alarm.disable(alarm);
alarm = Alarm.alarmRepeat(8,35,0, MorningAlarm); // 8:35am every day
C. Alarm.write(alarm, AlarmHMS(8, 35, 0));
None of them works... :-/
Thanks!
I reallly need a form to use parameters..
Alarm.timerOnce (10,0,0, ledOn (2));
Void ledOn (int ledPin) {
digitalWtite (ledPin, High)
}
Can you help me?
I'm using a Wemos D1 mini and the board resets if I set Alarm.delay() with more than 1000 ms. The only way to make longer pauses is to put a loop with {Alarm.delay(1000);delay(1);} as even two consecutive Alarm.delay(1000) reset the board.
I also have a second question, is TimeAlarms compatible with deepsleep? The source code for Alarm.delay() seems a busy-wait loop, which is not very energy-saver...
HI all.
I really dont know what's going on here. Can somebody give me a hand?
The thing is that the 4 Alarm dont never is triggered.
Thanks all.
By the way, is like more than 6 alarmRepeat are not permited. Because if i put the alarm number 4 just before the others... well then that work but not the last....
This is my code:
#include <Time.h>
#include <TimeAlarms.h>
#include <DS1307RTC.h>
void setup () {
Serial.begin(9600);
pinMode(2, OUTPUT);
digitalWrite(2, HIGH);
pinMode(6, OUTPUT);
digitalWrite(6, HIGH);
pinMode(8, OUTPUT);
digitalWrite(8, HIGH);
pinMode(4, OUTPUT);
digitalWrite(4, HIGH);
setSyncProvider(RTC.get);
if (timeStatus() != timeSet)
Serial.println("Fallo de RTC");
else
Serial.println("Sincronizado con RTC");
// Crear las alarmas y configurar las funciones correspondientes a cada una
Alarm.alarmRepeat(22, 52, 0, EventoEnciendeLuz);
Alarm.alarmRepeat(22, 52, 30, EventoApagaLuz);
Alarm.alarmRepeat(22, 53, 0, EventoEnciendeLuz2);
Alarm.alarmRepeat(22, 53, 30, EventoApagaLuz2);
///////////////
Alarm.alarmRepeat(22, 54, 0, EventoEnciendeLuz3);
Alarm.alarmRepeat(22, 54, 30, EventoApagaLuz3);
Alarm.alarmRepeat(22, 55, 0, EventoEnciendeLuz4);
Alarm.alarmRepeat(22, 55, 30, EventoApagaLuz4);
}
void loop() {
digitalClockDisplay();
Alarm.delay(1000);
}
void EventoEnciendeLuz()
{
Serial.println("Encendiendo Luz!!!");
digitalWrite(2, LOW);
}
void EventoApagaLuz()
{
Serial.println("Apagando Luz!!!");
digitalWrite(2, HIGH);
}
void EventoEnciendeLuz2()
{
Serial.println("Encendiendo Luz!!!");
digitalWrite(6, LOW);
}
void EventoApagaLuz2()
{
Serial.println("Apagando Luz!!!");
digitalWrite(6, HIGH);
}
void EventoEnciendeLuz3()
{
Serial.println("Encendiendo Luz!!!");
digitalWrite(8, LOW);
}
void EventoApagaLuz3()
{
Serial.println("Apagando Luz!!!");
digitalWrite(8, HIGH);
}
void EventoEnciendeLuz4()
{
Serial.println("Encendiendo Luz!!!");
digitalWrite(4, LOW);
}
void EventoApagaLuz4()
{
Serial.println("Apagando Luz!!!");
digitalWrite(4, HIGH);
}
void digitalClockDisplay() {
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.println();
}
void printDigits(int digits) {
Serial.print(":");
if (digits < 10)
Serial.print('0');
Serial.print(digits);
}
Analyzing your code shows following problem in line 195 of TimeAlarms.cpp:
Timealarms lib is not working if you use ntp sync.
Please give an example if you can make it work.
Hello,
If I use the example script, everything goes with esp8266-e12 great. Also on my Arduino Uno with RTC everything is super. :-)
For an ESP8266 with NTP without RTC the alarm works fine every 15 seconds. But alarm at certain special times does not work. For alarm time I use UTC and UTC time is displayed with digitalClockDisplay (); In serial print, correct UTC time is displayed. No alarm at special alarm time, only the 15 second alarm is all 15sec to see.
I use that NTP Script for EPS8266-E12 to get Time from Internet
http://www.arduinoclub.de/2016/05/07/arduino-ide-esp8266-ntp-server-timezone/
Do you have a idea?
I use the fake code below to trigger a hourly bell.
1.Settime(...)
2.(add 48 alarms)
Alarm.repeate(00:00, bell)
Alarm.repeate(00:30,bell)
....
Alarm.repeate(23:00, bell)
Void bell()
{
...
}
I think the 48 alarms may use the small ram of esp8266, could you please add a graceful function that can alarm hourly all the day?
Thank you.
Time check in TimeAlarmsClass::create avoids that alarms can be created before system time is set
System time has at least to elapse 1 year (1.1.1971) before alarms can be added. I don't see a reason not to allow this. This one is required for setting up a alarm schedule at startup in combination with system time is setup later on (ie. as soon as NTP server is reachable)
if ( ! ( (dtIsAlarm(alarmType) && **now() < SECS_PER_YEAR**) || (dtUseAbsoluteValue(alarmType) && (value == 0)) ) ) {
Alarm.alarmRepeat(1, handle);
setTime(0);
TimeAlarms 1.5.0
Is it possible to set an alarm that triggers at the top of every minute?
It looks like Alarm.timerRepeat(60, everyMin); will trigger once a minute, every minutes, but it's relative to the start time. I'd like to be specifiy an event that triggers at the top of every minute.
I make a test with BasicOTA.ino and it work fine on my Wemos D1 mini
I modified the sketch with
...
#include <TimeLib.h>
#include <TimeAlarms.h
...
void loop() {
ArduinoOTA.handle();
Alarm.delay(1000);
}
And my wemos don't appear on network port
Hello
The have way to setup alarm for trigger on Week day , and other Alarm for Weekend Day ( Saturday , Sunday ) ?
Thanks
Alain Tanguay
I have a problem when I try to get the local time using the standard ESP32 function getLocalTime
. The following error appears:
error: aggregate 'tm timeinfo' has incomplete type and cannot be
defined
The problem can be reproduced by writing the following code with the installed TimeAlarms library.
struct tm timeinfo;
if(!getLocalTime(&timeinfo)){
Serial.println("Failed to obtain time");
return;
}
It seems like this problem is not present in Linux as far I can see.
Board: ESP32 DevKit V4
Arduino IDE version: Platformio, PLATFORM: Espressif 32 (1.12.4) > DOIT ESP32 DEVKIT V1
Operating system & version: Windows 10
More than one Alarm ID
, but all of ID
are triggered even once of the ID
has disable
condition
Board ESP32 Dev Board
Shields / modules Not used
Arduino IDE version 1.8.12
Teensyduino version (if using Teensy)
Version info & package name (from Tools > Boards > Board Manager) ESP 32 Dev Module
Operating system & version Windows 7 64 Profesional
Any other software or hardware?
`// Questions? Ask them here:
// http://forum.arduino.cc/index.php?topic=66054.0
#include <TimeLib.h>
#include <TimeAlarms.h>
AlarmId id1;
AlarmId id2;
void setup() {
Serial.begin(9600);
while (!Serial) ; // wait for Arduino Serial Monitor
setTime(8,00,0,7,30,21); // set time to Saturday 8:29:00am Jan 1 2011
// create the alarms, to trigger at specific times
id2= Alarm.alarmRepeat(8,30,0, MorningAlarm); // 8:30am every day
// Alarm.alarmRepeat(17,45,0,EveningAlarm); // 5:45pm every day
// Alarm.alarmRepeat(dowSaturday,8,30,30,WeeklyAlarm); // 8:30:30 every Saturday
// create timers, to trigger relative to when they're created
Alarm.timerRepeat(15, Repeats); // timer for every 15 seconds
id1 = Alarm.timerRepeat(2, Repeats2); // timer for every 2 seconds
Alarm.timerOnce(10, OnceOnly); // called once after 10 seconds
AlarmId.disable(id1);
AlarmId.enable(id2);
}
void loop() {
digitalClockDisplay();
Alarm.delay(1000); // wait one second between clock display
}
// functions to be called when an alarm triggers:
void MorningAlarm() {
Serial.println("Alarm: - turn lights off");
}
void EveningAlarm() {
Serial.println("Alarm: - turn lights on");
}
void WeeklyAlarm() {
Serial.println("Alarm: - its Monday Morning");
}
void ExplicitAlarm() {
Serial.println("Alarm: - this triggers only at the given date and time");
}
void Repeats() {
Serial.println("15 second timer");
}
void Repeats2() {
Serial.println("2 second timer");
}
void OnceOnly() {
Serial.println("This timer only triggers once, stop the 2 second timer");
// use Alarm.free() to disable a timer and recycle its memory.
Alarm.free(id);
// optional, but safest to "forget" the ID after memory recycled
id = dtINVALID_ALARM_ID;
// you can also use Alarm.disable() to turn the timer off, but keep
// it in memory, to turn back on later with Alarm.enable().
}
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);
}`
Result Both AlarmId are Triggered
Thanks
I want to delete alarms on the fly.
I can create it, and disable it. But I want to do is delete it. There is a alarma limits, and i cant increase it because the RAM is not enough.
I saw createAlarms() but i dont know how to implement a delete function.
Thanks.
I tried to use Alarm.write() to store a value, but I couldn't retrieve it using Alarm.read() in the callback.
After debugging, I found that it's because the alarm is freed before the callback.
I used Alarm.alarmOnce() with a day of the week.
When changing the time in the Time library, TimeAlarms misses alarms.
The expected behavior is:
update() {
if(last_update_time < alarm_time < present_update_time) {
TriggerAlarmCallback();
}
}
..in other words, every instance of the time passing through a recurring alarm should result in the alarm firing.
You can demonstrate this bug by
A more practical example of this bug is if the time is set to 7:00PM and you run the clock back to 7:00AM, the alarm will not trigger. This is highly likely to cause alarms (possibly for the whole day) to be missed, and is something a user of an alarm clock might do.
Workaround:
Update the alarm each instance of updating the time:
void saveTimeCurrentTime(uint8_t setHour, uint8_t setMinute) {
setTime(setHour, setMinute, 0, day(), month(), year());
Alarm.write(gAlarmID1, AlarmHMS(gTime1.hours, gTime1.minutes, 0));
}
Where gTime1
struct holds the hour and minute of the alarm as a global variable.
Hi! is my syntax for ExplicittimeAlarm on time_t for Oct. 10. 2017 22:01:00 correct?
Code:
// create the alarms, to trigger at specific times
Alarm.alarmRepeat(7,0,0, MorningAlarm); // 8:30am every day
Alarm.alarmRepeat(22,0,0,EveningAlarm); // 5:45pm every day
Alarm.alarmRepeat(dowWednesday,20,30,0,WeeklyAlarm); // 18:30:00 every Saturday
Alarm.alarmOnce(0,1,22,10,10,17,ExplicitAlarm); // time_t for Oct. 10. 2017 22:01:00
Explicit code won't work in my project...
If I initiate more than 6 Alarm.timerOnce timers they will be ignored.
Is this an error or is this just the maximum amount of timers I can set?
Just wondering if it would be possible to use this with an RTC library instead of the time library.
at the moment my time is obtained by rtc.now();
I could set the internal time of the arduino using the RTC but wonder if there is a way to use this directly instead of doing this?
alarmOnce and presumably alarmRepeat where HMS is given does not fire at midnight.
set alarmOnce(0,0,0,myHandler);
This will not fire. It's easy to see why and if I get a chance I'll update .h and do a pull request. Certain functions, most notably
AlarmID_t alarmRepeat(const timeDayOfWeek_t DOW, const int H, const int M, const int S, OnTick_t onTickHandler)
and
AlarmID_t alarmOnce(const timeDayOfWeek_t DOW, const int H, const int M, const int S, OnTick_t onTickHandler)
and
AlarmID_t alarmOnce(const int H, const int M, const int S, OnTick_t onTickHandler)
all call AlarmHMS() and then call their time_t variant with the result. The time_t variant does this check
if (value <= 0) return invalid alarm.
Passing in midnight, 0,0,0, gives a value of 0 which is perfectly ok. This needs to be changed to < 0, not <=.
Thanks.
Looks like a great library but I get these errors as soon as I include it for my esp8266 project:Any work arounds? arduino 1.67, wemos mini esp8266, Time v1.5.0, TimeAlarms v1.4.0
In file included from sketch\ProgTimer.cpp:3:0:
C:\Users\tim\Documents\electronics\arduino\libraries\TimeAlarms/TimeAlarms.h:71:31: error: 'timeDayOfWeek_t' does not name a type
AlarmID_t alarmRepeat(const timeDayOfWeek_t DOW, const int H, const int M, const int S, OnTick_t onTickHandler); // as above, with day of week
^
C:\Users\tim\Documents\electronics\arduino\libraries\TimeAlarms/TimeAlarms.h:71:47: error: ISO C++ forbids declaration of 'DOW' with no type [-fpermissive]
AlarmID_t alarmRepeat(const timeDayOfWeek_t DOW, const int H, const int M, const int S, OnTick_t onTickHandler); // as above, with day of week
^
C:\Users\tim\Documents\electronics\arduino\libraries\TimeAlarms/TimeAlarms.h:75:29: error: 'timeDayOfWeek_t' does not name a type
AlarmID_t alarmOnce(const timeDayOfWeek_t DOW, const int H, const int M, const int S, OnTick_t onTickHandler); // as above, with day of week
^
C:\Users\tim\Documents\electronics\arduino\libraries\TimeAlarms/TimeAlarms.h:75:45: error: ISO C++ forbids declaration of 'DOW' with no type [-fpermissive]
AlarmID_t alarmOnce(const timeDayOfWeek_t DOW, const int H, const int M, const int S, OnTick_t onTickHandler); // as above, with day of week
^
exit status 1
Both AlarmClass::updateNextTrigger() and TimeAlarmsClass::enable() methods, upon receiving a request with an alarm value of 0 automatically disable said alarm. For both a daily alarm set to 00:00:00 and a weekly alarm set to Sunday 00:00:00, the value of 'value' will be 0, and thus be immediately disabled.
Just allowing a value of 0 will cause an issue with method TimeAlarmsClass::read() as it uses dtINVALID_TIME, defined as 0, to report an error reading the 'value' property from an unallocated alarm.
Hello, my arduino communicates with an MQTT server.
Can i set an alarm on the fly ?
For example morning alarm should be changed if the server tells my arduino that.
PS: The alarm is predefined at the beginning.
Thanks.
Due to a complex interaction of multiple functions, the code in write() does not end up properly setting nextTrigger to update the alarm to the desired time.
A full description of what is going on can be found here:
http://forum.arduino.cc/index.php?topic=66054.msg2731860#msg2731860
The solution is very simple and requires the addition of a single line.
While the code is in the thread above I'll reproduce it here.
change write() from this:
// write the given value to the given alarm
void TimeAlarmsClass::write(AlarmID_t ID, time_t value)
{
if(isAllocated(ID))
{
Alarm[ID].value = value;
enable(ID); // update trigger time
}
}```
to this:
// write the given value to the given alarm
void TimeAlarmsClass::write(AlarmID_t ID, time_t value)
{
if(isAllocated(ID))
{
Alarm[ID].value = value;
Alarm[ID].nextTrigger = 0; // clear out previous trigger time
enable(ID); // update trigger time
}
}
BTW, unrelated, but the leading indention in TimeAlarms.cpp is messed up starting at line 139:
AlarmID_t TimeAlarmsClass::alarmRepeat(time_t value, OnTick_t onTickHandler){ // trigger daily at the given time
Somebody somehow, probably accidentally, moved all the lines below this point over a bit.
This update would be a good excuse to fix that as well.
It is a pretty simple update, but if you prefer, I could create a pull request.
I'd assume that to make it complete, I'd update write(), fix the indention, and bump the revision number in library.properties
Tried to set two alarms on the same weekday with Alarm.alarmRepeat, but only the fist one fires.
Hello! I am Prithul, from Bangladesh. I have 2 questions-
How can I make the program so that the time library automatically gets the time from my computer?
I am making a project which will turn on a light at a fixed time. It will have an LCD and some buttons. I wanna set the alarm time by pressing the buttons (for example - pressing a button will increase the hour by 1) But my question is how can I change the alarms time once it has been set?
How can I modify an existing alarm? I mean, if I set an alarm with Alarm.alarmRepeat(); and after I want to change it, what should I do? Should I use write(ID, value)? If yes, what can I write in "value" field?
I'm using this library with ESP8266 and RTC Module DS3231.
#include <ESP8266WiFi.h>
#include <Wire.h>
#include <TimeLib.h>
#include <TimeAlarms.h>
#include <RTClib.h>
AlarmId id;
RTC_DS3231 rtc;
void setup()
{
DateTime now = rtc.now();
setTime(now.hour(),now.minute(),now.second(),now.day(),now.month(),now.year()); // set time
//time_t t = now.unixtime(); // tried both method of setting time.
//setTime(t);
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (1);
}
id = Alarm.alarmRepeat(16, 02, 0, MorningAlarm);
pinMode(2, OUTPUT);
digitalWrite(2, LOW);
}
void MorningAlarm() {
Serial.printf("Alarm Running..!");
digitalWrite(2, HIGH);
}
void loop() {
}
What could be the issue.?
I thinks that must be either prominently mentioned in README or got fixed.
This code doesn't work as expected:
#include <Time.h>
#include <TimeAlarms.h>
void setup() {
Serial.begin(9600);
Alarm.alarmRepeat(8,29,30, MorningAlarm);
setTime(8,29,25,1,1,11);
}
void test(){
Serial.println("test");
}
void loop(){
Alarm.delay(1000);
}
This code also doesn't work:
#include <Time.h>
#include <TimeAlarms.h>
AlarmID_t alarm1;
void setup() {
Serial.begin(9600);
alarm1 = Alarm.alarmRepeat(8,29,30, MorningAlarm);
setTime(8,29,25,1,1,11);
Alarm.enable(alarm1);
}
void test(){
Serial.println("test");
}
void loop(){
Alarm.delay(1000);
}
But this one works!:
#include <Time.h>
#include <TimeAlarms.h>
AlarmID_t alarm1;
void setup() {
Serial.begin(9600);
setTime(8,29,25,1,1,11);
alarm1 = Alarm.alarmRepeat(8,29,30, MorningAlarm);
}
void test(){
Serial.println("test");
}
void loop(){
Alarm.delay(1000);
}
Just spend a good hour trying to get things working.
Adding to PlatformIO dies not work, as obviously the versioning is broken.
PlatformIO tries to install with version number: paulstoffregen/[email protected]+sha.c291c1ddad
Trying to use #include <TimeAlarms.h> in code doe not work.
Install using PlatformIO
Board: ESP32
Arduino IDE version; arduinoespressif32 @ 3.20004.220825 (2.0.4)
This brings me to my questions:
Is there a simple call to free up the ids & memory and end all the alarms? I can see that the TimeAlarmsClass constructor does just that. Not sure how to call it though.
(so I forked the repo and copied the constructor as void TimeAlarmsClass::clear()
and now whenever the the client app wants to reschedule all the alarms I call that first. Otherwise the alarms that never got triggered just took up space and accumulated)
Hi,
once I issue an Alarm, for example:
Alarm.timerOnce(3600, BathReset)
how can I later disable or cancel this Alarm?
It seems like this command merely returns a true/false regarding whether the Alarm was created or not.
Looking through the code, I don't know how to get the ID, nor how to declare the variable that the ID can be contained in for future action on it.
Thanks for your help!
TimeAlarms gives following exception when using along with EEPROM or SPIFFS.
Soft WDT reset
ctx: sys
sp:
Exception (
ets Jan 8 2013,rst cause:4, boot mode:(1,6)
wdt reset
Board : GENERIC ESP8266
Shields / modules used: NODEMCU
Arduino IDE version : 1.6.5
Version info & package name : 2.4.2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.