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 » Fri Dec 20, 2013 3:47 pm

normski001 wrote: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
I have already done that yesterday see 2 posts above the picture,
are you saying i have purchased a screen that will not post the time from a DS1307 RTC

andrew
Site Admin
Posts: 1380
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 5:25 pm

No the screen is independent of the RTC module and just displays whatever you send to it. The reason why I needed you to confirm that the RTC is working with our own library is because your setup was getting a little confusing what with having two types of RTC module and different libraries. I have tried the sketch you have posted with the appropriate library and I get the same thing. As we have established that the DS1307 module does work, then this now points to a problem with the henningkarlsen library. Unfortunately as we didn't write this library it is difficult for us to debug it but my suspicion would be that it assumes the module is on a different I2C address. I have quickly mashed together our LCD keypad shield example together with our DS1307 RTC example that uses our own library:

Code: Select all

/* Include the wire library */
#include "Wire.h"
/* Include the Hobby Components RTC library */
#include <HCRTC.h>

/* Define the I2C addresses for the RTC and EEPROM */
#define I2CDS1307Add 0x68

/* Include the standard LiquidCrystal library */
#include <LiquidCrystal.h>


/* DIO pin definitions */
#define LCD_DATA4 4         /* LCD data DIO pin 4 */
#define LCD_DATA5 5         /* LCD data DIO pin 5 */
#define LCD_DATA6 6         /* LCD data DIO pin 6 */
#define LCD_DATA7 7         /* LCD data DIO pin 7 */
#define LCD_RESET 8         /* LCD Reset DIO pin */
#define LCD_ENABLE 9        /* LCD Enable DIO pin */
#define LCD_BACKLIGHT 10    /* LCD backlight DIO pin */


/* Initialise the LiquidCrystal library with the correct DIO pins */
LiquidCrystal lcd(LCD_RESET, LCD_ENABLE, LCD_DATA4, LCD_DATA5, LCD_DATA6, LCD_DATA7);


/* Used in example as an index pointer */
byte index;

/* Create an instance of HCRTC library */
HCRTC HCRTC;


void setup()
{
  Serial.begin(9600);
  
  /* Use the RTCWrite library function to set the time and date. 
     Parameters are: I2C address, year, month, date, hour, minute, second, 
     day of week */
  HCRTC.RTCWrite(I2CDS1307Add, 13, 4, 24, 14, 21, 0, 3);
  
   /* Set the correct display size (16 character, 2 line display) */
  lcd.begin(16, 2); 
}

void loop()
{
 
  /* Continuously read the current time and date from the RTC */ 
  while(true)
  {
    
    /* Read the current time from the RTC module */
    HCRTC.RTCRead(I2CDS1307Add);
    
    lcd.setCursor(0,0); 
    lcd.print("Seconds:");
  
    lcd.setCursor(0,1); 
    lcd.print(HCRTC.GetSecond());
  
    /* Wait a second before reading again */
    delay(1000);  
  }
}

This is a very basic sketch that will output the 'second' reading from the DS1307 and display it on the LCD. This will at least confirm that your setup is fine (which it appears to be) and give you and idea on how to do this using our library.
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 6:17 pm

it gets to 60 seconds then starts at 9 again and jumps all over. but as you said it was a fast fix.
is there anywhere i can get a library and sketch that will work with the clock please, i have spent 3 days now looking for one.

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

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

Post by andrew » Sat Dec 21, 2013 6:31 pm

I'll have a look to see if there are any example sketches. Failing this I'll add to the code I posted before but please bear with us as this is a very busy time for us.
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 » Mon Dec 23, 2013 11:09 am

i found some code that got it working on the mega the only problem now is with the poor breadboard and wires dont seem to match each other very loose fit, if i touch a wire clock numbers go crazy.
i have just been to maplin and got a proto type board so will hardwire what i can.
got one program done will post info on my other thread,

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

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

Post by andrew » Mon Dec 23, 2013 12:02 pm

I've just uploaded an updated version of our library. This now includes two new functions which will return the time and date in a formatted form that makes it easy to output to a serial terminal or LCD display. There is also a new example sketch included with the library that will demonstrate how to use them with an LCD display.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

pocketmoon
Posts: 7
Joined: Thu Dec 26, 2013 11:32 pm

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

Post by pocketmoon » Mon Jan 13, 2014 10:56 pm

Hi,

I recently ordered 3 of these are 2 work fine but I was having bizarre problems with the 3rd - failing to set or read the time. After some real head scratching I checked the batteries. Two measure around 3v but the 3rd measures 4v! I swapped a ~3v battery into the problem module and it works (sets time, reads time, keeps time when unplugged). I took the battery out, and it works (set/read time on USB power via arduino although of course doesn't retain time without the battery). Put the 4v battery back in and 'splat' - it breaks.

Does this sound like a faulty module or a dodgy battery ?! Max Bat is 3.5 in the datasheets and it sounds like the unit only recognises inputs when "recognizes inputs when VCC is greater than 1.25 x VBAT"

So on a 4v battery and a 5v power supply that's marginal and may explain why the module does work. If that sounds sensible can you get a replacement battery out to me ?

Cheers

Rob James

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

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

Post by andrew » Tue Jan 14, 2014 12:26 pm

This is a little puzzling as the voltages sound fine. LIR2032's can have a battery voltage in excess of 4V when at full capacity. However this quickly drops off to its nominal voltage after the battery is drained slightly. Its actually quite normal to measure 4V across the battery if at full charge. The battery isn't directly connected to the DS1307, i.e you shouldn't expect to see the battery voltage at the Vbat pin. It is actually connected to the Vbat pin via a 3/4 potential divider. Therefore you should see around 2.8V on the Vbat pin for a fully charged battery (4V * 3/4 - a little for loading effect of the Vbat pin). This is less than the Vbat fail voltage of 3.75V so I don't think this should be the problem.

So it's not obvious to me what the actual problem is. If possible could you try measuring the Vbat pin with and without the 5V Vcc connected. It would be interesting to see what voltages you measure. On a working module they should be around 2.8V give or take for a 4V battery.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

pocketmoon
Posts: 7
Joined: Thu Dec 26, 2013 11:32 pm

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

Post by pocketmoon » Tue Jan 14, 2014 7:09 pm

Ah! I just noticed I've been driving the RTC off of 3.3v (from an adafruit trinket) rather than 5v usb! Doh!

With the fresh "4v" battery back in I get 2.8v across bat/gnd and the module doesn't work. Pop back in a 3v cell and I get 2.1 across bat/gnd and the clock works fine. The other two modules measure 2.2/2.1 and also work.

So in my case VBat (2.8v) is too close the V++ in order to wake up the RTC :) Sorted!

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

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

Post by andrew » Wed Jan 15, 2014 11:23 am

That would explain it. It may also explain why the voltage on your other two batteries are a little low as they wouldn't be charging properly. I'll look at adding some pinout information to the first post.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Post Reply

Return to “RTC”