ChronoDot (Adafruit) use with Teensy 2++ ?

Status
Not open for further replies.

tdg8934

Active member
Has anyone used this ChronoDot with the Teensy 2++ (Teensyduino software)?

http://www.adafruit.com/products/255
http://docs.macetech.com/doku.php/chronodot

I connected:
ChronoDot GND to pin Teensy 2++ (GND)
ChronoDot VCC to pin Teensy 2++ (+5V)
ChronoDot SCL to pin Teensy 2++ (pin 0) I Didn't see SCL pin for Teensyduino pinouts (just for C language pinouts)?
ChronoDot SDA to pin Teensy 2++ (pin 1) I Didn't see SDA pin for Teensyduino pinouts (just for C language pinouts)?

All of the examples I saw did not show any 4.7K or 10K resistors soldered in for R1, R2 on the ChronoDot. The DS1307 uses 2.2K and this uses 4.7K or 10K? Confusing?? I did not solder in any resistors into the ChronoDot yet.

Is this correct? I bring up the Serial Monitor (set at 9600) and see nothing happening. Resistors maybe? Which ones if any?

Used this example code from the Macetech site:

#include <Wire.h>

void setup()
{
Wire.begin();
Serial.begin(9600);

// clear /EOSC bit
// Sometimes necessary to ensure that the clock
// keeps running on just battery power. Once set,
// it shouldn't need to be reset but it's a good
// idea to make sure.
Wire.beginTransmission(0x68); // address DS3231
Wire.send(0x0E); // select register
Wire.send(0b00011100); // write register bitmap, bit 7 is /EOSC
Wire.endTransmission();
}

void loop()
{
// send request to receive data starting at register 0
Wire.beginTransmission(0x68); // 0x68 is DS3231 device address
Wire.send(0); // start at register 0
Wire.endTransmission();
Wire.requestFrom(0x68, 3); // request three bytes (seconds, minutes, hours)

while(Wire.available())
{
int seconds = Wire.receive(); // get seconds
int minutes = Wire.receive(); // get minutes
int hours = Wire.receive(); // get hours

seconds = (((seconds & 0b11110000)>>4)*10 + (seconds & 0b00001111)); // convert BCD to decimal
minutes = (((minutes & 0b11110000)>>4)*10 + (minutes & 0b00001111)); // convert BCD to decimal
hours = (((hours & 0b00110000)>>4)*10 + (hours & 0b00001111)); // convert BCD to decimal (assume 24 hour mode)

Serial.print(hours); Serial.print(":"); Serial.print(minutes); Serial.print(":"); Serial.println(seconds);
}

delay(1000);
}
 
You will need pullup resistors, yes. 10k is probably a maximum (beyond that, a square wave is too rounded off to be recognised as digital) and 1k a minimum (or the current becomes too much and you get DC offset on the 0V edge).

Have a look at the waveforms with different values of I2C pullup resistors here. Based on that page, I tend to use 2k2.
 
ChronoDot SCL to pin Teensy 2++ (pin 0) I Didn't see SCL pin for Teensyduino pinouts (just for C language pinouts)?
ChronoDot SDA to pin Teensy 2++ (pin 1) I Didn't see SDA pin for Teensyduino pinouts (just for C language pinouts)?

I believe that on the Teensy ++ 2.0 (40 pin) SCL is A5 (43)(physical pin 23) and SDA is A4 (42) (physical pin 24):cool:


// DS1307_Serial_Hard (C)2010 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// A quick demo of how to use my DS1307-library to
// retrieve time- and date-data for you to manipulate.
//
// I assume you know how to connect the DS1307.
// DS1307: SDA pin -> Arduino Digital 4
// SCL pin -> Arduino Digital 5
// Needs 4.7k pullups

// CODE WORKS FINE ON TEENSY++
// This code bypasses the arduino wire library !!!!

#include <DS1307.h>

// Init the DS1307
DS1307 rtc(42, 43); // <---------------------------<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

// Init a Time-data structure
Time t;


int run_led = 6;

void setup()
{

// initialize the digital pin as an output.
pinMode(run_led, OUTPUT);
// Set the clock to run-mode
rtc.halt(false);

// Setup Serial connection
Serial.begin(9600);

// The following lines can be commented out to use the values already stored in the DS1307 <-------------<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
//rtc.setDOW(THURSDAY); // Set Day-of-Week to THURSDAY
//rtc.setTime(22, 16, 0); // Set the time to 12:00:00 (24hr format)
//rtc.setDate(27, 9, 2012); // Set the date to 27 Sept 2012
}

void loop()
{
digitalWrite(run_led, HIGH); // turn the LED on (HIGH is the voltage level)
// Get data from the DS1307
t = rtc.getTime();

// Send date over serial connection
Serial.print("Today is the ");
Serial.print(t.date, DEC);
Serial.print(". day of ");
Serial.print(rtc.getMonthStr());
Serial.print(" in the year ");
Serial.print(t.year, DEC);
Serial.println(".");

// Send Day-of-Week and time
Serial.print("It is the ");
Serial.print(t.dow, DEC);
Serial.print(". day of the week (counting monday as the 1th), and it has passed ");
Serial.print(t.hour, DEC);
Serial.print(" hour(s), ");
Serial.print(t.min, DEC);
Serial.print(" minute(s) and ");
Serial.print(t.sec, DEC);
Serial.println(" second(s) since midnight.");

// Send a divider for readability
Serial.println(" - - - - - - - - - - - - - - - - - - - - -");

// Wait one second before repeating :)

digitalWrite(run_led, LOW); // turn the LED off by making the voltage LOW
delay (1000);
}




I did not solder in any resistors into the ChronoDot yet.

Just install the two 4.7K on the Chronodot and you will be fine.
 
Last edited:
It says on the C Language pinout that pins 0 and 1 are SCL and SDA. The Arduino language pinout does not list SCL and SDA. However pins 42 (A4) and pins 43 (A5) work for the ChronoDot and intermitantly for the DS1307. I am using 4.7K resistors on the DS1307 circuit and CR2032 battery. On the ChronoDot I am using 2.2K resistors and 3v battery. Could this be a problem?

Here is the working Teensy 2++ code for the ChronoDot and somewhat for the DS1307:

// DS1307_Serial_Easy (C)2010 Henning Karlsen
// Modified slightly for Teensy 2++ by Tim Gilmore
//
// web: http://www.henningkarlsen.com/electronics
//
// A quick demo of how to use my DS1307-library to
// quickly send time and date information over a serial link
//
// I assume you know how to connect the DS1307.
// DS1307: SDA pin -> Arduino Analog In 4
// SCL pin -> Arduino Analog In 5

#include <DS1307.h>

// Init the DS1307
//DS1307 rtc(4, 5); // Arduino pins here

DS1307 rtc(42, 43); // Teensy 2++ pins here

// Same pins for use with ChronoDot as with DS1307
// DS1307 pin 1 and 2 to the crystal (32.768 KJz)
// DS1307 pin 3 to (+) on 3vdc battery
// DS1307 pin 4 to GND and (-) on 3vdc battery
// DS1307 pin 5 (SDA) to pin 42 (A4) on Teensy 2++
// DS1307 pin 6 (SCL) to pin 43 (A5) on Teensy 2++
// DS1307 pin 8 to +5V on Teensy 2++

void setup()
{
// Set the clock to run-mode
rtc.halt(false);

// Setup Serial connection
Serial.begin(9600);

// 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
}

void loop()
{
// Send Day-of-Week
Serial.print(rtc.getDOWStr());
Serial.print(" ");

// Send date
Serial.print(rtc.getDateStr());
Serial.print(" -- ");

// Send time
Serial.println(rtc.getTimeStr());

// Wait one second before repeating :)
delay (1000);
}
 
I am using 4.7K resistors on the DS1307 circuit and CR2032 battery. On the ChronoDot I am using 2.2K resistors and 3v battery. Could this be a problem?

I'm guessing that you didn't follow the link I posted earlier about resistor values for I2C.

Here is the working Teensy 2++ code for the ChronoDot and somewhat for the DS1307:
Please wrap your code in code tags (it's the # button on the toolbar).
 
I didn't see a # button on the toolbar until now when I clicked on 'Advanced' at the bottom:

Code:
// DS1307_Serial_Easy (C)2010 Henning Karlsen
 // Modified slightly for Teensy 2++ by Tim Gilmore
 //
 // web: http://www.henningkarlsen.com/electronics
 //
 // A quick demo of how to use my DS1307-library to 
// quickly send time and date information over a serial link
 //
 // I assume you know how to connect the DS1307.
 // DS1307: SDA pin -> Arduino Analog In 4
 // SCL pin -> Arduino Analog In 5
 
#include <DS1307.h>
 
// Init the DS1307
 //DS1307 rtc(4, 5); // Arduino pins here
 
DS1307 rtc(42, 43); // Teensy 2++ pins here
 
// Same pins for use with ChronoDot as with DS1307
 // DS1307 pin 1 and 2 to the crystal (32.768 KJz)
 // DS1307 pin 3 to (+) on 3vdc battery
 // DS1307 pin 4 to GND and (-) on 3vdc battery
 // DS1307 pin 5 (SDA) to pin 42 (A4) on Teensy 2++
 // DS1307 pin 6 (SCL) to pin 43 (A5) on Teensy 2++
 // DS1307 pin 8 to +5V on Teensy 2++
 
void setup()
 {
 // Set the clock to run-mode
 rtc.halt(false);

 // Setup Serial connection
 Serial.begin(9600);
 
// 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
 }
 
void loop()
 {
 // Send Day-of-Week
 Serial.print(rtc.getDOWStr());
 Serial.print(" ");

 // Send date
 Serial.print(rtc.getDateStr());
 Serial.print(" -- ");
 
// Send time
 Serial.println(rtc.getTimeStr());

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

I did take a look at the link and saw how the shape of the squarewaves were affected by the resistor values used.
 
However pins 42 (A4) and pins 43 (A5) work for the ChronoDot

Good, glad you got it working for the ChronoDot because it works perfect for me. Finding the proper library is the key. Do not use this same library on the Teensy 3. :cool:
 
What I found out is these somewhat thin (28 gauge?) wires from adafruit (http://www.adafruit.com/products/153) don't always keep good contact with solderless breadboards creating intermittant contact. I found that using 22 gauge wire from radio shack holds a better contact and solved my problem with the DS1307.

Both the DS1307 and ChronoDot RTC work now. I did use 2.2K resistors with both RTC's if that makes any difference compared to using 4.7K.

Thanks to all your help!
 
Right now, your default I2C clock rate is 100 Khz but if you want 400 khz (4x), on your high speed ChronoDot, you would need to change the library default setting and adjust the pullups to a higher value. This will not work for the 100 Khz only DS1307.
 
Good, glad you got it working for the ChronoDot because it works perfect for me. Finding the proper library is the key. Do not use this same library on the Teensy 3.

t3andy,

You mention finding the proper library is the key and not to use the same library on the Teensy 3. We'll I have gone back to the Teensy 2++ as my Teensy 3 got damaged from soldering. What library are you refering to on this? Just so that we are on the same page.

Thanks,

Tim
 
I tried to look up on the datasheet about the 400 KHz speed and not much was listed. What benefits does it provide you? What file do I change in the library default setting (Teensy 2++) if you can tell me?

Thanks,

Tim
 
What benefits does it provide you?
If you can complete your code execution 4x faster using the DS3231 ChronoDot. To some users this is not an issue.;)
BTW ... inspect the library cpp for the speed change. <---- correction disreguard

Correction: 11/29/12 15:22
Note: This special DS1307 library bypasses the wire.h therefore you cannot adjust the I2C speed.;)
You need to find another RTC library that uses "wire.h" then adjust in the wire.cpp in lines about 56-65?
 
Last edited:
t3andy,

Its been a while since I have done any C related programming as I'm trying to get back into it again with the Teensyduino software for the Teensy 2++. Can you tell me if there is any way to edit the library cpp as I tried it in Notepad and it was all wrapped together. Anything simple and free to use to make these modifications?

Thanks,

Tim
 
Status
Not open for further replies.
Back
Top