I'm pretty sure it is down to me only working on programming for a few weeks now.
So I am still a total fool and have on a few times created problems for myself that were not needed and simple to fix once understood... retlating to
#include <TimeLib.h>
#include <TimeAlarms.h>
I love the arduino IDE, I have sketch that I am having problems with. The unit saves ssid and password to the eeprom and starts up automatically and connects to the internet. (just using snippets of other people's code)
All that works fine and I can even connect to NTP server and display time on an oled....
But I I stumped by a simple line in the timeAlarms sketch.
setTime(8,29,0,1,1,11); // set time to Saturday 8:29:00am Jan 1 2011 //this is the line I don't now how to write.
I can not seem to get this data completed automatically... I have even done formatting of the time.. and it pints out as the correct 6 numbers and comas on the serial if asked but I can not get the line of code correct to set time to the current time.
I'm only posting partial sketch but I'm pretty sure that the problem lies here... As is it connects to the internet and displays time to the OLED, but time printed to the Serial from timealarms is from 00:00:00 each time it starts and never syncs up.
even when I tried formatting it like this
String get_time3(){
time_t now;
time(&now);
char time3_output[30];
// See http://www.cplusplus.com/reference/ctime/strftime/ for strftime functions
strftime(time3_output, 30, "%H,%M,%w,%d,%m,%y", localtime(&now)); // "%H,%M,%w,%d,%m,%y" goal
return String(time3_output); //
//Serial.println(get_time2());
}
I can't seem to get this value placed after SetTime in the line of code below....
If I can get this time to track the time on the OLED, my problems would be solved.... at least until my RTC arrives... (I only heard of those last week)
...WiFi.begin(esid.c_str(), epass.c_str()); //connects to wifi just fine
configTime(0, 0, "za.pool.ntp.org", "time.nist.gov"); //"za.pool.ntp.org",
// See https://github.com/nayarsystems/posix_tz_db/blob/master/zones.csv for Timezone codes for your region
setenv("TZ", "SAST-2", 1); //displays correct time on oled
delay(15000);
Serial.println(F("wifi connected"));
Serial.println(get_time());
Serial.println(get_dom());
}
String get_time(){
time_t now;
time(&now);
char time_output[6];
// See http://www.cplusplus.com/reference/ctime/strftime/ for strftime functions
strftime(time_output, 6, "%R", localtime(&now));
return String(time_output); // returns 12:31:45
//Serial.println(get_time());
}
Just partial code but just wanted to show how I have been getting my time....
I just dont know how to edit the line that sets the time for the timealarm, and it has been 3 days now!
Happy new year to everyone else fighting code rather than hangover this morning.