Home made ds3231 circuit failed

ds3231pcb

I made a ds3231 circuit as the following circuit, I followed the code for a regular ds3231 module for arduino and I got the following result:

I made a ds3231 RTC circuit following its datasheet. The circuit is in the following chart. I followed the code online for a regular ds3231 module and the time I have got is:

Temperature=-9999
20165-85-165 25:165:165

Temperature=-9999
20165-85-165 25:165:165
Temperature=-9999

the code is

/*
DS3231_test.pde
Eric Ayars
4/11

Test/demo of read routines for a DS3231 RTC.

Turn on the serial monitor after loading this to check if things are
working as they should.

*/

#include <DS3231.h>
#include <Wire.h>

DS3231 Clock;
bool Century=false;
bool h12;
bool PM;
byte ADay, AHour, AMinute, ASecond, ABits;
bool ADy, A12h, Apm;

byte year, month, date, DoW, hour, minute, second;

void setup() {
	// Start the I2C interface
	Wire.begin();
        Clock.setSecond(20);//Set the second 
        Clock.setMinute(44);//Set the minute 
        Clock.setHour(19);  //Set the hour 
        Clock.setDoW(6);    //Set the day of the week
        Clock.setDate(10);  //Set the date of the month
        Clock.setMonth(7);  //Set the month of the year
        Clock.setYear(21);  //Set the year (Last two digits of the year)
	// Start the serial interface
	Serial.begin(9600);
}
void ReadDS3231()
{
  int second,minute,hour,date,month,year,temperature; 
  second=Clock.getSecond();
  minute=Clock.getMinute();
  hour=Clock.getHour(h12, PM);
  date=Clock.getDate();
  month=Clock.getMonth(Century);
  year=Clock.getYear();
  
  temperature=Clock.getTemperature();
  
  Serial.print("20");
  Serial.print(year,DEC);
  Serial.print('-');
  Serial.print(month,DEC);
  Serial.print('-');
  Serial.print(date,DEC);
  Serial.print(' ');
  Serial.print(hour,DEC);
  Serial.print(':');
  Serial.print(minute,DEC);
  Serial.print(':');
  Serial.print(second,DEC);
  Serial.print('\n');
  Serial.print("Temperature=");
  Serial.print(temperature); 
  Serial.print('\n');
}
void loop() {ReadDS3231();delay(1000);
	// send what's going on to the serial monitor.
	// Start with the year
/*	Serial.print("2");
	if (Century) {			// Won't need this for 89 years.
		Serial.print("1");
	} else {
		Serial.print("0");
	}
	Serial.print(Clock.getYear(), DEC);
	Serial.print('-');
	// then the month
	Serial.print(Clock.getMonth(Century), DEC);
	Serial.print('-');
	// then the date
	Serial.print(Clock.getDate(), DEC);
	Serial.print(' ');*/
	// and the day of the week
	/*Serial.print(Clock.getDoW(), DEC);
	Serial.print(' ');*/
	// Finally the hour, minute, and second
	/*Serial.print(Clock.getHour(h12, PM), DEC);
	Serial.print(':');
	Serial.print(Clock.getMinute(), DEC);
	Serial.print(':');
	Serial.print(Clock.getSecond(), DEC);
	// Add AM/PM indicator
	if (h12) {
		if (PM) {
			Serial.print(" PM ");
		} else {
			Serial.print(" AM ");
		}
	} else {
		Serial.print(" 24h ");
	}
	// Display the temperature
	Serial.print("T=");
	Serial.print(Clock.getTemperature(), 2);
	// Tell whether the time is (likely to be) valid
	if (Clock.oscillatorCheck()) {
		Serial.print(" O+");
	} else {
		Serial.print(" O-");
	}*/
	// Indicate whether an alarm went off
	/*if (Clock.checkIfAlarm(1)) {
		Serial.print(" A1!");
	}
	if (Clock.checkIfAlarm(2)) {
		Serial.print(" A2!");
	}*/
	// New line on display
	//Serial.print('\n');
       // delay(1000);
	// Display Alarm 1 information
/*	Serial.print("Alarm 1: ");
	Clock.getA1Time(ADay, AHour, AMinute, ASecond, ABits, ADy, A12h, Apm);
	Serial.print(ADay, DEC);
	if (ADy) {
		Serial.print(" DoW");
	} else {
		Serial.print(" Date");
	}
	Serial.print(' ');
	Serial.print(AHour, DEC);
	Serial.print(' ');
	Serial.print(AMinute, DEC);
	Serial.print(' ');
	Serial.print(ASecond, DEC);
	Serial.print(' ');
	if (A12h) {
		if (Apm) {
			Serial.print('pm ');
		} else {
			Serial.print('am ');
		}
	}
	if (Clock.checkAlarmEnabled(1)) {
		Serial.print("enabled");
	}
	Serial.print('\n');
	// Display Alarm 2 information
	Serial.print("Alarm 2: ");
	Clock.getA2Time(ADay, AHour, AMinute, ABits, ADy, A12h, Apm);
	Serial.print(ADay, DEC);
	if (ADy) {
		Serial.print(" DoW");
	} else {
		Serial.print(" Date");
	}
	Serial.print(' ');
	Serial.print(AHour, DEC);
	Serial.print(' ');
	Serial.print(AMinute, DEC);
	Serial.print(' ');
	if (A12h) {
		if (Apm) {
			Serial.print('pm');
		} else {
			Serial.print('am');
		}
	}
	if (Clock.checkAlarmEnabled(2)) {
		Serial.print("enabled");
	}*/
	/* display alarm bits
	Serial.print('\n');
	Serial.print('Alarm bits: ');
	Serial.print(ABits, DEC);
	*/
/*
	Serial.print('\n');
	Serial.print('\n');
	delay(1000);

	// Display the time once more as a test of the getTime() function
	Clock.getTime(year, month, date, DoW, hour, minute, second);
	
        Serial.print(year, DEC);
        Serial.print("/");
	Serial.print(month, DEC);
        Serial.print("/");
	Serial.print(date, DEC);
        Serial.print("day of the week :");
	Serial.println(DoW, DEC);
	Serial.print(hour, DEC);
        Serial.print(":");
	Serial.print(minute, DEC);
        Serial.print(":");
	Serial.println(second, DEC);*/
}

Other i2c devices on the same i2c wires are working fine.

I found there is an eeprom chip in a regular ds3231 module, but didn;t find one in the example circuit in the datasheet of ds3231, is that part necessary?

The chip is functional (swaped with a commercial ds3231 module).

Is there any suggestions?

Show us a good schematic of your complete circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.


In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.
Use the </> icon from the ‘reply menu’ to attach the copied sketch.

The circuit is complete, because it is a module. I just uploaded the pcb of it. It is used as a regular arduino module, just like any other i2c module. When I used it, I connect it with a mega2560 with an eeprom module, too. The eeprom works fine, but not this ds3231 one.

Start with a I2C Scanner sketch.
If you use a library for the DS3231, tell us which one.

There are a lot of traces that are closer than is normally acceptable.

Below are the "standard" steps to verify a new board.

Do you have a blank (unbuilt) left over? If so measure the traces that are close to verify there are not shorts.

With a magnifying glass, verify you have not solder shorts on the board.

I would then power the circuit (without battery). If you can verify the expected current draw that would be good.

With a voltmeter I would measure every input and verify it is what you expect.

1 Like

ds3231pcb

Yes, suggest you take out a DMM and confirm no shorts to adjacent pads or traces.

The traces on R12, R16, C7 and C10 are much closer to the adjacent pad then is necessary for the space you have on the board. Let us know what you find I am doing one of these myself at the moment, but only using the SDA, SCL lines and the battery.

Actually for my 'proof of concept' I used an Adafruit module Adafruit DS3231 Precision RTC Breakout : ID 3013 : $13.95 : Adafruit Industries, Unique & fun DIY electronics and kits
If you buy one of those you can check the voltages between it and your board.

Get the SOIC-8 version instead

DS3231

Easier to route on a custom PCB

Joe,
The next time you design a board you might consider increasing the trace width. Unfortunately many board design software defaults to what most board houses consider a minimum trace width their process is capable of.

I'm in the process of making a combination RTC, SDCard, plugin for 1.3" OLED board.
I looked at the SOIC-8 version but I read the older versions (that only come 16 pin) had a more precise clock, also more fragile. But being the OCDish person I am I went for the older version.
I've already received the parts, well see if they are really the old version (I believe there is a alpha suffix different).

The OP's board has plenty of room for alternate trace paths. I'm sure once he gets more experience he will do fine. After all, these new folks are going from zero to a full PCB design capability. We (or at least me) learned at my first job out of college, not the same.

Thanks, I am doing that. I just used automatic wiring in the eda and the result is like this. I have checked the board, there is no short. Is there any special requirment for these i2c wires? They are quite slow so should be fine anyway, right?

I connected a tmp117 module together with this ds3231 one, and tried this i2c scanner and find the following error:

https://playground.arduino.cc/Main/I2cScanner/

Scanning...
I2C device found at address 0x48 !
Unknown error at address 0x68
done

Looks lie the ds3231 is at 0x68. Maybe the wires are too long so that it can't run at that high speed?

Can you post a good picture of the actual board?

That's never a good idea. There are lots of issues with the routing; while I'm confident it will work Okish if manufactured well, it's far from ideal. But let's skip over this for a second.

Why 10k pullups on I2C? What happens if you use a bit stronger ones, like 4k7?

The EEPROM is just a convenient add-on for the pre-made boards, not needed at all for the DS3231. Probably added because the DS3231 lacks the internal ram found in the DS1307 that is commonly used in RTC boards.

I used a second i2c scanner and found this result:

TIME DEC HEX 50 100 200 250 400 500 800 [KHz]

93535 8 0x8 . . . . . . .
93537 9 0x9 . . . . . . .
93539 10 0xA . . . . . . .
93542 11 0xB . . . . . . .
93544 12 0xC . . . . . . .
93546 13 0xD . . . . . . .
93549 14 0xE . . . . . . .
93551 15 0xF . . . . . . .
93554 16 0x10 . . . . . . .
93556 17 0x11 . . . . . . .
93559 18 0x12 . . . . . . .
93561 19 0x13 . . . . . . .
93564 20 0x14 . . . . . . .
93566 21 0x15 . . . . . . .
93570 22 0x16 . . . . . . .
93572 23 0x17 . . . . . . .
93575 24 0x18 . . . . . . .
93577 25 0x19 . . . . . . .
93580 26 0x1A . . . . . . .
93582 27 0x1B . . . . . . .
93584 28 0x1C . . . . . . .
93587 29 0x1D . . . . . . .
93589 30 0x1E . . . . . . .
93592 31 0x1F . . . . . . .
93594 32 0x20 . . . . . . .
93597 33 0x21 . . . . . . .
93599 34 0x22 . . . . . . .
93602 35 0x23 . . . . . . .
93604 36 0x24 . . . . . . .
93607 37 0x25 . . . . . . .
93609 38 0x26 . . . . . . .
93613 39 0x27 . . . . . . .
93615 40 0x28 . . . . . . .
93618 41 0x29 . . . . . . .
93620 42 0x2A . . . . . . .
93623 43 0x2B . . . . . . .
93625 44 0x2C . . . . . . .
93628 45 0x2D . . . . . . .
93630 46 0x2E . . . . . . .
93633 47 0x2F . . . . . . .
93635 48 0x30 . . . . . . .
93638 49 0x31 . . . . . . .
93640 50 0x32 . . . . . . .
93643 51 0x33 . . . . . . .
93645 52 0x34 . . . . . . .
93648 53 0x35 . . . . . . .
93650 54 0x36 . . . . . . .
93654 55 0x37 . . . . . . .
93656 56 0x38 . . . . . . .
93659 57 0x39 . . . . . . .
93661 58 0x3A . . . . . . .
93664 59 0x3B . . . . . . .
93666 60 0x3C . . . . . . .
93669 61 0x3D . . . . . . .
93671 62 0x3E . . . . . . .
93674 63 0x3F . . . . . . .
93676 64 0x40 . . . . . . .
93679 65 0x41 . . . . . . .
93681 66 0x42 . . . . . . .
93684 67 0x43 . . . . . . .
93686 68 0x44 . . . . . . .
93689 69 0x45 . . . . . . .
93691 70 0x46 . . . . . . .
93694 71 0x47 . . . . . . .
93697 72 0x48 V V V V V V V
93700 73 0x49 . . . . . . .
93702 74 0x4A . . . . . . .
93705 75 0x4B . . . . . . .
93707 76 0x4C . . . . . . .
93710 77 0x4D . . . . . . .
93712 78 0x4E . . . . . . .
93714 79 0x4F . . . . . . .
93717 80 0x50 . . . . . . .
93719 81 0x51 . . . . . . .
93722 82 0x52 . . . . . . .
93724 83 0x53 . . . . . . .
93727 84 0x54 . . . . . . .
93729 85 0x55 . . . . . . .
93732 86 0x56 . . . . . . .
93734 87 0x57 . . . . . . .
93737 88 0x58 . . . . . . .
93740 89 0x59 . . . . . . .
93743 90 0x5A . . . . . . .
93745 91 0x5B . . . . . . .
93748 92 0x5C . . . . . . .
93750 93 0x5D . . . . . . .
93753 94 0x5E . . . . . . .
93755 95 0x5F . . . . . . .
93758 96 0x60 . . . . . . .
93760 97 0x61 . . . . . . .
93763 98 0x62 . . . . . . .
93765 99 0x63 . . . . . . .
93768 100 0x64 . . . . . . .
93770 101 0x65 . . . . . . .
93773 102 0x66 . . . . . . .
93776 103 0x67 . . . . . . .
93778 104 0x68 . . . . . . V
93782 105 0x69 . . . . . . .
93784 106 0x6A . . . . . . .
93787 107 0x6B . . . . . . .
93789 108 0x6C . . . . . . .
93792 109 0x6D . . . . . . .
93795 110 0x6E . . . . . . .
93797 111 0x6F . . . . . . .
93800 112 0x70 . . . . . . .
93802 113 0x71 . . . . . . .
93805 114 0x72 . . . . . . .
93807 115 0x73 . . . . . . .
93810 116 0x74 . . . . . . .
93813 117 0x75 . . . . . . .
93815 118 0x76 . . . . . . .
93818 119 0x77 . . . . . . .

2 devices found in 292 milliseconds.

the 0x68 should be the ds3231. Does that mean the i2c wire happened to be wrong the low speed rather than 800kHz and 800kHz happened to be unsupported by the current wire lib so it didn't work?

The other module (tmp117) works fine along these wires.

You don't have to think what could be wrong. Something is very wrong. Either the DS3231 is broken or there is a shortcut or something else. Do you have another DS3231 ? or perhaps an other pcb ? Check everything once more. If you can not find the problem, then put the pcb away and start all over.

I have 10 of the pcb and tried two of them. I tested three chips one of this was verified functional in a premade ds3231 module. I think it is the resistors.

No pullup resistors or 4k7 or 10k does not cause such big troubles. You have to think about a shortcut or something damaged or a missing connection or a unpowered DS3231. I checked your schematic, but I can not see a problem there. Can you upload a detailed photo ?