Erriez / ErriezDS1302

Erriez 3-wire DS1302 Real Time Clock library for Arduino

Home Page:https://github.com/Erriez/ErriezArduinoLibraries

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RAM Test Failed also RTC.read() returning error

yoshuaaadk opened this issue · comments

Hello, i've been trying to get ESP32 to communicate with DS1302 with many libraries for my project to add scheduling feature to my pzem004t, but nothing seems work. With this library when i try to run ErriezDS1302RAM it result on the image attached. Honestly im confused to use this RTC module.
Since i'm using ESP32 30pinouts, this is my wiring (there is no pin 0):
#define DS1302_CLK_PIN 2
#define DS1302_IO_PIN 4
#define DS1302_CE_PIN 5

Then i tried to run ErriezDS1302WriteRead, it can go through setup() until loop(), but it returns "RTC read failed".

Any idea / answer to get this ESP32 work fine with DS1302? Thankyou so much..
DS1302ERR

@yoshuaaadk Thanks for using my library. I've tested the ErriezDS1302RAM example on an UNO and ESP32-WROOM board on master (tag 2.0.0) today and both works. Also tested with the clock pin on GPIO2.

There are also known fake DS1302 chips which do not work correctly on 3.3V. The RAM example works without a battery. I had one RTC on a PCB with a defect crystal, but I do not remember if this is required when accessing RAM.

Your output seems to be related to no power or a wiring problem. Some boards uses different pin numbering. It is recommended to:

  1. Is the chip mounted in the correct direction? (check pin 1)
  2. Measure the power on the DS1302 chip
  3. Toggle the CLK / IO and CE pins individually and measure if these pins respond as expected.

Success!

Thankyou for your response. I also have try this DS1302 with arduino Uno using this library, and it runs fine with default pins that you gave.
#define DS1302_CLK_PIN 2
#define DS1302_IO_PIN 3
#define DS1302_CE_PIN 4
Now i try to toggle the Pins of CLK /IO and CE and gave me conclusion that if either CLK / IO is disconnect to board, it will return "RTC not found", but when i disconnect the CE it still detect DS1302 but cannot execute the RTC.read() function and return "RTC read failed". I think in the case of my ESP32 that the pin of CE is not defined and attached correctly on the same Pins. I will try one by one which one is the correct PINS on ESP32 if i declare like this:
#define DS1302_CLK_PIN 2
#define DS1302_IO_PIN 4
#define DS1302_CE_PIN 5
The power seems fine, because i attached the RTC power source to my Arduino Uno with 5V.
Once more thankyou for your response!

Now it works fine, thankyou for your advice!
It because the wiring of ESP32, i have to connect another ground wire from ESP32 to my Power source (Arduino Uno) instead using the default USB power ground.
I want to ask you, once i write initial Time to RTC, it will automatically ticking by itself right? If i want to build ESP32 relay scheduler works with and without WiFi, is it better to set the time everytime ESP32 turn on by re-setting the time when it connect to WiFi from NTP, or just set it once and let it ticking?
And is there any ways to change the format of time inside "cpp" or "h" files?
Thankyou so much!!! This library saved my project.

Good to hear that you found an issue with the wiring.

Function clockEnable() should be called once after first power-on without a battery attached. (See examples). Then the clock remains ticking when a battery is connected and main power (3.3V or 5V) is removed.

Time deviations may be visible within weeks, but depends on the XTAL and is different per RTC. I use the DS1302 to control an lake pump which is less critical and needs to be reprogrammed every half year (summer/winter time). This accuracy is sufficient. For higher accuracy, a DS3231 is recommended, but probably not necessary for you. Reprogramming the RTC once a day or week via NTP is probably sufficient.

Timeformat can be changed with standard C time functions by including <time.h>. time_t getEpoch(); maybe helpful.

Success!