New to programming Arduino. DS3231 is not working

Hello, I'm trying to set up my DS3231 for near years, I'm using this http://misclab.umeoce.maine.edu/boss/Arduino/bensguides/DS3231_Arduino_Clock_Instructions.pdf

and I get alot of errors (I copy and pasted the code, my code is exactly the same).

My errors: sketch_dec20a:10: error: 'DS3231' does not name a type
sketch_dec20a.ino: In function 'void setup()':
sketch_dec20a:25: error: 'Clock' was not declared in this scope
sketch_dec20a.ino: In function 'void ReadDS3231()':
sketch_dec20a:37: error: 'Clock' was not declared in this scope

Thanks.

  • VCaleb

sketch_dec20a:10: error: 'DS3231' does not name a type

So, why do you think it does? How are we supposed to know, when only YOU can see your code?

Most often, this happens because you have not downloaded and installed the mystery library in the right place. Of course, you also failed to tell us where you got the library or where you installed it.

PaulS:
So, why do you think it does? How are we supposed to know, when only YOU can see your code?

Most often, this happens because you have not downloaded and installed the mystery library in the right place. Of course, you also failed to tell us where you got the library or where you installed it.

Look at the link, it has the code i copy and paste and the libary.

VCaleb:
Look at the link, it has the code i copy and paste and the libary.

The time of people here is precious. YOU post the code. Don't expect people to go looking for something for your convenience.

And make sure to post the ACTUAL code you are using - not the code from some other place.

...R

Seems like you forgot a vital part in your code.

there should be something like

DS3231 Clock;

somewhere in your code.

I haven't read the link you posted, since my time is precious too as previously stated by Robin2. :slight_smile:

I could however just post the code i have running:

/*
DS3231_test.pde
Eric Ayars
4/11

Test/demo of read routines for a DS3231 RTC.

Turn on the serial monitor after loading this to check if things are
working as they should.

*/

#include <DS3231.h>
#include <Wire.h>

DS3231 Clock;
bool Century=false;
bool h12;
bool PM;
byte ADay, AHour, AMinute, ASecond, ABits;
bool ADy, A12h, Apm;

byte year, month, date, DoW, hour, minute, second;

void setup() {
	// Start the I2C interface
	Wire.begin();
        Clock.setSecond(00);//Set the second 
        Clock.setMinute(52);//Set the minute 
        Clock.setHour(20);  //Set the hour 
        Clock.setDoW(6);    //Set the day of the week
        Clock.setDate(20);  //Set the date of the month
        Clock.setMonth(12);  //Set the month of the year
        Clock.setYear(14);  //Set the year (Last two digits of the year)
	// Start the serial interface
	Serial.begin(115200);
}
void ReadDS3231()
{
  int second,minute,hour,date,month,year,temperature; 
  second=Clock.getSecond();
  minute=Clock.getMinute();
  hour=Clock.getHour(h12, PM);
  date=Clock.getDate();
  month=Clock.getMonth(Century);
  year=Clock.getYear();
  
  temperature=Clock.getTemperature();
  
  Serial.print("20");
  Serial.print(year,DEC);
  Serial.print('-');
  Serial.print(month,DEC);
  Serial.print('-');
  Serial.print(date,DEC);
  Serial.print(' ');
  Serial.print(hour,DEC);
  Serial.print(':');
  Serial.print(minute,DEC);
  Serial.print(':');
  Serial.print(second,DEC);
  Serial.print('\n');
  Serial.print("Temperature=");
  Serial.print(temperature); 
  Serial.print('\n');
}
void loop() {ReadDS3231();delay(1000);}

This sets the clock to the values specified under void setup, after you have set them once you can delete or comment out the respective lines in void setup

Seems like you forgot a vital part in your code

I'm pretty sure that line was in the code the OP says was copied exactly.

My suspicion is that the library in question has not been installed...