Sunspot Home

Arduino speaking variometer
- adding a Tiny RTC DS1307 clock board - working at last!

These are my backup project notes - please email me if interested

Objective
Add a real time clock (RTC) to the speaking variometer
- use it to time-stamp stored data of flights



Method
Another board from China that presents many problems - but it is very cheap!

I bought this one on eBay for just £1.21 delivered - less than UK local postage?
Tiny RTC I2C DS1307 AT24C32 Real Time Clock Module For Arduino AVR PIC 51 ARM

They can be bought from many suppliers.

In company with many others I could not get it to keep time on battery when the main Vcc supply was off.

tinyrtc

I fixed it by removing the components R4 R5 R6 and D1 (these charge the LIR2032 rechargeable lithium cell).
(Use copper wick de-soldering tape to suck off the solder from the surface mount components - then push them off).

I shorted R6 and fitted a standard Duracell 2032 non-rechargeable coin cell - it should last for years.

I also removed the i2c pull up resistors R2 and R3 (I am not sure if that was necessary as I did it before removing R4 etc).

The Tiny RTC needs 5 Volts i2c logic so I connected it to my 3.3v Arduino via a small FET level changer board.

This sketch was used to set the clock and prove that the power could be removed.
Load it first with this line active to set the clock then again with it commented out (//)- I will try a more advanced sketch soon that lets you adjust the date/time and test the 24C32 memory chip.
RTC.adjust(DateTime(__DATE__, __TIME__));

//Arduino with Tiny RTC I2C http://zygzax.com/?lang=en
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;

void setup () {
//Initialize the serial port, wire library and RTC module
Serial.begin(9600);
Wire.begin();
RTC.begin();
//If we remove the comment from the following line, we will set up the module time and date with the computer one
// RTC.adjust(DateTime(__DATE__, __TIME__));
}

void loop () {
DateTime now = RTC.now();
//We print the day
Serial.print(now.day(), DEC);
Serial.print('/');
//We print the month
Serial.print(now.month(), DEC);
Serial.print('/');
//We print the year
Serial.print(now.year(), DEC);
Serial.print(' ');
//We print the hour
Serial.print(now.hour(), DEC);
Serial.print(':');
//We print the minutes
Serial.print(now.minute(), DEC);
Serial.print(':');
//We print the seconds
Serial.print(now.second(), DEC);
Serial.println();
//We check the time and sent through the serial port every 3s
delay(3000);
}

 

Comments? email me