Tiny RTC DS1307 + 24C32 Real Time Clock Module (HCMODU0011)

Real Time Clock modules for microcontrollers
normski001
Posts: 35
Joined: Thu Dec 12, 2013 7:58 am

Re: Tiny RTC DS1307 + 24C32 Real Time Clock Module (HCMODU00

Post by normski001 » Thu Dec 19, 2013 9:19 am

when i run the example program that comes with DS1307 folder i get something strange.
here is what i run

Code: Select all

// DS1307_LCD (C)2010 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// A quick demo of how to use my DS1307-library to make a quick
// clock using a DS1307 and a 16x2 LCD.
//
// I assume you know how to connect the DS1307 and LCD.
// DS1302:  SDA pin   -> Arduino Digital 4
//          SCL pin   -> Arduino Digital 5
// 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 <DS1307.h>

// Init the DS1307
DS1307 rtc(20, 21);

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

void setup()
{
  // Set the clock to run-mode
  rtc.halt(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 DS1307
  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(3, 10, 2010);   // Set the date to October 3th, 2010

  // Set SQW/Out rate to 1Hz, and enable SQW
  rtc.setSQWRate(SQW_RATE_1);
  rtc.enableSQW(true);
}

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);
}

and on the screen i get
middle of first line 27:85:85
bottom line XXX 85.85.2165

i think some think is being kept in memory somewhere as this is part of the screen from the program i put in the other day .
can the memory be cleared or it this just coincidence,
i have just checked the 1302 clock and i get the same as above when i run the clock program that worked before.

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: Tiny RTC DS1307 + 24C32 Real Time Clock Module (HCMODU00

Post by andrew » Thu Dec 19, 2013 12:11 pm

You are probably seeing that odd date and time because the software is unable to read the actual time out of the RTC for some reason. Can you try the example sketch in the first post of this thread with your DS1307. This was written by us and will help debug your connections and rule out any complications with the other code.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

normski001
Posts: 35
Joined: Thu Dec 12, 2013 7:58 am

Re: Tiny RTC DS1307 + 24C32 Real Time Clock Module (HCMODU00

Post by normski001 » Thu Dec 19, 2013 12:47 pm

i loaded the button test program first so i had the seconds running, then i loaded the sketch on the first post as you asked.
the sketch say,s after loading in white at bottom black screen "binary sketch size: 7,336 byets of a (258,048 byte maximum)"

the seconds counter has stopped running but screen still shows original screen

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: Tiny RTC DS1307 + 24C32 Real Time Clock Module (HCMODU00

Post by andrew » Thu Dec 19, 2013 4:15 pm

I think I should have explained a little better how to use this sketch. The sketch in the first post of this thread is just to test the DS1307 module and doesn't include any code for the LCD screen. You can see the output from this sketch by clicking on the magnifying glass in the top right hand corner of the sketch window. This will open a new window which is a serial terminal. It will display anything output from the serial port of your Arduino board. Make sure that the number in the bottom right hand corner of this new window says 9600 which is the serial communication speed that the sketch uses. If everything is working correctly with the module you should see a time and date incrementing once every second.

If this is the case then you know that your DS1307 module is connected correctly and the problem must be elsewhere.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

normski001
Posts: 35
Joined: Thu Dec 12, 2013 7:58 am

Re: Tiny RTC DS1307 + 24C32 Real Time Clock Module (HCMODU00

Post by normski001 » Thu Dec 19, 2013 4:55 pm

in serial monitor it says 24/4/13 14:22:38 DOW3
ant then it increases by 1 second a time.
so how do i get that to show on the screen

normski001
Posts: 35
Joined: Thu Dec 12, 2013 7:58 am

Re: Tiny RTC DS1307 + 24C32 Real Time Clock Module (HCMODU00

Post by normski001 » Thu Dec 19, 2013 5:29 pm

i now have the old clock working again it seems the pins on the wires are not making contact with the breadboard if i move them gently the time changes
i will now try the 1307 clock again, i had to fit the 1302 direct to the arduino to get it to run smooth.

normski001
Posts: 35
Joined: Thu Dec 12, 2013 7:58 am

Re: Tiny RTC DS1307 + 24C32 Real Time Clock Module (HCMODU00

Post by normski001 » Thu Dec 19, 2013 7:48 pm

still cannot get the ds1307 to work with the lcd
any help would be good please andrew
i have run tests in the 1307 sample folder from the library, here are results if it helps
Image

Ram Test

Image

serial easy

Image

serial hard

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: Tiny RTC DS1307 + 24C32 Real Time Clock Module (HCMODU00

Post by andrew » Fri Dec 20, 2013 11:13 am

That is definitely a sign that the software can't communicate with the module for some reason. Can you describe how you currently have the module connected to your Mega? I.e. what pin is connected to what.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

normski001
Posts: 35
Joined: Thu Dec 12, 2013 7:58 am

Re: Tiny RTC DS1307 + 24C32 Real Time Clock Module (HCMODU00

Post by normski001 » Fri Dec 20, 2013 11:24 am

i am connected in to P2 on the clock
Gnd to gnd to end of digital pin slot,
Vcc to +5 top of digital pin slot,
SDA to pin 20
scl to pin 21
on the mega 2560 board

andrew
Site Admin
Posts: 1374
Joined: Sun Aug 05, 2012 4:15 pm

Re: Tiny RTC DS1307 + 24C32 Real Time Clock Module (HCMODU00

Post by andrew » Fri Dec 20, 2013 3:35 pm

The pin connections are correct for a mega but the library on this forum doesn't have any example programs that would output what's in the the screen captures in your previous post. Can you confirm that you have the HCRTC library available in the first post of this forum, and that you have run the example sketch also in the first post. It is important to start with this library and sketch as it was written to work with the module you have and so will help confirm that you have a working module and your setup is ok.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Post Reply

Return to “RTC”