Good Day All,
Please assist I have explored with the following:
Arduino Uno,
16x2 LCD
DS1302 RTC
the library of the RTC you can call a function "myRTC.setDS1302Time(00,16,22,2,31,3,2020)"
My aim is to update the time with this function from a string received from the serial monitor and eventually from the comport of a PC, I am reading the data into a string "00,16,22,2,31,3,2020"and my thought was to call the the function "Funtion(withstring)".
Doing this I receive an error from the compiler "no matching function for call to 'virtuabotixRTC::setDS1302Time(String&)'"
Please could any one advise on a way of achieving this?
Thank you
/*
* Pinouts of connected Equipment
* RTC - Uno
*
* VCC - 3.3VDC
* GND - GND
* MOSI - 7
* SCK - 6
* CS - 8
*
* LCD1602 - Uno
* VCC - 5VDC
* GND - GND
* SDA - A4
* SCL - A5
*/
#include <virtuabotixRTC.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <TimerOne.h>
LiquidCrystal_I2C lcd(0x27,16,2);
virtuabotixRTC myRTC(6,7,8);
String A = "Sun";
String B = "Mon";
String C = "Tue";
String D = "Wed";
String E = "Thu";
String F = "Fri";
String G = "Sat";
String dow = "";
byte readTime = 0;
byte tensec = 0;
String rxData;
String timeUpdate = "";
void setup() {
Serial.begin(9600);
Timer1.initialize(1000000);
Timer1.attachInterrupt(ISRtimerLCD);
lcd.init(); // initialize the lcd
lcd.backlight();
lcd.setCursor(0,0); //Defining positon to write from first row,first column .
lcd.print("* Arduino Uno *"); //You can write 16 Characters per line
lcd.setCursor(0,1); //Defining positon to write from first row,first column .
lcd.print("DS1302 RTC Clock"); //You can write 16 Characters per line .
// Set the current date, and time in the following format:
// seconds, minutes, hours, day of the week, day of the month, month, year
//myRTC.setDS1302Time(00,16,22,2,31,3,2020);
}
void loop() {
// This allows for the update of variables for time or accessing the individual elements.
myRTC.updateTime();
if (readTime == 1) {
readTime = 0;
printTimetoLCD();
}
while(Serial.available()) {
rxData= Serial.readString();// read the incoming data as string
timeUpdate = rxData;
Serial.println("rxData "+rxData);
Serial.println("timeUpdate "+timeUpdate);
myRTC.setDS1302Time(timeUpdate);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(rxData);
Serial.flush();
delay(2000);
}
}//Closing Main Loop
void printTimetoLCD(){
updateDOW();
// Build String to send to LCD
char dayBuffer [10] = "";
char timeBuffer [10] = "";
sprintf(dayBuffer, "%02d/%02d/%04d", myRTC.dayofmonth, myRTC.month, myRTC.year);
sprintf(timeBuffer, "%02d:%02d:%02d", myRTC.hours, myRTC.minutes, myRTC.seconds);
//Start Sending Data to the LCD for a refresh
lcd.clear();
lcd.setCursor(0,0);
lcd.print(dow),
lcd.print(" ");
lcd.print(dayBuffer);
lcd.setCursor(3,1);
lcd.print(timeBuffer);
/*Serial.println(dayBuffer);
Serial.println(timeBuffer);
Serial.println(dow);*/
}
void ISRtimerLCD(){
readTime = 1;
}
void updateDOW(){
if (myRTC.dayofweek == 0) {
dow = A;
}
else if (myRTC.dayofweek == 1) {
dow = B;
}
else if (myRTC.dayofweek == 2) {
dow = C;
}
else if (myRTC.dayofweek == 3) {
dow = D;
}
else if (myRTC.dayofweek == 4) {
dow = E;
}
else if (myRTC.dayofweek == 5) {
dow = F;
}
else if (myRTC.dayofweek == 6) {
dow = G;
}
}