DS3231 misreading with current draw

Hello!

I'm trying to make a clock with an Arduino Uno, and a DS3231 RTC featherwing (Pinouts | DS3231 Precision RTC FeatherWing | Adafruit Learning System). The clock will display words through white LEDs controlled by 4x 74HC595 shift registers, and on a person's birthday serial-controlled RGB neopixel LEDs will be illuminated. I've tested the components separately from one another and they seem to work as expected. I'm powering everything separately on 5V provided by HUSB238 (Adafruit USB Type C Power Delivery Dummy Breakout - I2C or Fixed [HUSB238] : ID 5807 : Adafruit Industries, Unique & fun DIY electronics and kits). I also have a MUX (4051) for 6 control buttons, and another set of 5x 74HC595 shift registers for 7-segment displays, but those aren't in use for the stage of integration testing I'm currently doing. edited to add rough circuit diagram below

Now that I'm putting everything together (the RTC, the white LEDs + the RGB LEDs) and doing integration testing, I'm seeing some weird behaviour. Whenever I have more than about ~7-8 RGB LEDs illuminated simultaneously with the white LEDs, the serial readout of my RTC gets very strange:

Initializing RTC...
Checking if RTC lost power...
====================================
2025/10/31 5:32:30
IT IS HALF PAST   FIVE (hours) OCLOCK 
Sleeping...
====================================
2025/24/20 25:10:0
IT IS TEN (minutes) MINUTES PAST  ONE OCLOCK 
Sleeping...

2025/0/10 14:18:0
IT IS TWENTY MINUTES PAST  TWO OCLOCK 
Sleeping...
====================================
2025/0/12 10:0:0
IT IS     TEN (hours) OCLOCK 
Sleeping...
====================================
2025/0/0 12:0:0
IT IS     TWELVE OCLOCK 
Sleeping...

However, if I reset the arduino, I see the initial readout from the RTC is maintained (and I don't see a message indicating the RTC lost power and is being reset to time of the last sketch compilation), so I don't believe the RTC itself is compromised or losing its time. My suspicion at this point is noise on the SDA/SCL, or instability of the 5VDC. Measuring with a DMM indicates the 5V isn't dropping, so I don't believe it's related to current starvation. I've also tried putting a 0.1uF capacitor on the 5V rail to smooth out voltage ripple, but the same behaviour persists.

Some forums/sources I've read suggest putting pull-up resistors (5-10k) between the SDA/SCL lines and the 3.3V line -- but my understanding is that the DS3231 RTC featherwing already HAS pullup resistors, so I'm at a loss as to what else to try and what might be the root cause of this issue.

Thanks in advance for your help. I'll post my code below for completeness but I think the likely problem is outside the code. There are some subclasses which I haven't included but can upon request if it's material to the solution/debugging.

#include "RTClib.h"
#include "TimeWords.h"
#include "RainbowWords.h"

RTC_DS3231 rtc;

const int selectPins[3] = {3, 4, 5}; // S0~3, S1~4, S2~5
const int zInput = 2; 

// shift register pins for the white words
const int whiteLedsClockPin=12;
const int whiteLedsLatchPin=11;
const int whiteLedsDataPin=13;

// shift register pins for the side-panel 7-segment display
// A0-A5 can be called by D14-19
const int segmentClockPin=19;
const int segmentLatchPin=18;
const int segmentDataPin=17;

TimeWords timeWords(whiteLedsClockPin,whiteLedsLatchPin,whiteLedsDataPin);
RainbowWords rainbowWords;

void setup() {
  // select pins for MUX
  for (int i=0; i<3; i++)
  {
    pinMode(selectPins[i], OUTPUT);
    digitalWrite(selectPins[i], HIGH);
  }
  pinMode(zInput, INPUT_PULLUP); // Set up Z as an input

  // white LED shift register pin declarations
  pinMode(whiteLedsClockPin,OUTPUT);
  pinMode(whiteLedsLatchPin,OUTPUT);
  pinMode(whiteLedsDataPin,OUTPUT);

  // 7-segment shift register pin declarations
  pinMode(segmentClockPin,OUTPUT);
  pinMode(segmentLatchPin,OUTPUT);
  pinMode(segmentDataPin,OUTPUT);

  rainbowWords.initialize();

  // serial console setup
  Serial.begin(9600);  
  #ifndef ESP8266
    while (!Serial); // wait for serial port to connect. Needed for native USB
  #endif

  // Real-time clock initialization for DS3231
  Serial.println("Initializing RTC...");
    if (! rtc.begin()) {
      Serial.println("Couldn't find RTC");
      Serial.flush();
      while (1) delay(10);
    }

  Serial.println("Checking if RTC lost power...");
    if (rtc.lostPower()) {
      Serial.println("RTC lost power, let's set the time!");
      // When time needs to be set on a new device, or after a power loss, the
      // following line sets the RTC to the date & time this sketch was compiled
      rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
    }
}

void loop() {
  Serial.println(F("===================================="));

  DateTime now = rtc.now();

  Serial.print(now.year(), DEC);
  Serial.print('/');
  Serial.print(now.month(), DEC);
  Serial.print('/');
  Serial.print(now.day(), DEC);
  Serial.print(F(" "));
  Serial.print(now.hour(), DEC);
  Serial.print(':');
  Serial.print(now.minute(), DEC);
  Serial.print(':');
  Serial.print(now.second(), DEC);
  Serial.println(F(""));

  timeWords.updateAllTimeWords(now);
  rainbowWords.updateAllRainbowWords(now);

  Serial.println(F("Sleeping..."));
  delay(1000);
}
  • Always show us a good schematic of your proposed circuit.
    Show us good images of your ‘actual’ wiring.
1 Like

Thanks Larry, I've uploaded a rough circuit diagram showing how the pieces connect.

  • Thank you.

  • Your 4051 needs 5v power too.
    How will the Arduino be powered ?

  • Remember, every digital I.C. needs a properly connected de-coupling ceramic 100nF capacitor on each power pin.

  • This line of code should only be exectuted once, afterwards commented out after the RTC set. i.e. upload the sketch with the line uncommented, then comment the line and upload the code again with the line commented out thereafter.

rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  • Assume the RTC has a battery ?

  • 83 WS2813 pixels needs 4A :scream:

Thanks again, Larry.

The 4051 is connected to 5V as well; you're right.

The Arduino is powered by a USB connector to my power rail. While I'm programming (and Arduino is powered by USB to a computer), I tie the Arduino's ground pin to the ground of the power rail, but that will be disconnected when I'm not programming in order to avoid a ground loop.

I don't have de-coupling ceramic capacitors on each power pin -- that is quite likely my problem, or at the very least probably not helping the issue.

The RTC does have a battery.

I'm only turning on a maximum of 30 LEDs on the strip at once, so that should only be 1.5 A or so? (I might be misunderstanding how the strip lights work) My power brick can supply 4A.

  • But can your power brick cable supply 4A without voltage drop ?

  • After the Arduino is programmed, how is it powered ?

  • The Arduino GND needs to be connected to the GND of all the components the Arduino talks to.

Yeah, it's a good question -- I measured the 5V line and saw it go from 5.25 V to 5.18 V when the rainbow LEDs came on.

The Arduino is intended to be powered by a USB cable that I've soldered the +5 / GND cables to my power rail, so the same 5V that's powering everything else. It should have a common GND with all the other components, I believe.

  • Always show us good images of your ‘actual’ wiring.
  • So it will be powered via the USB connector to the power brick ?

Time for :sleeping:

I'm a little scared to post images, for fear of the community's scorn because my wiring is very messy, but I guess I'll be brave and post some images...

This is the back of the clock. The two red boards on the left are the shift registers for the white LED words. The two red boards on the right are for 7-segment side-panel display. The Arduino is in the center, the RTC below it. The power rail is on the bottom right. The MUX for the buttons and the connections for the 7-segment display are disconnected (the problem manifests without them connected).

Beneath all the PCBs is a network of wires and resistors for the white LEDs, in a grid. The PCBs are raised off the back by about 1/2" via standoffs, except the RTC, which had nothing below it.

Here is a close-up of the power-rail:

Arduino (the electrical tape is from me adding pull-up resistors after-the-fact):

RTC:

Shift registers for white LEDs:

Shift registers for 7-segment displays (x5):

Yes, that's the intention. Though I might be getting dangerously close to the limit of my power brick... I did try powering the Arduino with a 12V wall plug to see if that helped, and got the same result.

Seeing the wiring I would say your suspicions are correct.

putting pull-up resistors (5-10k) between the SDA/SCL lines and the 3.3V line

In your case it would be to the 5V line not 3.3
Have you tried 4.7K to 5V?

Thanks Jim. I ended up putting 10k pullup resistors to the 5V line and they didn't help, but 10k is probably too high for effective nose suppression?

The board already has 10K so the two in parallel would 5K. If that didn't make any difference than 4.7K probably will not either.

Shoot. I'm not sure what else to do... Would shielded wiring, and shortening as much as possible be likely to help and worthwhile?

Can't hurt but that is assuming it's an EMI problem and I don't think that has been proven yet
It could be a software issue but I'm not familiar with the timewords and rainbowwords libraries.

What is the power output of your HUSB238 ?

/ A0-A5 can be called by D14-19
const int segmentClockPin=19;
const int segmentLatchPin=18;
const int segmentDataPin=17;

18 and 19 are also the I2C pins !

5V, 3A. I was looking at this too and realized it doesn't quite use all the power brick's current capacity

Ohhhhhh!!! Thank you, Jim!

From here
https://www.adafruit.com/product/5807
Jumper-configured usage is simple : by default its hard-wired for 5V 1A output since that's what USB C will always provide at first.