DS3234 RTC

Hi,

I Purchased a DS3234 RTC from China (https://nl.aliexpress.com/item/33038164178.html?spm=a2g0s.12269583.0.0.191b347cD30sie) but am struggling with the wiring. According to all documentation, examples, libraries etc I should have PINS for SS, MISO, MOSI and CLK, However, my board shows connections for SS, SCL, MISO and MOSI.
I Have tried running it with the wiring following the labeling on the board itself, using the SCL PIN as CLK, and following examples for the DeadOn DS3234 wiring. Neither of them work.

Any ideas?

SS (Slave Select) and CS (Chip Select) are used interchangeable. So are SCL (Serial CLock) and CLK (CLocK).

All connections are straight (aka MISO goes to MISO).

Which library did you try?

I think the OP is using this one: GitHub - sparkfun/SparkFun_DS3234_RTC_Arduino_Library: Implements all time-keeping, setting, and alarming functions of the DS3234 RTC module.

My first concern is if the part is actually a DS3234. If it is a counterfeit or a remarked chip it might not work with that library. I'm dealing with some counterfeit DS3231's right now myself (loses 4 minutes a day).

OP: if that part is good and you are following the Sparkfun example accurately it should work. You do need to make sure that the SS or CS pin is connected to the pin that is defined in the code.

I recommend for beginners to use parts from Sparkfun instead of cheap stuff from China. Sometimes the cheap stuff is just as good, sometimes not.

What Arduino are you using? Are you using the Sparkfun code as is or modified?

You can try this code:
I could not test this as I don't have that chip, but it compiles and I expect it to work. I took the example code from the Sparkfun library and stripped out everything not really needed just to test. All it will do is read the year and print it. If the results are not an actual year or you get nothing then there is no communications. Of course I may have missed something in the code, but this might get you started.

#include <SPI.h>
#include <SparkFunDS3234RTC.h>



#define DS13074_CS_PIN 10 // DeadOn RTC Chip-select pin (the Chip Select pin should be connected to Arduino Pin 10 as 
//                           defined here. You can use any pin, but the the code must match.


void setup()
{
  Serial.begin(9600);
  rtc.begin(DS13074_CS_PIN);
  rtc.update();
  Serial.println(rtc.year());
}

void loop(){
}

I Have tried several libraries and scripts,

the Adafruit script,

a script from GitHub - Makuna/Rtc: Arduino Library for RTC, Ds1302, Ds1307, Ds3231, & Ds3234 with deep support. Please refer to the Wiki for more details. Please use the gitter channel to ask questions as the GitHub Issues feature is used for bug tracking.,

and a script I found on http://www.keyesrobot.cn/wiki/KE0072_keyes_DS3234高精度时钟模块(焊盘孔)_红色_环保.

They all seem to work. But none seem to update the RTC,. I Am working on an UNO R3,

What do you mean by update?

Set the start time you want? (aka current time).
Or do you get the same time all the time? Aka, stuck.

If it's the last I would suspect a badly soldered crystal.

septillion:
What do you mean by update?

Set the start time you want? (aka current time).
Or do you get the same time all the time? Aka, stuck.

If it's the last I would suspect a badly soldered crystal.

The rtc.setTime option does not work. Neither the Rtc.SetDateTime(compiled) or the manual option do not update the RTC to current time.

You have not posted your code, nor answered what Arduino you are working with. That would be required to help you figure it out. You have not mentioned if you tried my code, and if so what the result was. The idea was to find out if the chip was responding, if it could be read. If you can't read the time from it you will not be able to write the time to it.

My suggestion is buy the real part from Sparkfun and see if that works. Otherwise it is your wiring or your software.

amdkt7:
You have not posted your code, nor answered what Arduino you are working with. That would be required to help you figure it out. You have not mentioned if you tried my code, and if so what the result was. The idea was to find out if the chip was responding, if it could be read. If you can't read the time from it you will not be able to write the time to it.

My suggestion is buy the real part from Sparkfun and see if that works. Otherwise it is your wiring or your software.

Hi,

As stated in my earlier post, I am able to read the date and time from the RTC, but the rtc.setTime option does not work. I Also stated that I am working on an Uno R3.

// Reference for connecting SPI see https://www.arduino.cc/en/Reference/SPI
// CONNECTIONS:
// DS3234 MISO --> MISO
// DS3234 MOSI --> MOSI
// DS3234 CLK  --> CLK (SCK)
// DS3234 CS (SS) --> 5 (pin used to select the DS3234 on the SPI)
// DS3234 VCC --> 3.3v or 5v
// DS3234 GND --> GND

const uint8_t DS3234_CS_PIN = 10;

#include <SPI.h>
#include <RtcDS3234.h>

RtcDS3234<SPIClass> Rtc(SPI, DS3234_CS_PIN);

void setup () 
{
    Serial.begin(115200);
    while (!Serial);

    Serial.print("compiled: ");
    Serial.print(__DATE__);
    Serial.println(__TIME__);

    SPI.begin();
    Rtc.Begin();

    RtcDateTime compiled = RtcDateTime(__DATE__, __TIME__);
    printDateTime(compiled);
    Serial.println();

    if (!Rtc.IsDateTimeValid()) 
    {
        // Common Causes:
        //    1) first time you ran and the device wasn't running yet
        //    2) the battery on the device is low or even missing

        Serial.println("RTC lost confidence in the DateTime!");

        // following line sets the RTC to the date & time this sketch was compiled
        // it will also reset the valid flag internally unless the Rtc device is
        // having an issue

        Rtc.SetDateTime(compiled);
    }

    if (!Rtc.GetIsRunning())
    {
        Serial.println("RTC was not actively running, starting now");
        Rtc.SetIsRunning(true);
    }

    RtcDateTime now = Rtc.GetDateTime();
    if (now < compiled) 
    {
        Serial.println("RTC is older than compile time!  (Updating DateTime)");
        Rtc.SetDateTime(compiled);
    }
    else if (now > compiled) 
    {
        Serial.println("RTC is newer than compile time. (this is expected)");
    }
    else if (now == compiled) 
    {
        Serial.println("RTC is the same as compile time! (not expected but all is fine)");
    }

    // never assume the Rtc was last configured by you, so
    // just clear them to your needed state
    Rtc.Enable32kHzPin(false);
    Rtc.SetSquareWavePin(DS3234SquareWavePin_ModeNone); 
}

void loop () 
{
    if (!Rtc.IsDateTimeValid()) 
    {
        // Common Causes:
        //    1) the battery on the device is low or even missing and the power line was disconnected
        Serial.println("RTC lost confidence in the DateTime!");
    }

    RtcDateTime now = Rtc.GetDateTime();
    printDateTime(now);
    Serial.println();

	RtcTemperature temp = Rtc.GetTemperature();
	temp.Print(Serial);
	// you may also get the temperature as a float and print it
    // Serial.print(temp.AsFloatDegC());
    Serial.println("C");

    delay(10000); // ten seconds
}

#define countof(a) (sizeof(a) / sizeof(a[0]))

void printDateTime(const RtcDateTime& dt)
{
    char datestring[20];

    snprintf_P(datestring, 
            countof(datestring),
            PSTR("%02u/%02u/%04u %02u:%02u:%02u"),
            dt.Month(),
            dt.Day(),
            dt.Year(),
            dt.Hour(),
            dt.Minute(),
            dt.Second() );
    Serial.print(datestring);
}

I'm sorry if I missed where you mentioned your Uno, and that you were able to read the time, however I still cannot find where you mentioned either. No problem. Now, what library are you using? That code looks valid, but I need to see the documentation for that library to know how to use it. Provide a link to your library and I will be happy to look at it.

Itwasme:
I Have tried several libraries and scripts,

the Adafruit script,

a script from GitHub - Makuna/Rtc: Arduino Library for RTCs, Ds1302, Ds1307, Ds3231, Ds3232, Ds3234 and Pcf8563/BM8563 with deep support. Please refer to the Wiki for more details. Please use the Github Discussions to ask questions as the GitHub Issues feature is used for bug tracking.,

and a script I found on http://www.keyesrobot.cn/wiki/KE0072_keyes_DS3234高精度时钟模块(焊盘孔)_红色_环保.

They all seem to work. But none seem to update the RTC,. I Am working on an UNO R3,

The code I posted comes from GitHub - Makuna/Rtc: Arduino Library for RTCs, Ds1302, Ds1307, Ds3231, Ds3232, Ds3234 and Pcf8563/BM8563 with deep support. Please refer to the Wiki for more details. Please use the Github Discussions to ask questions as the GitHub Issues feature is used for bug tracking.

I see no issues with the code. The wiring must be right if you are able to read the time from the chip. What exactly happens when you try to update the time? Does it just remain the same time or does something else happen?

It's possible that you have a bad part.

amdkt7:
I see no issues with the code. The wiring must be right if you are able to read the time from the chip. What exactly happens when you try to update the time? Does it just remain the same time or does something else happen?

It's possible that you have a bad part.

The rtc.setTime option does not work. Neither the Rtc.SetDateTime(compiled) or the manual option do not update the RTC to current time.

What value do you get when you read the time? If you wait one minute and read the time again, what do you get? My DS3231 modules will read something like 127 for year, month, hour, minute when there is no functioning connection to the chip (because the wiring is wrong, or the code setup is wrong). I have no idea what your library might return when it actually can't talk to the chip. If you keep getting the same time everytime you read from it then the chip is not actually running. We need to know if that chip is running or not, and you have not supplied evidence that it is.

It's great to know that all those setTime functions don't work, but you are not describing exactly what you see. Maybe a few screen shots of your serial monitor might make the problem visible.

Last time I'm going to say it, but I think you need to make sure you have a genuine part by buying one from a reputable store like Sparkfun.

I'm trying to help, but so far I don't have the detailed kind of information that it takes to have a clue of what is going on. I do hope you can get it working.