After testing it, I put it in my parts bin for a planned project that never happened. Now I am thinking using it with my Raspberry Pi. It seems straight forward except for the pin labeled DS. I combed the net for a schematic with no result. I'm hoping you experts can shed some light on this.
It IS connected, to the center (data) pin of the empty three pin device location in the corner. That's where you can put a DS18B20 temperature sensor and talk to it with OneWire. The schematic shows a 3.3k pull-up resistor for the OneWire bus but I suspect that would have been in the empty R7 location next to the crystal.
I also have this RTC module. I have wired it to an arduina mega adk r3. The wiring is correct, and I'm trying to use the library from the adafruit tutorials.
I have managed to set the time on the RTC, but I have some problem with it now.
csabee:
I have managed to set the time on the RTC, but I have some problem with it now.
Here is my code:
Is that the code, or just a snippet? If the former, no, it's a snippet. Probably lifted from the example included in the DS1307 library. If you use the whole thing, you will probably get a result.
I found the following more useful. It doesn't use a clock library
//Arduino 1.0+ Only
//Arduino 1.0+ Only
#include <LiquidCrystal_I2C.h>
#include "Wire.h"
#define DS1307_ADDRESS 0x68
LiquidCrystal_I2C lcd(0x27,20,4);
void setup(){
Wire.begin();
Serial.begin(9600);
lcd.init();
delay(1000);
lcd.clear();
lcd.backlight(); //Backlight ON if under program control
lcd.setCursor(0,0);
// Print a message to the LCD.
lcd.print("Today it is");
}
void loop(){
printDate();
delay(1000);
}
byte bcdToDec(byte val) {
// Convert binary coded decimal to normal decimal numbers
return ( (val/16*10) + (val%16) );
}
void printDate(){
// Reset the register pointer
Wire.beginTransmission(DS1307_ADDRESS);
byte zero = 0x00;
Wire.write(zero);
Wire.endTransmission();
Wire.requestFrom(DS1307_ADDRESS, 7);
int second = bcdToDec(Wire.read());
int minute = bcdToDec(Wire.read());
int hour = bcdToDec(Wire.read() & 0b111111); //24 hour time
int weekDay = bcdToDec(Wire.read()); //0-6 -> sunday - Saturday
int monthDay = bcdToDec(Wire.read());
int month = bcdToDec(Wire.read());
int year = bcdToDec(Wire.read());
lcd.setCursor(10,1);
switch (weekDay) // Friendly printout the weekday
{
case 1:
lcd.print("MONDAY ");
Serial.print("MON ");
break;
case 2:
lcd.print("TUESDAY ");
Serial.print("TUE ");
break;
case 3:
lcd.print("WEDNESDAY ");
Serial.print("WED ");
break;
case 4:
lcd.print("THURSDAY ");
Serial.print("THU ");
break;
case 5:
lcd.print("FRIDAY ");
Serial.print("FRI ");
break;
case 6:
lcd.print("SATURDAY ");
Serial.print("SAT ");
break;
case 7:
lcd.print("SUNDAY ");
Serial.print("SUN ");
break;
}
Serial.print(monthDay);
Serial.print("/");
Serial.print(month);
Serial.print("/");
Serial.print(year);
Serial.print(" ");
Serial.print(hour);
Serial.print(":");
Serial.print(minute);
Serial.print(":");
Serial.println(second);
lcd.setCursor(10,2);
lcd.print(monthDay);
lcd.print("/");
lcd.print(month);
lcd.print("/");
lcd.print(year);
lcd.print(" ");
lcd.setCursor(0,3);
lcd.print(hour);
lcd.print(":");
lcd.print(minute);
lcd.print(":");
if ((second) < 10)
{
lcd.print("0");
};
lcd.print(second);
lcd.print(" ");
}
I got my hands on an other RTC module which is the same type, but it was working! So my problem was at all time that the original RTC was broken
Crap. But I don't know what could gone wrong in it? The eeprom or the IC maybe, but nothin other stuff.