Reply to topic  [ 35 posts ]  Go to page Previous  1, 2, 3, 4  Next
DS1302 Real Time Clock Module (HCMODU0035) 
Author Message
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 658
Post Re: DS1302 Real Time Clock Module (HCMODU0035)
I have moved your last post to the general discussions forum as it was getting a bit off topic for this thread.

The reason why you are getting these errors is because you need to install the library that is in the first post of this thread. A guide on how to do this is available on the official Arduino website here:

http://arduino.cc/en/Guide/Libraries

I would recommend using the manual install method.

_________________
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.


Fri Dec 13, 2013 2:23 pm
Profile

Joined: Thu Dec 12, 2013 7:58 am
Posts: 35
Post Re: DS1302 Real Time Clock Module (HCMODU0035)
that is done now installed but i have nothing but squares on my led screen


Fri Dec 13, 2013 3:12 pm
Profile

Joined: Thu Dec 12, 2013 7:58 am
Posts: 35
Post Re: DS1302 Real Time Clock Module (HCMODU0035)
if i put in example from library i get a time and date up, here is what i put in
Quote:
// DS1302_LCD (C)2010 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// A quick demo of how to use my DS1302-library to make a quick
// clock using a DS1302 and a 16x2 LCD.
//
// I assume you know how to connect the DS1302 and LCD.
// DS1302: CE pin -> Arduino Digital 2
// I/O pin -> Arduino Digital 3
// SCLK pin -> Arduino Digital 4
// LCD: DB7 -> Arduino Digital 6
// DB6 -> Arduino Digital 7
// DB5 -> Arduino Digital 8
// DB4 -> Arduino Digital 9
// E -> Arduino Digital 10
// RS -> Arduino Digital 11

#include <LiquidCrystal.h>
#include <DS1302.h>

// Init the DS1302
DS1302 rtc(26, 24, 22);

// Init the LCD
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup()
{
// Set the clock to run-mode, and disable the write protection
rtc.halt(false);
rtc.writeProtect(false);

// Setup LCD to 16x2 characters
lcd.begin(16, 2);

// The following lines can be commented out to use the values already stored in the DS1302
rtc.setDOW(FRIDAY); // Set Day-of-Week to FRIDAY
rtc.setTime(12, 0, 0); // Set the time to 12:00:00 (24hr format)
rtc.setDate(6, 8, 2010); // Set the date to August 6th, 2010
}

void loop()
{
// Display time centered on the upper line
lcd.setCursor(4, 0);
lcd.print(rtc.getTimeStr());

// Display abbreviated Day-of-Week in the lower left corner
lcd.setCursor(0, 1);
lcd.print(rtc.getDOWStr(FORMAT_SHORT));

// Display date in the lower right corner
lcd.setCursor(6, 1);
lcd.print(rtc.getDateStr());

// Wait one second before repeating :)
delay (1000);
}


Fri Dec 13, 2013 3:41 pm
Profile

Joined: Thu Dec 12, 2013 7:58 am
Posts: 35
Post Re: DS1302 Real Time Clock Module (HCMODU0035)
here is my final code to test clock may keep it to use later, made a few changes showing how it is connected for mega board and keypad shield
Code:
// DS1302_LCD (C)2010 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// DS1302:  RST pin   -> Mega 2560 pin 26
//          I/O pin   -> pin 24
//          SCK pin   -> pin  22
// LCD: Keypad shield 6 button
//   DB7       -> Mega 2560 pin 7
//   DB6       -> Mega 2560 pin 6
//   DB5       -> Mega 2560 pin 5
//   DB4       -> Mega 2560 pin 4
//   E         -> Mega 2560 pin 9
//   RS        -> Mega 2560 pin 8
//   Backlite  -> Mega 2560 pin 10



#include <LiquidCrystal.h>
#include <DS1302.h>


DS1302 rtc(26, 24, 22);  // Init the DS1302
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);  // Init the LCD

void setup()
{
 
  rtc.halt(false);   // Set the clock to run-mode, and disable the write protection
  rtc.writeProtect(false);
 
  lcd.begin(16, 2);   // Setup LCD to 16x2 characters

// to first set up clock remove the slashes in lines below, once set put them back to use internal clock time
 // rtc.setDOW(SUNDAY);        // Set Day-of-Week to SUNDAY
  //rtc.setTime(12, 0, 0);     // Set the time to 12:00:00 (24hr format)
 // rtc.setDate(15, 12, 2013);   // Set the date to December 15th, 2013
}

void loop()
{
  lcd.setCursor(6, 0);    // Display time on the upper line
  lcd.print(rtc.getTimeStr());
 
  lcd.setCursor(1, 0);   // Display abbreviated Day-of-Week in the upper left corner
  lcd.print(rtc.getDOWStr(FORMAT_SHORT));
 
  lcd.setCursor(5, 1);   // Display date in the lower right corner
  lcd.print(rtc.getDateStr());

 
  delay (1000);   // Wait one second before repeating :)
}


Sun Dec 15, 2013 5:07 pm
Profile

Joined: Thu Dec 12, 2013 7:58 am
Posts: 35
Post Re: DS1302 Real Time Clock Module (HCMODU0035)
if i have a program that uses a 1307 rtc can i use a 1302 rtc or do i need to use a 1307


Tue Dec 17, 2013 8:19 am
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 658
Post Re: DS1302 Real Time Clock Module (HCMODU0035)
No they use different controller chips so a 1307 library won't work with a 1302 and vice versa. We do have libraries for both versions on this forum though.

_________________
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.


Tue Dec 17, 2013 10:44 am
Profile

Joined: Mon Mar 17, 2014 5:13 pm
Posts: 1
Post Re: DS1302 Real Time Clock Module (HCMODU0035)
Hi, the battery on my RTC module has gone flat so it's forgetting the time whenever I unplug my Arduino. Is there any additional code I need to add to enable trickle charging or might there be another issue?
Thanks


Mon Mar 17, 2014 5:16 pm
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 658
Post Re: DS1302 Real Time Clock Module (HCMODU0035)
The trickle charging option is off by default and can be turned on via a register access but please keep in mind that the battery supplied with these modules is not rechargeable.

_________________
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.


Mon Mar 17, 2014 6:50 pm
Profile

Joined: Tue Jan 14, 2014 4:25 pm
Posts: 12
Post Re: DS1302 Real Time Clock Module (HCMODU0035)
hi andrew have uploaded code and when i view serial info i get 2 diffrent readings printed one the correct time which i have put in listing and a old time setting how do i get rid of the old time? it seems to read correct time then a old one from some where


Thu Nov 06, 2014 3:46 pm
Profile
Site Admin

Joined: Sun Aug 05, 2012 4:15 pm
Posts: 658
Post Re: DS1302 Real Time Clock Module (HCMODU0035)
Which sketch are you using, is it the one in the first post of this thread written by us or something else?

_________________
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.


Fri Nov 07, 2014 9:52 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 35 posts ]  Go to page Previous  1, 2, 3, 4  Next

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Thank you to phpBB.com & phpBB.ro.
Design created by Florea Cosmin Ionut.
© 2011 All contents of this site are © Hobby Components LTD