I followed a guide to make an arduino world clock. So far, I've assembled everything, but I only need to sort out the programming part.
Namely, in the part's list, a DS3231 RTC is listed, whereas the guy later on uses a DS1307 RTC. From what I can see, they syntax is a little bit different for setting the time on both.
I have managed to set the correct time on the RTC, but I cannot figure out how to implement the RTC DS3231 in that code.
Bellow is a copy of the code, and hopefully someone would be able to help me out
From what I can see, the library is the same. And I might have had a hardware connection error. Will get it fixed and post the outcome.
Furthermore, would anyone care to sum up the first lines of the code where the time is being set? With my limited programming knowledge, I cant understand what is going on.
Furthermore, would anyone care to sum up the first lines of the code where the time is being set? With my limited programming knowledge, I cant understand what is going on.
You should post the snippet that you don't understand, rather than having us guess which lines they are.
If you are trying to make a world clock, then I think you picked the wrong place to start. The software you chose does not appear to support time zones or Daylight Saving Time.
odometer:
If you are trying to make a world clock, then I think you picked the wrong place to start. The software you chose does not appear to support time zones or Daylight Saving Time.
Any ideas of a better software?
Furthermore, this version does have + and - 1min buttons, so it can be adjusted manually
PaulS:
You should post the snippet that you don't understand, rather than having us guess which lines they are.
This:
//Initialize RTC
Serial.begin(9600);
// while (!Serial) ; // wait until Arduino Serial Monitor opens
delay(200);
setSyncProvider(RTC.get); // the function to get the time from the RTC
setSyncInterval(60); // sync the time every 60 seconds (1 minutes)
if(timeStatus()!= timeSet){
Serial.println("Unable to sync with the RTC");
RTC.set(1408278800); // set the RTC to Aug 25 2014 9:00 am
setTime(1408278800);
}
else{
Serial.println("RTC has set the system time");
}
// initialize the LED I/O pins as outputs
// iterate over the pins:
for (int thisPin = 0; thisPin < 13; thisPin++) {
// initialize the output pins:
pinMode(col[thisPin], OUTPUT);
pinMode(row[thisPin], OUTPUT);
// take the col pins (i.e. the cathodes) high to ensure that
// the LEDS are off:
digitalWrite(col[thisPin], LOW);
}
// initialize the pixel matrix by setting all LED Anodes and Cathodes to LOW:
for (int x = 0; x < 13; x++) {
for (int y = 0; y < 13; y++) {
pixels[x][y] = LOW;
}
}
// initialize the Button I/O pins as Digital Inputs for Increment and Decrement time for manual adjustment of time
pinMode(8, INPUT); // Increment time
pinMode(9, INPUT); // Decrement time
}
void loop() {
// Read the current date and time from the RTC
if (timeStatus() == timeSet) {
UpdateDisp();
// hmdmDisplay();
} else {
Serial.println("The time has not been set. Please run the Time");
Serial.println("TimeRTCSet example, or DS1307RTC SetTime example.");
Serial.println();
delay(4000);
}
Well noticed! hahaha I had no idea it was a word clock.
Anyways, it is meant to be placed in a room, and not switched form that time zone. So daylight saving features would come in handy, but are not a top priority
stef_an:
Well noticed! hahaha I had no idea it was a word clock.
Word vs World is very different.
If you are just going to implement that design then you can use the DS3232 library with your ds3231.
Look at the examples with the ds3232 library and you will see how to set up the Time sync provider.
BTW, most of those ds3231 have a flaw in them. They were designed with a crappy battery circuit. They tried to tried to design it for a rechargeable battery but their design is bad. And to make things worse, many include a CR2032 (non chargeable) rather than the LIR2032 battery.
It is a simple modification to fix the board to work properly with a non chargeable battery.
Not doing so risks damaging the battery.
If you post a clear closeup photo of your RTC module I can take a look and show you which trace to cut to fix it.
--- bill
I built a word clock for my mother a couple of years ago.
It was a massive amount of work, with most of the work being the mechanical design since I was using individual LEDs.
You said that you didn't understand two lines, and then posted another, longer, snippet, with 56 lines in it. You STILL want us to guess which 2 lines you don't understand, only now our odds of guessing which two lines you don't understand are even worse.
If you are just going to implement that design then you can use the DS3232 library with your ds3231.
Look at the examples with the ds3232 library and you will see how to set up the Time sync provider.
BTW, most of those ds3231 have a flaw in them. They were designed with a crappy battery circuit. They tried to tried to design it for a rechargeable battery but their design is bad. And to make things worse, many include a CR2032 (non chargeable) rather than the LIR2032 battery.
It is a simple modification to fix the board to work properly with a non chargeable battery.
Not doing so risks damaging the battery.
If you post a clear closeup photo of your RTC module I can take a look and show you which trace to cut to fix it.
--- bill
I built a word clock for my mother a couple of years ago.
It was a massive amount of work, with most of the work being the mechanical design since I was using individual LEDs.
Sorry for my late response, but I was travelling and I just settled down Attached is a picture of my ds3231 module. I did change the included battery to a better cr2032 batt.
PaulS:
You said that you didn't understand two lines, and then posted another, longer, snippet, with 56 lines in it. You STILL want us to guess which 2 lines you don't understand, only now our odds of guessing which two lines you don't understand are even worse.
stef_an:
Sorry for my late response, but I was travelling and I just settled down Attached is a picture of my ds3231 module. I did change the included battery to a better cr2032 batt.
You will need to do the modification to disable the charging circuit.
You can either cut the trace or remove the diode or resistor.
I posted the entire part that I don't understand.
The mainline code uses the Time library and its API functions that is independent of the RTC library used.
The RTC library is only used to get a unix timestamp for time syncronization and to set set the time in the RTC h/w using a unix timestamp.
The DS3232 library uses the same API as the DS1307 API for getting the unix timestamp and setting the RTC from a unix timestamp, so it should just be matter of using the proper header file.
See the included examples in the DS3232 library and the header files for more information.
Okay guys, I managed to set up the time. I was supposed to be using a UNIX time format, and I am almost done with the clock.
However, I am having troubles compiling the final code with time transitions for this clock. I am getting an error message "was not declared in this scope".
I spent hours looking at the code, and I cant find the bug. The thing is, when I use the code without the time transitions I am not getting that error.
I am attaching the error message, the working code, and the one that returns error.
Look at line 125 you have a stray beginning of a comment:
A "/*" that is commenting out some code.
/*
//Decrement Button Pushed
if(digitalRead(8) == LOW){
delay(100); // Deboubnce by waiting then checking again
if(digitalRead(8) == LOW){
if(timeStatus() == timeSet){
adjustTime(-60);
RTC.set(now() -60);
blankscreen(); // Blank out all LEDs
}
}
delay(100);
}
Remove that line and it will compile.
I would also recommend using the auto format to fix up the indentation.
You need to use a better editor.
One that can colorize syntax.
With that, you would have seen the giant block of code commented out in the middle of your sketch.
BTW, if you were originally commenting out code, using /* */ is a bad way of doing it.
Using some thing like this:
#ifdef notdef
code you wanted commented out.
#endif
That will always work without having to worry about nested comments.
bperrybap:
Look at line 125 you have a stray beginning of a comment:
A "/*" that is commenting out some code.
/*
//Decrement Button Pushed
if(digitalRead(8) == LOW){
delay(100); // Deboubnce by waiting then checking again
if(digitalRead(8) == LOW){
if(timeStatus() == timeSet){
adjustTime(-60);
RTC.set(now() -60);
blankscreen(); // Blank out all LEDs
}
}
delay(100);
}
Remove that line and it will compile.
I would also recommend using the auto format to fix up the indentation.
You need to use a better editor.
One that can colorize syntax.
With that, you would have seen the giant block of code commented out in the middle of your sketch.
BTW, if you were originally commenting out code, using /* */ is a bad way of doing it.
Using some thing like this:
#ifdef notdef
code you wanted commented out.
#endif
That will always work without having to worry about nested comments.
--- bill
Yeah, that is intentionally commented out until install the buttons (later today). hat other editior would you suggest?
And @cattledog thanks for the input THe closing bracket was commented out. However, I am still getting this error
maija_clock:118: error: expected constructor, destructor, or type conversion before ';' token
refreshScreen();
^
maija_clock:122: error: expected constructor, destructor, or type conversion before ';' token
textblock(); // Name always on display
^
maija_clock:123: error: expected constructor, destructor, or type conversion before ';' token
itis(); // IT IS always on display
^
expected constructor, destructor, or type conversion before ';' token