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
88 stars 24 forks source link

Trying to use alarm to wake up from sleep. But when RST pin is connected I get AVRdude upload error. #39

Closed samuelwhiskeyjohnson closed 6 months ago

samuelwhiskeyjohnson commented 7 months ago

Using arduino UNO I'm getting this error when I connect SQW pin on RTC (with capacitor in between like you instructed in https://raw.githubusercontent.com/Naguissa/uRTCLib_doc_and_extras/master/imgs/deepsleep_connection.png) with RESET pin on Arduino.

avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
...
Failed uploading: uploading error: exit status 1

Basically the issue comes down to when RST pin is either held high or held low, it creates this error. The issue gets fixed when RST pin is not connected to anything.

Any idea on how to fix?

Naguissa commented 7 months ago

In short, remove capacitor and RTC from RESET pin while programming.

Detailed explanation: When programming MCU, 1st step is reset MCU and thanks to its bootloader, connect it in programming mode. As you have a capacitor and the RTC connected to the MCU, they are interfering with typical process and fooling the MCU and the programmer. Disconnecting them to program the MCU you'll solve the problem.

Naguissa commented 7 months ago

P.S.: I don't know your MCU, but a lot of them can operate with wake-up pin interrupts. Using RESET to do so is the most compatible way, but if your MCU supports it maybe using a pin-interrupt is way more beneficial....

samuelwhiskeyjohnson commented 6 months ago

It worked! I used pin 2 as interrupt pin and attachInterrupt().

Do you still need capacitor between SQW pin on RTC and pin 2 (interrupt pin) on Arduino?

Naguissa commented 6 months ago

Perfect!

Using any other pin than RST does not need any capacitor.