How to do something on concrete time...

Hi there,
I use arduino UNO to measure Temp / Hum (with SHT11),
also I use RTC/SD card for Real time clock and SD card storage,
I read sensor every 10 seconds and write data on SD card in format: date, time, temp, hum
this work ok,
The question is:
can somebody share with me idea how to read sensor on concrete time,
for example, I need to read sensor exactly on several concrete times per day (hours:minutes) according RTC :
10:15 oclock, read sensor,
13:45 oclock, read sensor...
thanks in advance
best regards

Depends on what libs you’re using.
E.g.
if (tm.hour == 10 && tm.minute == 15)

What?

EXACTLY is not a thing in science really.

You need to give us an idea of the timing precision you need these sensors to acquire data...

If a sensor is 100 milliseconds off taking a reading, will this suffice?
Must it be within 0.1 nano seconds?
Is a minute off alright?

You already seem to understand an RTC gives "real time" that has a good precision (a few parts per million).

You can continually poll the RTC till you hit the time you need to read the sensors...

You'll probably need a delay or you'll need to set a "flag" so that you don't loop and save thousands of readings between 10:15 and 10:16.

You should be OK with a 1 minute "window", but normally, you don't look for an exact time (or any exact "analog" value) because you might miss it. So typically, if you wanted to trigger an alarm clock at 7:00AM, you look for something like 7:00AM or later. (Greater than or equal to.)

Or, with analog you can look for a range so if you are looking for 1 Volt, you might look for anything between 0.90V and 1.10V, etc., depending on the application.

Just FMI.... What is 'concrete time' ?

lastchancename:
Just FMI.... What is 'concrete time' ?

I think it is slang, like 'on the nose' or 'on the money'

if flag is not set
if time >= 7:00:00:00:00
set flag that you are reading
read your thing
write to SD card.

increment your time to look for 8:00:00:00:00

it may take the reading at 7:00:47:22
and write at 7:01:02

if you want to take your readings as close to 7:00:00:00 as possible, start reading at 6:59:00
and at >= 7:00:00:00
stop reading and store the data as close to that number as you want.
record the time of the reading, not the time you stored.

re-read post #2
if you are trying to see where your car is, on a road while drivnig at 25 MPH, that is one thing, but if you need to know who crossed the line at 415 MPH on a drag race, you need to do a bit more on your timing.

pasicr:
Hi there,
I use arduino UNO to measure Temp / Hum (with SHT11),
also I use RTC/SD card for Real time clock and SD card storage,
I read sensor every 10 seconds and write data on SD card in format: date, time, temp, hum
this work ok,
The question is:
can somebody share with me idea how to read sensor on concrete time,
for example, I need to read sensor exactly on several concrete times per day (hours:minutes) according RTC :
10:15 oclock, read sensor,
13:45 oclock, read sensor…
best regards

I’d like to suggest this:
define the certain times, i.e. as an array of integers, with hours being hundreds, such like (perhaps):
int certainTimes={1015, 1345,1715};

Then write a loop function which checks for the current minute (from RTC) has a change.
When a change of the current minute is detected,simply loop throuth the certainTimes array and check if the RTC has just reached one of the certain times which will require some action to happen.

jurs:
I’d like to suggest this:
define the certain times, i.e. as an array of integers, with hours being hundreds, such like (perhaps):
int certainTimes={1015, 1345,1715};

Then write a loop function which checks for the current minute (from RTC) has a change.
When a change of the current minute is detected,simply loop throuth the certainTimes array and check if the RTC has just reached one of the certain times which will require some action to happen.

building on this, a bit of bit manipulation would be useful maybe.

32 bit unsigned long:

0-23:0-59:0-59 requires (24:60:60) = 5:6:6 = 17 bits.

Or if only needing minutes and hours:

0-23:0-59 = 5:6 = 11 bits

So an int of the time HH:MM could be as such:

PSUEDO

unsigned int int_time = get_RTC_Hours();
int_time = int_time << 6;
int_time+=get_RTC_minutes()

For example, if the time was 13:28

13 = B 00001101
28 = B 00011100

int_time = B 0000000000000000

So firstly set int_time to the number of hours…

int_time = get_RTC_hours()

which will make int_time = B 0000000000001101

Then shift it left 6 bits to make room for the minutes value:

int_time = int_time << 6;

Leaving:
int_time B 0000000000001101 (hours in binary)
int_time << 6 = B 0000001101000000 (hours in binary shifted left 6 bits)

then simply adding the number of minutes (will be 6 bits maximum…59 is B111011)

28 = 11100

int_time = int_time << 6 = B 0000001101000000 (hours in binary shifted left 6 bits)#
int_time + minutes (28) = B 0000001101111000

13:28 in DEC with this protocol = 888

Should be a bit “quicker” than like splitting numbers and such with DEC to BIN conversion and all sorts?

Thanks colleagues for useful info,
I will try like Johnny010 advice,
according "concrete time" or "exactly time" words...
is it not critical, if I try to read sensor at 13:58 is not problem if the real time is +/- a minute...
regards