So I put in a CR2032 battery but I noticed that after cutting power to the Arduino the time does not update, it seems like the module is not keeping track of the time whilst not on 5V power from arduino.
Did you turn the RTC on? There's a bit in one of the registers that needs to be set to turn it on. Since you
haven't posted your code we've no way of knowing what issues exist with it.
I'd recommend having one sketch to set it going and set the time, and your other sketches just read from the RTC.
MarkT:
Did you turn the RTC on? There's a bit in one of the registers that needs to be set to turn it on.
What is that bit??
This is the code for the clock I'm using
#include <FastLED.h>
#include <RCSwitch.h>
// Adafruits RTClib from https://github.com/adafruit/RTClib
#include <Wire.h>
#include "RTClib.h"
RTC_DS3231 RTC;
RCSwitch mySwitch = RCSwitch(); // send wireless Data
String inString = "";
#define NUM_LEDS 60
#define LED_TYPE WS2812B
#define DATA_PIN 6
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];
// Filter averaging factor - higher value means more sluggish response to changes in ambient brightness
#define FILTER_LEN 8
// Brightness level initial value
int level=15;
// Brightness correction for Leds
unsigned char bright[] = {0, 2, 4, 7, 11, 18, 30, 40, 50, 65, 80, 96, 125, 160, 200, 255};
void setup()
{
mySwitch.enableTransmit(10); // Der Sender wird an Pin 10 angeschlossen
// init RTClib
Wire.begin();
RTC.begin();
// Following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(__DATE__, __TIME__));
// Setup FastLED Lib
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds,NUM_LEDS).setCorrection(TypicalLEDStrip);
// setup measurement for LDR
digitalWrite(A0, HIGH); // set pullup on analog pin 0
pinMode(A1, OUTPUT);
digitalWrite(A1, LOW);
Serial.begin(57600);
}
... (nothing pertaining to RTC follows)
I expected the RTC to bahave in a way that if I cut power to the Arduino, and plug it back in, the Time would jump to the position according to the Real Time. Instead, after replugging, it just continues to advance where I cut it off.
Beware that when connected to 5V , the RTC-module will charge the battery.
If there is a CR.... , you should remove the charging circuit.
See the schematic - desolder that small resistor , in the corner, next to the SCL-marking