I have a functioning sketch that I am trying to graft into a Blynk sketch to gain easy networkability. My circuit is a Mega2560 w/Ethernet, a DHT sensor and an RTC. So far, I was able to get the DHT values sent to Blynk which displays the sensor readings in the Blynk app on my smartphone. I am now at the phase where I wish to also have my RTC values sent down stream, but have hit a roadblock. It was advised by the Blynk.cc founder to collect my RTC data into a string, but with my very limited knowledge in coding, I am unaware of how to do this and am seeking guidance, or more information than what is provided in the Arduino reference section. Below is the blocks in my sketch that queries my RTC and displays the hour according to 12 hour format. I created a local variable to capture that value and I wish to put this value, now.minute and now.second with respective colons in between into a string. Once I have the string, it will be much easier to forward the string to be displayed on my smartphone and I will be able to look in on my project and view climate conditions, project time and relay states.
void RTCdisplay()
{
//**********************************************************************************//
//****** Setting Time and testing to display 24 hour format as 12 hour format ******//
//**********************************************************************************//
DateTime now = RTC.now(); // reads time at beginning of loop
byte twelveHour = now.hour() - 12; // Variable used to display 13+ hours in 12 hour format
byte zeroHour = 12; // Variable use to convert "0" zero hour to display it as 12:00+
byte displayHour();
if (now.hour() == 0) // First we test if the hour reads "0"
{
zeroHour = displayHour();
Serial.print(zeroHour); // if yes, serial print a "12" instead
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.print(' ');
Serial.println (F("AM"));
}
else if (now.hour() >= 13) // if no, Second we test if the hour reads "13 or more"
{
twelveHour = displayHour();
Serial.print(twelveHour); // if yes, serial print that current hour minus 12
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.print(' ');
Serial.println (F("PM"));
}
else
{
Serial.print(now.hour(), DEC); // if no, Third we conclude that the am hours are being displayed correctly.
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.print(' ');
Serial.println (F("AM"));
}
{
//Blynk.virtualWrite(V3, displayHour(), now.minute(), now.second());
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print('/');
Serial.println(now.year(), DEC);
Serial.println();
}
Blynk.virtualWrite() is just my latest best guess how to send my data down, but it failed to compile and I commented it out until I figure out the proper course to take. Can someone please help me fill in some mental blank spots on this? Thank you in advance!