You get the entire timestamp.
im having issues by implementing RTC module to arduino. Watchdog resets the module if i add RTC module to nodemcu, having following message on Serial monitor and cant find the solution
wdt reset
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v614f7c32
~ld
EDIT: i was using pins 6-7-8 and it was causing reset ESP9266 changed pins to 2-3-4 but now cant get the true time from RTC it gives me output like Current Date / Time: 45/25/2165 45:85:85
Maybe because RTC needs 5v instead of 3.3v from Nodemcu ?
can you give a try with this code Arduino Playground - DS1302RTC
I tried this code many times but i could not let the code work neither with arduino nor with Nodemcu
Getting exceptions always with this library
In file included from C:\Users\Harun\Documents\Arduino\libraries\DS1302RTC\examples\DS1302_Serial\DS1302_Serial.ino:17:0:
C:\Users\Harun\Documents\Arduino\libraries\DS1302RTC/DS1302RTC.h:97:26: error: 'tmElements_t' has not been declared
static uint8_t read(tmElements_t &tm);
^
C:\Users\Harun\Documents\Arduino\libraries\DS1302RTC/DS1302RTC.h:98:27: error: 'tmElements_t' has not been declared
static uint8_t write(tmElements_t &tm);
^
C:\Users\Harun\Documents\Arduino\libraries\DS1302RTC\examples\DS1302_Serial\DS1302_Serial.ino: In function 'void loop()':
DS1302_Serial:61: error: 'tmElements_t' was not declared in this scope
tmElements_t tm;
^
DS1302_Serial:61: error: expected ';' before 'tm'
tmElements_t tm;
^
DS1302_Serial:66: error: expected primary-expression before ')' token
if (! RTC.read(tm)) {
^
DS1302_Serial:68: error: expected primary-expression before '.' token
print2digits(tm.Hour);
^
DS1302_Serial:70: error: expected primary-expression before '.' token
print2digits(tm.Minute);
^
DS1302_Serial:72: error: expected primary-expression before '.' token
print2digits(tm.Second);
^
DS1302_Serial:74: error: expected primary-expression before '.' token
Serial.print(tm.Day);
^
DS1302_Serial:76: error: expected primary-expression before '.' token
Serial.print(tm.Month);
^
DS1302_Serial:78: error: expected primary-expression before '.' token
Serial.print(tmYearToCalendar(tm.Year));
^
DS1302_Serial:78: error: 'tmYearToCalendar' was not declared in this scope
Serial.print(tmYearToCalendar(tm.Year));
^
DS1302_Serial:80: error: expected primary-expression before '.' token
Serial.print(tm.Wday);
^
exit status 1
'tmElements_t' was not declared in this scope
try connecting RTC vcc to vin pin of Nodemcu.
something weird with Nodemcu, it semes there are some pins device dont let you use, if you use it makes Wdt reset. For example i use pins 678 for RTC i get WDT reset. I use pins 123 RTC works but Blue light on ESP8266 runs continiueusly and the RTC gives wrong date- time Now testing all pins. going to be crazy…
i give up Trying RTC and started NTP somebody from community shared a code for getting time from NTP but i can not configure it for Nodemcu ESP8266
im closed with this code using time library.
#include <ESP8266WiFi.h>
#include <time.h>const char* ssid = “xxx”;
const char* password = “xxx”;
int timezone = 3;
int dst = 0;void setup() {
Serial.begin(115200);
Serial.setDebugOutput(true);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println(“\nConnecting to WiFi”);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(“.”);
delay(1000);
}
configTime(timezone * 3600, dst * 0, “pool.ntp.org”, “time.nist.gov”);
Serial.println(“\nWaiting for time”);
while (!time(nullptr)) {
Serial.print(“.”);
delay(1000);
}
Serial.println(“”);
}void loop() {
time_t now = time(nullptr);
Serial.println(ctime(&now));
delay(1000);
}
but it gives output like
Sat Jun 16 23:27:57 2018
i just need to parse it like Hour - minute
on github page it tells how there are avalible functions for it but i could not find out how to use it
Here are the functions i need from readme.md
time_t t = now(); // store the current time in time variable t
hour(t); // returns the hour for the given time t
minute(t); // returns the minute for the given time t
second(t); // returns the second for the given time t
day(t); // the day for the given time t
weekday(t); // day of the week for the given time t
month(t); // the month for the given time t
year(t); // the year for the given time t
void loop() {
time_t now;
struct tm * timeinfo;
time(&now);
timeinfo = localtime(&now);
Serial.println(timeinfo->tm_hour);
delay(1000);
}
i could parse just hour with this code but i dont know if i can send "timeinfo->tm_hour "
like that
Cayenne.virtualWrite(2,timeinfo->tm_hour , “Time”, “HHMM.SS”);
like that
It looks like you got it working, but I’m not sure. Should I mark your thread as helped?
it does not work exactly how i want but its ok. you can mark as helped. thank you