DS3231 with RTClibExtended.h : unable to serial print time

Unable to serial print (serial monitor) time and date from a stupid little program like this, what do I stupidly do wrong? Date printed is continually 6, time is continually printed as 42.
On Arduino Uno.

SDA and SCL are connected correctly, baud rate set correctly.

// http://forum.arduino.cc/index.php?topic=499210.msg3407044#msg3407044
// http://forum.arduino.cc/index.php?topic=396450.0

// HC12 Communication between Arduinos
// v2: modify to include RTC and transmit time
// corresponds with Arduino_serial_Arduino_TX_HC12_burst_test_hardware_v4

/*
  This program serves to send two integers (or byte) from one (later to become two different)
  HC12 transmitter.
  The data are sent with start- and endmarkers

  // TRANSMITTER PART
*/

#include <Wire.h>
#include <RTClibExtended.h>
#include <LowPower.h>
#define DS3231_I2C_ADDRESS 0x68
RTC_DS3231 RTC;      //we are using the DS3231 RTC

int analogValue5, val5, seconds, minutes;
int HC12power = 8;
const int interval1 = 100; // HC12 power-off delay time in milliseconds
const int interval3 = 1000; // HC12 fixed retransmission timings
unsigned long previousMillis1 = 0; // timer1
unsigned long previousMillis3 = 0; // timer3


void setup()
{
  Serial.begin(115200);     // Open serial port to computer
  pinMode(HC12power, OUTPUT);
  pinMode(LED_BUILTIN, OUTPUT);
  Wire.begin();
  RTC.begin();
  
}

void loop() {

  // read analog pin 5
  analogValue5 = analogRead(5);
  // remap values from the analogValue5 variable to 0 / 255
  val5 = map(analogValue5, 0, 1023, 0, 255);
  DateTime now = RTC.now;

  if (millis() - previousMillis3 >= interval3) {
    previousMillis3 = millis();

    if (digitalRead(HC12power) == LOW) {
      digitalWrite(HC12power, HIGH);
      digitalWrite(LED_BUILTIN, HIGH);
      previousMillis1 = millis();
      delay(50);
    }

    Serial.print('<');
    Serial.print(val5);
    Serial.print(',');
    Serial.print(now.minute(), DEC);
    Serial.print(',');
    Serial.print(now.hour(), DEC);
    Serial.print(",B>");
    Serial.println();
   

    /*
      HC12.print('<');
      HC12.print(val5);
      HC12.print(',');
      HC12.print(val5);
      HC12.print(",B>");
    */
  }
  //start timer to switch off HC12
  if (millis() - previousMillis1 >= interval1) {
    digitalWrite(HC12power, LOW);
    digitalWrite(LED_BUILTIN, LOW);
  }
}

This code returns correct minute and hour on serial output:

#include <Wire.h>
#include <RTClibExtended.h>

RTC_DS3231 rtc;

void setup () {
  Serial.begin(9600);
   // while the serial stream is not open, do nothing:
   while (!Serial) ;
  Wire.begin();
  rtc.begin();

}

void loop () {
  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(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();
  
    Serial.println();
    delay(1000);
  
}

This code returns 42 for minute and 6 for hour forever:

// http://forum.arduino.cc/index.php?topic=499210.msg3407044#msg3407044
// http://forum.arduino.cc/index.php?topic=396450.0

// HC12 Communication between Arduinos
// v2: modify to include RTC and transmit time
// corresponds with Arduino_serial_Arduino_RX_HC12_burst_test_hardware_v4

/*
  This program serves to send two integers (or byte) from one (later to become two different)
  HC12 transmitter.
  The data are sent with start- and endmarkers

  // TRANSMITTER PART
*/

#include <Wire.h>
#include <RTClibExtended.h>
#include <LowPower.h>
#define DS3231_I2C_ADDRESS 0x68
RTC_DS3231 RTC;      //we are using the DS3231 RTC

int analogValue3, val3, seconds, minutes;
int HC12power = 8;
const int interval1 = 100; // HC12 power-off delay time in milliseconds
const int interval3 = 1000; // HC12 fixed retransmission timings
unsigned long previousMillis1 = 0; // timer1
unsigned long previousMillis3 = 0; // timer3


void setup()
{
  Serial.begin(9600);     // Open serial port to computer
  pinMode(HC12power, OUTPUT);
  pinMode(LED_BUILTIN, OUTPUT);
  Wire.begin();
  RTC.begin();
  
}

void loop() {

  // read analog pin 3
  analogValue3 = analogRead(3);
  // remap values from the analogValue5 variable to 0 / 255
  val3 = map(analogValue3, 0, 1023, 0, 255);
  DateTime now = RTC.now;

  if (millis() - previousMillis3 >= interval3) {
    previousMillis3 = millis();

    if (digitalRead(HC12power) == LOW) {
      digitalWrite(HC12power, HIGH);
      digitalWrite(LED_BUILTIN, HIGH);
      previousMillis1 = millis();
      delay(50);
    }

    Serial.print('<');
    Serial.print(val3);
    Serial.print(',');
    Serial.print(now.minute(), DEC);
    Serial.print(',');
    Serial.print(now.hour(), DEC);
    Serial.print(",B>");
    Serial.println();
   

    /*
      HC12.print('<');
      HC12.print(val5);
      HC12.print(',');
      HC12.print(val5);
      HC12.print(",B>");
    */
  }
  //start timer to switch off HC12
  if (millis() - previousMillis1 >= interval1) {
    digitalWrite(HC12power, LOW);
    digitalWrite(LED_BUILTIN, LOW);
  }
}

What is wrong with this last piece of code?

I don't see anything obviously wrong with the non-working code. The RTC could be stopped, so make sure it is running when you use it.

BTW the ", DEC" modifiers are not needed in the print statements. That is default. And these declarations should be unsigned long:

const int interval1 = 100; // HC12 power-off delay time in milliseconds

jremington:
I don't see anything obviously wrong with the non-working code. The RTC could be stopped, so make sure it is running when you use it.

BTW the ", DEC" modifiers are not needed in the print statements. That is default.

ok for ", DEC". But what in that second code could make the DS3231 to stop?

The DS3231 may be stopped for some reason other than your code.

Control Register (0Eh)
Bit 7: Enable Oscillator (EOSC). When set to logic 0,
the oscillator is started. When set to logic 1, the oscillator
is stopped when the DS3231 switches to VBAT. This
bit is clear (logic 0) when power is first applied. When
the DS3231 is powered by VCC, the oscillator is always
on regardless of the status of the EOSC bit. When
EOSC is disabled, all register data is static.

There is different syntax for DateTime now call in the two versions.

Working code with proper syntrax

 DateTime now = RTC.now();

Not working code improper syntax

 DateTime now = RTC.now;

Yep, I missed that.

jremington:
Yep, I missed that.

OMG!! Thanks, I became just blind after all that code-staring.

cattledog:
There is different syntax for DateTime now call in the two versions.

Working code with proper syntrax

 DateTime now = RTC.now();

Not working code improper syntax

 DateTime now = RTC.now;

+1