Complier errors in DS1302 Clock program

I have problem trying to get time using Nuelectronics “Real-time Data-log & IO shield” (it has the DS1302 chip). I have Mega 256 board with this shield plugged into it.
I’ve gotten other devices to work fine (like Parallax Ping Ultrasonic Distance Sensor, 3 axis accel, etc).
I have tried several different programs and now have gone back to what appears to be, a simple program, “set_clock, copyright Matt Sparks, 2009”.
I have tried adding different support files in the library, like Mr Karlsen’s, and tried his program. But, like I said, trying to simplify situation with original stuff (programs and libs).
My guess is very basic stupid mistake, but driving me nutso.
Thanks for any suggestions!

------ Start code sample ------

#include <stdio.h>
#include <string.h>
#include <DS1302.h>

/* Set the appropriate digital I/O pin connections */

uint8_t CE_PIN = 4; //4 was 5
uint8_t IO_PIN = 1; //1 was 6
uint8_t SCLK_PIN = 3; //3 was 7

/* Create buffers */

char buf[50];
char day[10];

/* Create a DS1302 object */

DS1302 rtc(CE_PIN, IO_PIN, SCLK_PIN);

------ end code sample that generates first errors -----

----- First few errors- (sorry don’t know how to copy & paste error msgs)

set_clock:23: error: no matching function for call to
‘DS1302::DS1302(uint8_t&, uint8_t&, uint8_t&)’
C:\Controller\libraries\DS1302/DS1302.h:49: note:
DS1302::DS1302(const DS1302&)

---- end sample first error codes —

I downloaded the library… GitHub - msparks/arduino-ds1302: Arduino library for the DS1302 Real Time Clock chip and compiled the example.

Unmodified, it compiles with no errors on my 2560. I am assuming that you introduced an error somehow.

Thanks very much for responding. I deleted all examples of this program and grabbed the files from that Sparks directory you listed. Without making any changes, still get the same errors. When I tried to make sure the Sparks files were in the library, the library listed them under a heading "Contributed". It acts like it can't see the library or something since there are so many errors, and it works for you. Any ideas? BTW- I couldn't find a pointer that specifically listed a full directory path to the library. It has to get the path from somewhere, no?

I deleted everything and reinstalled. I don't get the error message anymore! But I get all zero's for the time and data info on the serial monitor. I have the shield plugged directly into the headers of the Mega 256 board, are there any other connections I have to make? This problem may have to be moved to another topic heading, since I think it is a hardware issue.

Thanks for any suggestions, Steve

Post your code, inside code tags.

Read this before posting a programming question

How to use this forum

Sorry I was dealing with someone else who had downloaded the code. So see below. The only mods I did was add the LED statements, which didn’t affect the serial output at all.
Like I said earlier, the shield is plugged directly on top of the Mega 256 board. Putting a 'scope on J1 digital lines 5, 6, 7, I can see pulses, so the chip appears alive. Any suggestions really appreciated.

Steve

----------- Code Listing Start -----------
/*
Example sketch for interfacing with the DS1302 timekeeping chip.

Copyright (c) 2009, Matt Sparks
All rights reserved.

http://quadpoint.org/projects/arduino-ds1302
*/
#include <stdio.h>
#include <string.h>
#include <DS1302.h>

/* Set the appropriate digital I/O pin connections */
uint8_t CE_PIN = 5;
uint8_t IO_PIN = 6;
uint8_t SCLK_PIN = 7;

/* Create buffers */
char buf[50];
char day[10];
const int LED = 10;

/* Create a DS1302 object */
DS1302 rtc(CE_PIN, IO_PIN, SCLK_PIN);

void print_time()
{
/* Get the current time and date from the chip */
Time t = rtc.time();
digitalWrite(LED, HIGH);

/* Name the day of the week /
memset(day, 0, sizeof(day)); /
clear day buffer */
switch (t.day) {
case 1:
strcpy(day, “Sunday”);
break;
case 2:
strcpy(day, “Monday”);
break;
case 3:
strcpy(day, “Tuesday”);
break;
case 4:
strcpy(day, “Wednesday”);
break;
case 5:
strcpy(day, “Thursday”);
break;
case 6:
strcpy(day, “Friday”);
break;
case 7:
strcpy(day, “Saturday”);
break;
}

/* Format the time and date and insert into the temporary buffer */
snprintf(buf, sizeof(buf), “%s %04d-%02d-%02d %02d:%02d:%02d”,
day,
t.yr, t.mon, t.date,
t.hr, t.min, t.sec);

/* Print the formatted string to serial so we can see the time */
Serial.println(buf);
}

void setup()
{
Serial.begin(9600);

/* Initialize a new chip by turning off write protection and clearing the
clock halt flag. These methods needn’t always be called. See the DS1302
datasheet for details. */
rtc.write_protect(false);
rtc.halt(false);

pinMode(LED, OUTPUT);

/* Make a new time object to set the date and time /
/
Tuesday, May 19, 2009 at 21:16:37. */
Time t(2009, 5, 19, 21, 16, 37, 3);

/* Set the time and date on the chip */
rtc.time(t);
// digitalWrite(LED, HIGH);

}

/* Loop and print the time every second */
void loop()
{
print_time();
delay(500);
digitalWrite(LED, LOW);
delay(500);
}
-------------------------- End Code Listing --------------------

Any suggestions really appreciated.

OK, here's one. Read this, as you were told to: http://forum.arduino.cc/index.php/topic,97455.0.html

Yes, I reviewed it before posting. Your suggestion was very helpful and to the point. I guess you were never new to an environment. I am trying to follow the rules. Did someone put out a hit on me or something? I understand you must get a lot of really stupid questions and I truly apologize if I fall in that category. If I am wasting your time, just don't respond. Any real suggestions?

Your friend forever, Steve

I understand you must get a lot of really stupid questions and I truly apologize if I fall in that category.

It's not the stupid (they're really not) questions. It's the improperly posted code. Fix that, and I (and others) will be happy to look at it. Leave it as is, and I (and others) won't even look at it.

/*
Example sketch for interfacing with the DS1302 timekeeping chip.


Copyright (c) 2009, Matt Sparks
All rights reserved.

http://quadpoint.org/projects/arduino-ds1302
*/
#include <stdio.h>
#include <string.h>
#include <DS1302.h>

/* Set the appropriate digital I/O pin connections */
uint8_t CE_PIN   = 5;
uint8_t IO_PIN   = 6;
uint8_t SCLK_PIN = 7;

/* Create buffers */
char buf[50];
char day[10];
const int LED = 10;

/* Create a DS1302 object */
DS1302 rtc(CE_PIN, IO_PIN, SCLK_PIN);

void print_time()
{
  /* Get the current time and date from the chip */
  Time t = rtc.time();
 digitalWrite(LED, HIGH);

  /* Name the day of the week */
  memset(day, 0, sizeof(day));         /* clear day buffer */
  switch (t.day) {
    case 1:
      strcpy(day, "Sunday");
      break;
    case 2:
      strcpy(day, "Monday");
      break;
    case 3:
      strcpy(day, "Tuesday");
      break;
    case 4:
      strcpy(day, "Wednesday");
      break;
    case 5:
      strcpy(day, "Thursday");
      break;
    case 6:
      strcpy(day, "Friday");
      break;
    case 7:
      strcpy(day, "Saturday");
      break;
  }

  /* Format the time and date and insert into the temporary buffer */
  snprintf(buf, sizeof(buf), "%s %04d-%02d-%02d %02d:%02d:%02d",
           day,
           t.yr, t.mon, t.date,
           t.hr, t.min, t.sec);

  /* Print the formatted string to serial so we can see the time */
  Serial.println(buf);
}

void setup()
{
  Serial.begin(9600);

  /* Initialize a new chip by turning off write protection and clearing the
     clock halt flag. These methods needn't always be called. See the DS1302
     datasheet for details. */
   rtc.write_protect(false);
   rtc.halt(false);

   pinMode(LED, OUTPUT);
  
   
  /* Make a new time object to set the date and time */
  /*   Tuesday, May 19, 2009 at 21:16:37.            */
  Time t(2009, 5, 19, 21, 16, 37, 3);

  /* Set the time and date on the chip */
  rtc.time(t); 
  // digitalWrite(LED, HIGH);
  
}

/* Loop and print the time every second */
void loop()
{
  print_time();
  delay(500);
  digitalWrite(LED, LOW);
  delay(500);
 }

With your (now properly posted) code, and the DS1302 library downloaded and installed in the proper place, I only get one "error":

Binary sketch size: 6,118 bytes (of a 32,256 byte maximum)

Trying to read into your reply-

I am guessing that you don't have the same shield and so you could not determine if the time was reported correctly. But there didn't appear to be any software errors so I should post my question in a hardware section of the forum?

Pete999: I am guessing that you don't have the same shield and so you could not determine if the time was reported correctly. But there didn't appear to be any software errors so I should post my question in a hardware section of the forum?

You're inquiring about compiler errors. What happens when the sketch runs is irrelevant since you can't run it until you resolve the compiler errors. Are you say it now compiles OK and you have some other problem? If so you need to explain what that other problem is - what you expect your sketch to do, and what it actually does.

Hi Peter,

Yes, my original problem was complier errors. In Reply #3, I mentioned that I deleted and reinstalled everything and the complier errors were gone, but that I wasn't reading the time correctly (all zeros). I also sorta asked twice, if I should move my new problem to a hardware related area, but being new, didn't know if the moderator would do that or not. I will just repost my problem in the project help section. Thanks for everybody's time...