Read Passing Second from RTC

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
User avatar
AbhijitR
Posts: 299
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 280 times
Been thanked: 79 times
Contact:

Read Passing Second from RTC

Post by AbhijitR »

Hello!

I am trying to save some readings after every 1 second, i am using DS3231 RTC for time keeping, i tried to do something similar from below post of Ben, but unfortunately it is not working as expected.

viewtopic.php?p=98927#p98927

I want to note and add the reading on every passing second, then after finishing 60 sec or 1 min i want to divide the reading by 60 to find the average for that minute and then store in SD, i am able to do the math and store too but what i notice is the time delay of 60 sec to do the math is increasing by few sec after every 1 minute, i think i am not catching each passing sec correctly from the RTC.

IS there any other way to catch the second from RTC correctly.

Thank you.

Abhi

mnf
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Read Passing Second from RTC

Post by mnf »

Hi Abhi,

The RTC can generate a 1s pulse - use this to generate an interrupt - and take a reading then.

Martin

User avatar
AbhijitR
Posts: 299
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 280 times
Been thanked: 79 times
Contact:

Re: Read Passing Second from RTC

Post by AbhijitR »

Hi! Martin
good afternoon

Thank you to share your views, may i request you to share some example if possible, or may be a link to some post, unfortunately i did not find any on that topic. I have observed one more thing with my RTC module, apart from Vcc, Gnd, SDA, SCK there is no other pin available to collect the signal or pulse.

Abhi

mnf
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Read Passing Second from RTC

Post by mnf »

Hi Abhi,

A simple example - I used an Arduino Nano (and then I can plug my RTC module in on pin A2-A7 and power the RTC using A2 and A3 - you can remove the setup (output to A2 and A3) if you use a different power mode).

Note - I used the Ds3231 component from viewtopic.php?f=80&t=22188&hilit=ds3231+revisited - but the same principle applies if you use the FC component.

The MCU is 'slept' - and woken by the 1s interrupt - connect the sqw output pin on RTC to d2 (it's SQW on my board - if there are only 4 pins then maybe there is no SQW out available with your board!). SQW is pin 3 on the DS3231 chip and it needs a pullup resistor to Vcc (see https://www.digikey.co.uk/en/datasheets ... 31-ds3231s) I'd be tempted to try connecting it to D2 and using the Arduino internal pullup :-)

Here it just outputs the time and the 1s counter counting the interrupts (which runs 0..255 as I used a byte and don't roll it into minutes)
timer.fcfx
(13.88 KiB) Downloaded 113 times
Martin

User avatar
AbhijitR
Posts: 299
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 280 times
Been thanked: 79 times
Contact:

Re: Read Passing Second from RTC

Post by AbhijitR »

Hello! Martin

Humbly thank you for your valuable input, your suggestion worked like a "Piece of Cake".

As you instructed i manage to take the pin 3 of the chip to one of the interrupt pin on my chip, the RTC was already powered, i configured the SQWandINTcontrol Macro at the beginning of the main loop and done, i can see the LED placed in the INT macro flashing every sec, i had a very big smile on my face, :D like that.

Thank you once again for your quick reply.

Abhi

mnf
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Read Passing Second from RTC

Post by mnf »

Glad to hear it worked - especially with the connection to the chip being necessary - I'm not sure my soldering skills would cope with that!

Martin

User avatar
AbhijitR
Posts: 299
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 280 times
Been thanked: 79 times
Contact:

Re: Read Passing Second from RTC

Post by AbhijitR »

Hi! Martin

Not only the LED blink every second my calculation box now calculate the average exactly after 1 minute without fail.

And regarding the soldering to the pin 3, it was not a big trouble.

Cheers Martin, have a pleasant evening.

Abhi
Attachments
20211003_182346.jpg
20211003_182346.jpg (58.18 KiB) Viewed 2424 times

Post Reply