ds 1307 memory

Hi! I'd like you to help me out with storing a number of 5 digits for my alarm-clock project. 4 digits for the time, and 1 for on/off alarm state. Is there any piece of code that could help me out? Thanks!

Try Googling "DS1307 alarm clock code ardiono". I got over 16000 hits. Surely one of them will be helpful.

I'm sorry for bothering you again, but i couldn't find what i needed. At what adress do i have to write the alarm number? Here's the code for storing time and date into the rtc eprom.

void set_date()

void get_date()
  Wire.write(3);//set register to 3 (day)
  Wire.requestFrom(104, 4); //get 5 bytes(day,date,month,year,control);
  day   = bcdToDec(Wire.read());
  date  = bcdToDec(Wire.read());
  month = bcdToDec(Wire.read());
  year  = bcdToDec(Wire.read());

I'm not aware of anything in the DS1307 dedicated to setting an alarm. You need to store the target values for the alarm in variables (globals or statics) and then compare those to what the RTC is telling you. Also, when reading the clock, it is more common to use code like:

  Wire.beginTransmission(RTCI2CADDRESS);  // Send out the RTC device address on the bus
  Wire.write(0);                          // Reset the Time Keeper register pointer
  result = Wire.endTransmission();
  if (result)                             // Non-zero means we couldn't write to the chip

  sentBack = Wire.requestFrom(RTCI2CADDRESS, 7);  // Ask for all 7 data bytes
  if (sentBack == 0)                              // It didn't like that request...

Note how sentBack makes sure we read the data. Your code would follow the snippet above and check to see if it's time to trigger the alarm. Also, the statement:

 Wire.requestFrom(104, 4); //get 5 bytes(day,date,month,year,control);

has a comment that is misleading...usually not a good idea.

Well, it didn't work... so i used arduino's EEPROM. Is there a problem setting the alarm every day, and writing to the EEPROM memory?

Well, it didn't work

Well, we don't have a clue what "it " is. Post all of your code so we can compile it ourselves.

I believe the DS1307 does have alarms, but as far as I can remember its only one or two To get the alarm feature you need the DS1337. Apparently the 1307 only has the square wave output capability. Not only you have to program the alarm, you also have to define the SQ pin as an output for the alarm. It is active low.

Not sure about library, I usually read the datasheet and send the required commands using the wire library. You will take some time to get to terms with that but the exercise is worth it. Pretty much everything works similarly if you want to communicate with any other I2C device.

@casemod: I looked up the DS1307 data sheet and it doesn't mention anything about alarm capability. Do you have a spec that details the alarm function?

Right, I had to check that up.

The DS1307 does infact not have any alarms. The version with the alarms is the DS1337!