Naguissa / uRTCLib

Really tiny library to basic RTC functionality on Arduino. DS1307, DS3231 and DS3232 RTCs are supported.
https://www.foroelectro.net/librerias-arduino-ide-f29/rtclib-arduino-libreria-simple-y-eficaz-para-rtc-y-t95.html
GNU Lesser General Public License v3.0
87 stars 24 forks source link

Why is SQW connected to RST, instead of the more usual pin 2? #33

Closed samuelwhiskeyjohnson closed 5 months ago

samuelwhiskeyjohnson commented 5 months ago

Just curious, for setting up the alarm, why is SQW connected to RST, instead of the more usual pin 2 as interrupt pin?

Naguissa commented 5 months ago

It's also possible. Done this way in order to simplify the example, as it runs on 3 types of MCUs with different capabilities.

samuelwhiskeyjohnson commented 5 months ago

Thanks for your reply

  1. Are you saying I can use the deep sleep example by simply connecting to the pin 2? or is it hard coded in your library that users can ONLY use the RST pin? uRTCLib_deepsleep.ino

  2. Do I still need the10uF capacitor if I use pin 2? Or why use capacitor at all for RST pin too? I'm just curious because I've seen other RTC libraries just connect pin 2 to RTC directly without the capacitor.

Naguissa commented 5 months ago

You can test it on Arduino using LowPower library: https://github.com/arduino-libraries/ArduinoLowPower/blob/master/examples/ExternalWakeup/ExternalWakeup.ino

In this case you will probably not need the capacitor. The capacitor is used to 'release' RST pin, as MCU doesn't restart until released.

Naguissa commented 5 months ago

Also, if you want to use alarm again, remember to use alarmClearFlag() : https://naguissa.github.io/uRTCLib_doc_and_extras/classuRTCLib.html#a1832bbb5322fbe2895c14132e559e03a

samuelwhiskeyjohnson commented 5 months ago

Hi thanks again for reply.

  1. What do you mean by "The capacitor is used to 'release' RST pin, as MCU doesn't restart until released"? At least for Arduino uno you don't need to release the RST pin? As long you send low signal for more than 2 micro seconds it restarts the Arduino.

  2. Does the rtc.alarmSet() send a pulse of low signal or toggles to low signal? I thought it toggles to low signal hence why you need alarmClearFlag() to toggle back to high.

Naguissa commented 5 months ago

Hello again!

I reply in inverse order, as it's more logical: