Hi There,
I'm trying to organize my codes since they are getting longer and longer. I'm trying to use the tabs and so far it going well, till I tried to let a function return a value.
my main file;
#include <SPI.h>
#include <Wire.h>
#include <SD.h>
void setup() {
Serial.begin(9600);
Wire.begin();
//startSD();
startRTC();
//startTemp();
}
void loop() {
Serial.println(getTimeDate());
My RTC part is loaded in his own tabfile;
#include <RTClib.h>
RTC_DS1307 rtc;
char buf1[20];
void startRTC(){
Serial.println("Starting RTC...");
rtc.begin();
getTimeDate();
}
void getTimeDate(){
DateTime now = rtc.now();
sprintf(buf1, "%02d:%02d:%02d %02d/%02d/%02d", now.hour(), now.minute(), now.second(), now.day(), now.month(), now.year());
return buf1;
}
When runnings this code I get the following error;
"templogger:17: error: invalid use of void expression"
I'm trying to make a function to format for me the time and date and returns this new value.
This function I will use for logger into a .txt file at the SD card.
function getTimeDate() is working fine. Output of buf1 is actually what I want.
I'm tried for days many different approaches to reach my result, but without any luck.
This code looks for me the most logical way to realize what I want.