Ich kann nicht DS3231 RTC zu arbeiten

Habe ich ein DS3231 RTC Modul, und ich bin versucht zu Lesen Zeit, aus der es mit meinem Arduino UNO über I2C. Ich bin mit dem sample-code mit der Bibliothek, aber es scheint nicht zu funktionieren.

Das einzige, was ich raus aus dem serial monitor ist dieser:

20165-85-165 25:165:165
Temperature=254

War ich immer die gleiche Sache mit einer anderen RTC-Modul als auch, und meine Vermutung (was wahrscheinlich nicht stimmt) ist, dass Sie vielleicht überflogen aber es scheint nicht zu sein, einen reset-pin.

#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();
  #define oneTime
  #ifdef oneTime
    Clock.setSecond(50);//Set the second 
    Clock.setMinute(59);//Set the minute 
    Clock.setHour(11);  //Set the hour 
    Clock.setDoW(5);    //Set the day of the week
    Clock.setDate(31);  //Set the date of the month
    Clock.setMonth(5);  //Set the month of the year
    Clock.setYear(13);  //Set the year (Last two digits of the year)
  #endif
        //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);}
Dies ist nicht C! Fügen Sie keine C-tag für Arduino-code.

InformationsquelleAutor Ege Feyzıoglu | 2015-10-31

Schreibe einen Kommentar