I'm trying to merge 2 Arduino samples, in order to be able to use DS3231 RTC module with ESP8266 WiFi simple web server.
My RTC library is this: https://github.com/Makuna/Rtc/wiki
Generally, to code runs ok (I have the Web server responses to my browser calls, and I think the DS3231 RTC code also works). But when I'm trying to use a variable from within the RTC object into the Web server function - I get nothing.
I thought declaring the 'now' object outside any function (Setup() nor Loop()) will make it global, and when I'll update it in the Loop() function using
now = Rtc.GetDateTime();
It will be available to other functions as well, but all I get is "0" when I try to print it.
My code is here: Definitions part:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
/* This block is for I2C protocol for DS3231 module (for normal hardware wire use below) */
#include <Wire.h> // must be included here so that Arduino library object file references work
#include <RtcDS3231.h>
RtcDS3231<TwoWire> Rtc(Wire);
/* The above block is for I2C protocol and DS3231 module (for normal hardware wire use above) */
ESP8266WebServer server(80);
RtcDateTime now;
My Loop():
void loop(void) {
now = Rtc.GetDateTime();
Serial.println(now.Minute());
server.handleClient();
delay(500);
}
And all I get is "0" printed.
Any help would be appreciated!
now
into theloop()
function?