I have a uno that is used to control an poultry incubator. Settings and Readings are sent/received via bluetooth from an Android programmed with App Inventor.
Now I need to sync date and time from the android. I can get the required parameters to the uno as “hr,min,sec,day,mth,year” into a variable.
But I cannot get the variable to operate in the setTime(hr,min,sec,day,mth,year) command for the Timelib library.
As you can see from the test code when I manually set it, it works fine.
You can see what I have tried and the result in the code.
// Time - Version: Latest
// #include <Time.h>
#include <TimeLib.h>
void setup() {
Serial.begin(9600);
// This works to set the time ...
setTime(12,59,11,12,9,2017);
// This does NOT work ...
// String newTime = "12,59,11,12,9,2017";
// setTime(newTime); // error: no matching function for call to 'setTime(String&)'
// Niether does this ...
// char newTime[20] = {12,59,11,12,9,2017};
// newTime[19] = "\0";
// setTime(newTime); // results = 0:38 1/1/1970
Serial.println();
// Serial.println(newTime);
time_t t = now();
Serial.print(hour(t));
Serial.print(":");
Serial.print(minute(t));
Serial.print(" ");
Serial.print(day(t));
Serial.print("/");
Serial.print(month(t));
Serial.print("/");
Serial.println(year(t));
}
void loop() {
}