GETTING THIS ERROR 'NO MATCH FUNCTION FOR CALL TO DS3231::DS32310

Arduino: 1.8.4 (Mac OS X), Board: "Arduino/Genuino Uno"

easy_clock:29: error: no matching function for call to 'DS3231::DS3231()'
DS3231 Clock; DS3231
^
/Users/khaliddavirus/Desktop/sketches/easy_clock/easy_clock.ino:29:8: note: candidates are:
In file included from /Users/khaliddavirus/Desktop/sketches/easy_clock/easy_clock.ino:15:0:
/Users/khaliddavirus/Documents/Arduino/libraries/DS3231/DS3231.h:80:3: note: DS3231::DS3231(uint8_t, uint8_t)
DS3231(uint8_t data_pin, uint8_t sclk_pin);

^
/Users/khaliddavirus/Documents/Arduino/libraries/DS3231/DS3231.h:80:3: note: candidate expects 2 arguments, 0 provided
/Users/khaliddavirus/Documents/Arduino/libraries/DS3231/DS3231.h:77:7: note: constexpr DS3231::DS3231(const DS3231&)
class DS3231

^
/Users/khaliddavirus/Documents/Arduino/libraries/DS3231/DS3231.h:77:7: note: candidate expects 1 argument, 0 provided
/Users/khaliddavirus/Documents/Arduino/libraries/DS3231/DS3231.h:77:7: note: constexpr DS3231::DS3231(DS3231&&)
/Users/khaliddavirus/Documents/Arduino/libraries/DS3231/DS3231.h:77:7: note: candidate expects 1 argument, 0 provided
easy_clock:31: error: expected initializer before 'year'
byte year, month, date, DoW, hour, minute, second;
^
/Users/khaliddavirus/Desktop/sketches/easy_clock/easy_clock.ino: In function 'void loop()':
easy_clock:110: error: 'year' was not declared in this scope
Clock.getTime(year, month, date, DoW, hour, minute, second);
^
easy_clock:110: error: 'month' was not declared in this scope
Clock.getTime(year, month, date, DoW, hour, minute, second);
^
easy_clock:110: error: 'date' was not declared in this scope
Clock.getTime(year, month, date, DoW, hour, minute, second);
^
easy_clock:110: error: 'DoW' was not declared in this scope
Clock.getTime(year, month, date, DoW, hour, minute, second);
^
easy_clock:110: error: 'hour' was not declared in this scope
Clock.getTime(year, month, date, DoW, hour, minute, second);
^
easy_clock:110: error: 'minute' was not declared in this scope
Clock.getTime(year, month, date, DoW, hour, minute, second);
^
easy_clock:110: error: 'second' was not declared in this scope
Clock.getTime(year, month, date, DoW, hour, minute, second);
^
easy_clock:111: error: 'class DS3231' has no member named 'getTemperature'
int temperature=(Clock.getTemperature()*1.8+32);
^
exit status 1
no matching function for call to 'DS3231::DS3231()'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I can see nothing wrong with the code that you did not post

1 Like

I don't know how to post code

khaliddavirus:
I don’t know how to post code

Instructions in the sticky at the top of the forum.

But basically hit the </> icon and paste your code between the [code] and [/code] tags.

/

/*
 * Easy Clock
 * 
 * learnelectronics
 * 10 April 2017
 * 
 * adapted from a library example
 * "print_text" from MDMaxx72xx library
 * Copyright (C) 2012-16 Marco Colli.
 * 
 * www.youtube.com/c/learnelectronics
 * arduino0169@gmail.com
 */

#include <DS3231.h>
#include <Wire.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#define	PRINT(s, v)	{ Serial.print(F(s)); Serial.print(v); }
#define	MAX_DEVICES	4
#define	CLK_PIN		13  // or SCK
#define	DATA_PIN	11  // or MOSI
#define	CS_PIN		10  // or SS

#define  CHAR_SPACING  1 // pixels between characters


MD_MAX72XX mx = MD_MAX72XX(CS_PIN, MAX_DEVICES);
DS3231 Clock; DS3231

byte year, month, date, DoW, hour, minute, second;
// Global message buffers shared by Serial and Scrolling functions
#define	BUF_SIZE	10
char message[BUF_SIZE] = {"Hello!"};
bool newMessageAvailable = true;



void printText(uint8_t modStart, uint8_t modEnd, char *pMsg)

{
  uint8_t   state = 0;
  uint8_t	  curLen;
  uint16_t  showLen;
  uint8_t	  cBuf[8];
  int16_t   col = ((modEnd + 1) * COL_SIZE) - 1;

  mx.control(modStart, modEnd, MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);

  do     // finite state machine to print the characters in the space available
  {
    switch(state)
    {
      case 0:	// Load the next character from the font table
        // if we reached end of message, reset the message pointer
        if (*pMsg == '\0')
        {
          showLen = col - (modEnd * COL_SIZE);  // padding characters
          state = 2;
          break;
        }

        // retrieve the next character form the font file
        showLen = mx.getChar(*pMsg++, sizeof(cBuf)/sizeof(cBuf[0]), cBuf);
        curLen = 0;
        state++;
        // !! deliberately fall through to next state to start displaying

      case 1:	// display the next part of the character
        mx.setColumn(col--, cBuf[curLen++]);

        // done with font character, now display the space between chars
        if (curLen == showLen)  
        {
          showLen = CHAR_SPACING;
          state = 2;
        }
        break;

      case 2: // initialize state for displaying empty columns
        curLen = 0;
        state++;
        // fall through

      case 3:	// display inter-character spacing or end of message padding (blank columns)
        mx.setColumn(col--, 0);
        curLen++;
        if (curLen == showLen) 
          state = 0;
        break;

      default:
        col = -1;   // this definitely ends the do loop
    }
  } while (col >= (modStart * COL_SIZE));

  mx.control(modStart, modEnd, MD_MAX72XX::UPDATE, MD_MAX72XX::ON);
}

void setup()
{
  mx.begin();
  Wire.begin();
  Serial.begin(57600);
 
}

void loop() 
{
Clock.getTime(year, month, date, DoW, hour, minute, second);
int temperature=(Clock.getTemperature()*1.8+32);
int lh = ((hour/10)%10);
int rh = (hour%10);
int lm = ((minute/10)%10);
int rm = (minute%10);
int lt = ((temperature/10)%10);
int rt = (temperature%10);


if (second==30 || second==00){
message[0]=' ';
message[1]=' ';
message[2]=char(lt)+48;
message[3]=char(rt)+48;
message[4]='F';
message[5]='\0';
printText(0, MAX_DEVICES-1, message);
delay(1000);
}
else{

message[0]=' ';
message[1]=' ';
message[2]=char(lh)+48;
message[3]=char(rh)+48;
message[4]=':';
message[5]=char(lm)+48;
message[6]=char(rm)+48;
message[7]='\0';
printText(0, MAX_DEVICES-1, message);
}

}
DS3231 Clock; DS3231

byte

oops

Not getting you ..
Can you explain??

Compare that to this screen shot from the guy's YouTube video.

easy clock error.GIF

easy clock error.GIF

Same error I did compared it with original

khaliddavirus:
Same error I did compared it with original

So what does your revised code look like now ?

i just changed the DS3231 after the clock
same results

What DS3231 library are you using? There are many with the same name and different syntax. Is it properly installed? Can you run the basic library examples sketches?

Please see reply #9

the eroor is fixed now but now i am getting another type of error that is the GetTime errror

code is the same that was a library issue thanks to you resolved it but how to fix this one?

Arduino: 1.8.4 (Mac OS X), Board: "Arduino/Genuino Uno"

WARNING: Category 'Real-time clock' in library DS3231 is not valid. Setting to 'Uncategorized'
/Users/khaliddavirus/Desktop/sketches/easy_clock/easy_clock.ino: In function 'void loop()':
easy_clock:111: error: 'class DS3231' has no member named 'getTime'
Clock.getTime("year", "month", "date", DoW, "hour", "minute", "second");
^
exit status 1
'class DS3231' has no member named 'getTime'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

My best guess is you have the wrong library and it doesn't actually contain the functions you're trying to use from it.

But since you never answered the questions (in message #11) about exactly what library you're using and where got it from and you haven't posted your latest code after the changes, it's only a guess.

Steve

/*
DS3231_set.pde
Eric Ayars
4/11

these two libraries
no 1 MAAJIC DESIGNS> "MD_DS3231"
no 2 Eric Ayars "DS3231

FOLLLOWING THIS VIDEO

</>

/*
 * Easy Clock
 * 
 * learnelectronics
 * 10 April 2017
 * 
 * adapted from a library example
 * "print_text" from MDMaxx72xx library
 * Copyright (C) 2012-16 Marco Colli.
 * 
 * www.youtube.com/c/learnelectronics
 * arduino0169@gmail.com
 */
#include <MD_DS3231.h>
#include <DS3231.h>
#include <Wire.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#define	PRINT(s, v)	{ Serial.print(F(s)); Serial.print(v); }
#define	MAX_DEVICES	4
#define	CLK_PIN		13  // or SCK
#define	DATA_PIN	11  // or MOSI
#define	CS_PIN		10  // or SS

#define  CHAR_SPACING  1 // pixels between characters


MD_MAX72XX mx = MD_MAX72XX(CS_PIN, MAX_DEVICES);
DS3231 Clock;

byte year, month, date, DoW, hour, minute, second;
// Global message buffers shared by Serial and Scrolling functions
#define	BUF_SIZE	10
char message[BUF_SIZE] = {"Hello!"};
bool newMessageAvailable = true;



void printText(uint8_t modStart, uint8_t modEnd, char *pMsg)

{
  uint8_t   state = 0;
  uint8_t	  curLen;
  uint16_t  showLen;
  uint8_t	  cBuf[8];
  int16_t   col = ((modEnd + 1) * COL_SIZE) - 1;

  mx.control(modStart, modEnd, MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);

  do     // finite state machine to print the characters in the space available
  {
    switch(state)
    {
      case 0:	// Load the next character from the font table
        // if we reached end of message, reset the message pointer
        if (*pMsg == '\0')
        {
          showLen = col - (modEnd * COL_SIZE);  // padding characters
          state = 2;
          break;
        }

        // retrieve the next character form the font file
        showLen = mx.getChar(*pMsg++, sizeof(cBuf)/sizeof(cBuf[0]), cBuf);
        curLen = 0;
        state++;
        // !! deliberately fall through to next state to start displaying

      case 1:	// display the next part of the character
        mx.setColumn(col--, cBuf[curLen++]);

        // done with font character, now display the space between chars
        if (curLen == showLen)  
        {
          showLen = CHAR_SPACING;
          state = 2;
        }
        break;

      case 2: // initialize state for displaying empty columns
        curLen = 0;
        state++;
        // fall through

      case 3:	// display inter-character spacing or end of message padding (blank columns)
        mx.setColumn(col--, 0);
        curLen++;
        if (curLen == showLen) 
          state = 0;
        break;

      default:
        col = -1;   // this definitely ends the do loop
    }
  } while (col >= (modStart * COL_SIZE));

  mx.control(modStart, modEnd, MD_MAX72XX::UPDATE, MD_MAX72XX::ON);
}

void setup()
{
  mx.begin();
  Wire.begin();
  Serial.begin(57600);
 
}

void loop() 
{
Clock.getTime(year, month, date, DoW, hour, minute, second);
int temperature=(Clock.getTemperature()*1.8+32);
int lh = ((hour/10)%10);
int rh = (hour%10);
int lm = ((minute/10)%10);
int rm = (minute%10);
int lt = ((temperature/10)%10);
int rt = (temperature%10);


if (second==30 || second==00){
message[0]=' ';
message[1]=' ';
message[2]=char(lt)+48;
message[3]=char(rt)+48;
message[4]='F';
message[5]='\0';
printText(0, MAX_DEVICES-1, message);
delay(1000);
}
else{

message[0]=' ';
message[1]=' ';
message[2]=char(lh)+48;
message[3]=char(rh)+48;
message[4]=':';
message[5]=char(lm)+48;
message[6]=char(rm)+48;
message[7]='\0';
printText(0, MAX_DEVICES-1, message);
}

}

[code/]

So when you said the code was the same as you posted before you meant except that you have now included two separate DS3231 libraries. Why both ? You're only using one of them.

But anyway neither of them contain a getTime method so I have no idea where that comes from. One of them contains readTime and one contains separate gets for getDay, getHour, getMinute etc.

So as I said you have the wrong library to go with that code. I can't see in that video where he tells you where he got his library from so you need to do some investigating (or make some changes to the code).

Steve

yes he gave the link in the description from where he got the libraries ...
and i can't manage to obtain that get time function ..

here is the link from where he got the libraries.

That site contains the MD_DS3231 library but that's not the one he shows in the code in the video. And that's also not the one you're using. But anyway that one does not have a getTime method either. It has readTime but it's used completely differently to the code you have.

If you understand what the code is trying to do you should be able to change it to use MD_DS3231.h but it's a fairly major change.

After a lot of Googling it looks to me as though the original Eric Ayars DS3231.h from 2011 had a getTime() but it has been taken out of the many later "improved" versions. You could try loading the original library from Hardware Hacks: DS3231 Real-Time Clock in place of the one you currently have and see if that works. Oh and remove the include of MD_DS3231.h unless you're going to use it.

Steve