I have been trying to attach a DS1307 RTC to my ZUNO, for use in a rainfall accumulation sketch I'm trying to develop.
I bought a new DS1307 shield and tested it with an Arduino UNO - it runs perfectly.
I've configured my ZUNO as ME Z-Uno2 Beta, and I'm running the example sketch Ds1307Rtc without modification. I have the SDA attached to pin 10 and the SCL to pin 9; the SD1307 is powered from the ZUNO board 5VDC & GND as usual.
On the serial monitor I see the following:
Ds 1307 Rdc Example
The DS1307 is stopped.
Error: cannot read
Now, there have been no modifications to the DS1307; the only changes I made was to remove the connection to the UNO and connect to the ZUNO as above. I tried removing the battery from the DS1307 for 30 seconds, reinstalling it, and reuploading the sketch. Same result. It appears that the ZUNO is simply not reading the DS1307 correctly.
I don't understand what this line does in the example sketch:
7. #define EEPROM_STRING "D8B2DB76-C6CC-41E6-B7AB-A1F365824ABF"
Could this be incorrect for this device? Any other suggestions? I'm stumped!
ZUNO cannot talk to DS1307
-
- Posts: 22
- Joined: 07 Aug 2022 21:54
Re: ZUNO cannot talk to DS1307
Note that the example sketch I am trying to run (Ds1307Rtc) came directly from the "Examples" folder when I specified the board as
"Z-Wave>ME Z-Uno2 Beta". I made no modifications to it at all.
"Z-Wave>ME Z-Uno2 Beta". I made no modifications to it at all.
Re: ZUNO cannot talk to DS1307
Hello.
Perhaps it would be clearer like this:
I checked this example definitely works for me, maybe we have different versions of RTC ...
Try it without EPROM:
Allows you to check if the current time is set or not.I don't understand what this line does in the example sketch:
7. #define EEPROM_STRING "D8B2DB76-C6CC-41E6-B7AB-A1F365824ABF"
Perhaps it would be clearer like this:
Code: Select all
#define EEPROM_STRING __TIMESTAMP__
Try it without EPROM:
Code: Select all
#include "Ds1307Rtc.h"
#include "Custom_timestamp.h"
#define MY_SERIAL Serial
Ds1307RtcClass rtc = Ds1307RtcClass();
static const char *monthNames[] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
static const char *dayNames[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
void setup(void) {
if (zunoIsValidDate() == false)
zunoSetTimeStamp(ZUNO_SKETCH_BUILD_TS + 1 + (3 * 60 * 60));//+ (3 * 60 * 60) sec - Mck; + 1 sec - build and load
MY_SERIAL.begin(115200);
MY_SERIAL.print("\n");
MY_SERIAL.println("Ds 1307 Rtc Example");
if (rtc.begin(9, 10) != true) {
MY_SERIAL.print("Error: cannot initilzed device\n");
while (0xFF)
delay(0x10);
}
if (rtc.isRunning() == true) {
MY_SERIAL.print("The DS1307 is runnig.\n");
}
else {
MY_SERIAL.print("The DS1307 is stopped.\n");
}
if (rtc.set(zunoGetTimeStamp()) != true) {
MY_SERIAL.print("Error: cannot set\n");
while (0xFF)
delay(0x10);
}
}
void loop(void) {
struct tm timeinfo;
if (rtc.get(&timeinfo) != true) {
MY_SERIAL.print("Error: cannot get\n");
while (0xFF)
delay(0x10);
}
if ((size_t)timeinfo.tm_mon >= (sizeof(monthNames) / sizeof(monthNames[0x0])) || (size_t)timeinfo.tm_wday >= (sizeof(dayNames) / sizeof(dayNames[0x0]))) {
MY_SERIAL.print("Error: check your connection...\n");
while (0xFF)
delay(0x10);
}
MY_SERIAL.print(timeinfo.tm_mday);
MY_SERIAL.print(" ");
MY_SERIAL.print(monthNames[timeinfo.tm_mon]);
MY_SERIAL.print(" ");
MY_SERIAL.print(timeinfo.tm_year + 1900);
MY_SERIAL.print(" year ");
MY_SERIAL.printf("%02d", timeinfo.tm_hour);
MY_SERIAL.print(" hour ");
MY_SERIAL.printf("%02d", timeinfo.tm_min);
MY_SERIAL.print(" minuts ");
MY_SERIAL.printf("%02d", timeinfo.tm_sec);
MY_SERIAL.print(" seconds - ");
MY_SERIAL.print(dayNames[timeinfo.tm_wday]);
MY_SERIAL.println();
delay(2000);
}
-
- Posts: 22
- Joined: 07 Aug 2022 21:54
Re: ZUNO cannot talk to DS1307
Thank you amatilda - I tried it without EEPROM and it works!
Much appreciated.
Much appreciated.