Timed events at specific time?

The example sketch i did find for the rtc didn't have any real clarification on how to call time by hour and minute, only get full string of time and date.

#include "I2C_BM8563.h"

// RTC BM8563 I2C port

// I2C pin definition for M5Stick & M5Stick Plus & M5Stack Core2
#define BM8563_I2C_SDA 21
#define BM8563_I2C_SCL 22

// I2C pin definition for M5Stack TimerCam
// #define BM8563_I2C_SDA 12
// #define BM8563_I2C_SCL 14

I2C_BM8563 rtc(I2C_BM8563_DEFAULT_ADDRESS, Wire1);

void setup() {
  // Init Serial
  Serial.begin(115200);
  delay(50);

  // Init I2C
  Wire1.begin(BM8563_I2C_SDA, BM8563_I2C_SCL);

  // Init RTC
  rtc.begin();
}

void loop() {
  I2C_BM8563_DateTypeDef dateStruct;
  I2C_BM8563_TimeTypeDef timeStruct;

  // Get RTC
  rtc.getDate(&dateStruct);
  rtc.getTime(&timeStruct);

  // Print RTC
  Serial.printf("%04d/%02d/%02d %02d:%02d:%02d\n",
                dateStruct.year,
                dateStruct.month,
                dateStruct.date,
                timeStruct.hours,
                timeStruct.minutes,
                timeStruct.seconds
               );

  // Wait
  delay(1000);

Thats the only thing coming close to get time. Nothing showing how to use time in an if statement

Man, you are confused. read your own log file! Don't you think it is working? If the audio doesn't play, test the audio!

Yes IT IS WORKING partly. did you miss the message about the file being opened repeatedly over and over again
the audio works now, however the file never gets a chance to play because its being opened so many times the buffer is full.

How do you know that? Also you never answered my question about commenting out main().

Because I watched the log and had it throwing an error every ms let me see if I can get It to repeat the problem hang on and I know the audio works because all other alerts are playing

Ddi you not see my comment I removed main and put it in loop

That would never compile, so it's not what you did. Also if you made that change and didn't post it, the code you posted is useless for troubleshooting...

What "other" alerts?

The log shows its playing multiple times and then the buffers/file descriptors are overloaded.

> Executing task: C:\Users\Administrator.MYTDS\.platformio\penv\Scripts\platformio.exe device monitor <

--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at http://bit.ly/pio-monitor-filters
--- Miniterm on COM6  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jul 29 2019 12:21:46

rst:0x1 (POWERON_RESET),boot:0x17 (Srv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:10124
load:0x40080400,len:5828
entry 0x400806a8
��M5Core2 initializing...axp: vbus limit off
axp: gpio1 init
axp: gpio2 init
axp: rtc battery charging enabled
axp: esp32 power voltage was set to 3.35v
axp: lcd backlight voltage was set to 2.80v
axp: lcd logic and sdcard voltage preset to 3.3v
axp: vibrator voltage preset to 2v
touch: FT6336 ready (fw id 0x10 rel 1, lib 0x300E)
OK
E ␀M5Stack CORE2 code starting
Free Heap: 236304
SD Card Type: SDHC
SD Card Size: 15193 MB
Ini file exists
section 'config' has an entry 'nightscout' with value 
section 'config' has an entry 'token' with value
bootpic =
name = dev_unit
device_name = pampers
time_zone = -18000
dst = 0
show_mgdl = 1
sgv_only = 0
default_page = 0
restart_at_time = 03:30
restart_at_logged_errors = 0
show_current_time = 1
show_COB_IOB = 0
snooze_timeout = 30
alarm_repeat = 3
dev_mode = 0
yellow_low = 4.50
yellow_high = 9.00
red_low = 3.89
red_high = 11.00
snd_warning = 3.72
snd_alarm = 3.00
snd_warning_high = 14.00
snd_alarm_high = 20.00
snd_no_readings = 20
snd_loop_error = 1
snd_warning_at_startup = 1
snd_alarm_at_startup = 0
NO warning_music
warning_volume = 100
NO alarm_music
alarm_volume = 100
LED_strip_mode = 0
LED_strip_pin = 25
LED_strip_count = 10
LED_strip_brightness = 2
vibration_mode = 0
vibration_pin = 26
vibration_strength = 512
micro_dot_pHAT = 0
info_line = 1
brightness1 = 50
brightness2 = 100
brightness3 = 10
date_format = 0
time_format = 0
NO invert_display defined = -1
display_rotation = 1
temperature_unit = 1
disable_web_server = 0

No invert_display defined in INI.
/wav/warningsound.wav
volumeGain:0.39
WiFi connect start

Wait for WiFi... .
WiFi connected to SSID EmpireXerxes
IP address: 10.0.0.229
Waiting for time.
Tuesday, October 12 2021 13:50:53
Connection done
MDNS responder started OK.
is_https_Heroku 0
JSON query NSurl = 'https://api/v1/entries.json'
http.begin OK
Returning with error -1 after 25 ms :-(
connection refused
Battery 4.17 V = 100%
Local time: 13:50:57 DST 0
Sensor time difference = 1634064657 sec
Glyk:  0.0
Last 10 values: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 
Alarm time difference = 1634064657 sec
Snooze time remaining = 0 sec, Snooze until 0
WARNING NO READINGS
/wav/warningsound.wav
volumeGain:0.39
1
2615
Battery 4.17 V = 100%
Local time: 13:51:24 DST 0
Sensor time difference = 1634064684 sec
Glyk:  0.0
Last 10 values: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 
Alarm time difference = 27 sec
Snooze time remaining = 0 sec, Snooze until 0
WARNING NO READINGS
Battery 4.17 V = 100%
Local time: 13:51:39 DST 0
Sensor time difference = 1634064699 sec
Glyk:  0.0
Last 10 values: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 
Alarm time difference = 42 sec
Snooze time remaining = 0 sec, Snooze until 0
WARNING NO READINGS
Battery 4.17 V = 100%
Local time: 13:51:54 DST 0
Sensor time difference = 1634064714 sec
Glyk:  0.0
Last 10 values: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 
Alarm time difference = 57 sec
Snooze time remaining = 0 sec, Snooze until 0
WARNING NO READINGS
is_https_Heroku 0
JSON query NSurl = 'https://api/v1/entries.json'
http.begin OK
Returning with error -1 after 29 ms :-(
connection refused
Battery 4.17 V = 100%
Local time: 13:52:9 DST 0
Sensor time difference = 1634064729 sec
Glyk:  0.0
Last 10 values: 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 
Alarm time difference = 73 sec
Snooze time remaining = 0 sec, Snooze until 0
WARNING NO READINGS
/wav/warningsound.wav
volumeGain:3.51
/wav/warningsound.wav
volumeGain:3.51
/wav/warningsound.wav
volumeGain:3.51
/wav/warningsound.wav
volumeGain:3.51
/wav/warningsound.wav
volumeGain:3.51
E (108485) vfs_fat: open: no free file descriptors
/wav/warningsound.wav
volumeGain:3.51
AudioGeneratorWAV::begin: file not open
E (108557) vfs_fat: open: no free file descriptors
/wav/warningsound.wav
volumeGain:3.51
AudioGeneratorWAV::begin: file not open
E (108628) vfs_fat: open: no free file descriptors
/wav/warningsound.wav
volumeGain:3.51
AudioGeneratorWAV::begin: file not open
E (108699) vfs_fat: open: no free file descriptors
/wav/warningsound.wav
volumeGain:3.51
AudioGeneratorWAV::begin: file not open
E (108770) vfs_fat: open: no free file descriptors
/wav/warningsound.wav
volumeGain:3.51
AudioGeneratorWAV::begin: file not open
E (108842) vfs_fat: open: no free file descriptors
/wav/warningsound.wav
volumeGain:3.51
AudioGeneratorWAV::begin: file not open
E (108914) vfs_fat: open: no free file descriptors
/wav/warningsound.wav
volumeGain:3.51
AudioGeneratorWAV::begin: file not open
E (108986) vfs_fat: open: no free file descriptors
/wav/warningsound.wav
volumeGain:3.51
AudioGeneratorWAV::begin: file not open

Inside my project! No point in using the small sketch it works there.

You forgot to repost your updated, latest code as I requested.

Did not see that my apologiesbg1248.ino (113.8 KB)
,

How come you know better than me what I did? Why have to have an attitude toward someone,, what have i done to you?

Okay, I was reading your code until you posted that. Bye! I know because what you said you did, would result in compile errors. My attitude is that I need certain things to help people, if they are not forthcoming with details I try to convince them to supply them, before moving on...

I can prove it composed no build errors at all. And I wanst trying to be rude saying that, I simply felt like you were upset with me or something and i wanted to address it if you had an attitude with me why, was it something i did? Am I wasting your time? sorry im not that versed in knowledge

Whether you have wasted my time or not, depends on whether other people will gain some insight, now that they at least have an updated, current sketch.

1 Like

It has to be something in my code messing it up, I ran a blank minimal project and it did exactly like it should. I went back tested again on my project, and it worked, kinda....i set it for 1pm, it completed the action at 106, tried again for 120 completed at 123, so im not sure whats happening.