I’m trying to create a height datalogger using a Seeeduino V4.2(ATMega328P) to host a Grove High Precision RTC (to timestamp the barometer data), Grove High Precision Barometer (to give a barometric reading, which can be converted to a height value) and an SD Card Shield (to save the data)
I am trying to find a sketch which will allow me to set the time and date, but every one I have tried so far either fails to recognise the chip, or appears to set the time, but only when the sketch is running - i.e when it is checked later, the clock is no longer set.
I have tried another clock chip, as I thought the first one may be faulty, but the replacement behaves the same. I have checked the voltage from the clock battery, and the battery is functioning normally.
I have run a I2C Scan, and the chip is being detected on 0x51 (as it should be)
I will focus on one sketch at first, as it will become complicated if I mention more than one (although I have tried several sketches made for this purpose, all of them unsuccessful).
In this example, I will use the sketch created by lambor, which is attributed to SeeedStudio, and is called ‘PCF85063TP_RTC’. The code is below, followed by the error message below that.
Function: Set time and get the time from RTC chip(PCD85063TP) and display
// it on the serial monitor.
// Hardware: Grove - RTC v2.0
// Arduino IDE: Arduino-1.6.6
// Author: lambor
// Date: June 14,2016
// Version: v1.0
// by www.seeedstudio.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later verscion.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//
/**************************************************************************/
#include <Wire.h>
#include <PCF8563.h>
#include <RTC.h>
DS1307 RTclock;//define a object of PCD85063TP class
void setup() {
- Serial.begin(9600);*
- RTclock.begin();*
// /*
// RTclock.stopClock();
// RTclock.fillByYMD(2021,3,19);//Jan 19,2013
// RTclock.fillByHMS(20,55,00);//15:28 30"
// RTclock.fillDayOfWeek(FRI);//Saturday
// RTclock.setTime();//write time to the RTC chip
// RTclock.startClock();
*// / - //clock.setcalibration(1, 32767.2); // Setting offset by clock frequency*
}
void loop() {
- printTime();*
- delay(1000);*
}
/Function: Display time on the serial monitor/
void printTime() { - RTclock.GetTime();*
- Serial.print(RTclock.hour, DEC);*
- Serial.print(":");*
- Serial.print(RTclock.minute, DEC)s*
- Serial.print(":");*
- Serial.print(RTclock.second, DEC);*
- Serial.print(" ");*
- Serial.print(RTclock.month, DEC);*
- Serial.print("/");*
- Serial.print(RTclock.dayOfMonth, DEC);*
- Serial.print("/");*
- Serial.print(RTclock.year + 2000, DEC);*
- Serial.print(" ");*
- Serial.print(RTclock.dayOfMonth);*
- Serial.print("");
- switch (RTclock.dayOfWeek) { // Friendly printout the weekday*
-
case MON:*
-
Serial.print("MON");*
-
break;*
-
case TUE:*
-
Serial.print("TUE");*
-
break;*
-
case WED:*
-
Serial.print("WED");*
-
break;*
-
case THU:*
-
Serial.print("THU");*
-
break;*
-
case FRI:*
-
Serial.print("FRI");*
-
break;*
-
case SAT:*
-
Serial.print("SAT");*
-
break;*
-
case SUN:*
-
Serial.print("SUN");*
-
break;*
- }*
- Serial.println(" ");*
}
Error message:
Arduino: 1.8.13 (Windows 10), Board: “Seeeduino V4(Atmega328P)”
In file included from Y:\2021_Images\Arduino\PCF85063TP_RTC\PCF85063TP_RTC.ino:28:0:
D:\Arduino\libraries\RTC\src/RTC.h:42:7: error: redefinition of ‘class DateTime’
-
class DateTime {*
-
^~~~~~~~*
In file included from D:\Arduino\libraries\RTC\src/PCF8563.h:10:0,
-
from Y:\2021_Images\Arduino\PCF85063TP_RTC\PCF85063TP_RTC.ino:27:*
D:\Arduino\libraries\RTC\src/RTC.h:42:7: note: previous definition of ‘class DateTime’
-
class DateTime {*
-
^~~~~~~~*
In file included from Y:\2021_Images\Arduino\PCF85063TP_RTC\PCF85063TP_RTC.ino:28:0:
D:\Arduino\libraries\RTC\src/RTC.h:60:7: error: redefinition of ‘class DS1307’
-
class DS1307*
-
^~~~~~*
In file included from D:\Arduino\libraries\RTC\src/PCF8563.h:10:0,
-
from Y:\2021_Images\Arduino\PCF85063TP_RTC\PCF85063TP_RTC.ino:27:*
D:\Arduino\libraries\RTC\src/RTC.h:60:7: note: previous definition of ‘class DS1307’
-
class DS1307*
-
^~~~~~*
In file included from Y:\2021_Images\Arduino\PCF85063TP_RTC\PCF85063TP_RTC.ino:28:0:
D:\Arduino\libraries\RTC\src/RTC.h:108:7: error: redefinition of ‘class NVRAM’
-
class NVRAM*
-
^~~~~*
In file included from D:\Arduino\libraries\RTC\src/PCF8563.h:10:0,
-
from Y:\2021_Images\Arduino\PCF85063TP_RTC\PCF85063TP_RTC.ino:27:*
D:\Arduino\libraries\RTC\src/RTC.h:108:7: note: previous definition of ‘class NVRAM’
-
class NVRAM*
-
^~~~~*
In file included from Y:\2021_Images\Arduino\PCF85063TP_RTC\PCF85063TP_RTC.ino:28:0:
D:\Arduino\libraries\RTC\src/RTC.h:127:7: error: redefinition of ‘class DS3231’
-
class DS3231 {*
-
^~~~~~*
In file included from D:\Arduino\libraries\RTC\src/PCF8563.h:10:0,
-
from Y:\2021_Images\Arduino\PCF85063TP_RTC\PCF85063TP_RTC.ino:27:*
D:\Arduino\libraries\RTC\src/RTC.h:127:7: note: previous definition of ‘class DS3231’
-
class DS3231 {*
-
^~~~~~*
In file included from Y:\2021_Images\Arduino\PCF85063TP_RTC\PCF85063TP_RTC.ino:28:0:
D:\Arduino\libraries\RTC\src/RTC.h:227:7: error: redefinition of ‘class PCF8563’
-
class PCF8563*
-
^~~~~~~*
In file included from D:\Arduino\libraries\RTC\src/PCF8563.h:10:0,
-
from Y:\2021_Images\Arduino\PCF85063TP_RTC\PCF85063TP_RTC.ino:27:*
D:\Arduino\libraries\RTC\src/RTC.h:227:7: note: previous definition of ‘class PCF8563’
-
class PCF8563*
-
^~~~~~~*
Y:\2021_Images\Arduino\PCF85063TP_RTC\PCF85063TP_RTC.ino: In function ‘void printTime()’:
PCF85063TP_RTC:51:13: error: ‘class DS1307’ has no member named ‘GetTime’; did you mean ‘setTime’?
-
RTclock.GetTime();*
-
^~~~~~~*
-
setTime*
PCF85063TP_RTC:52:26: error: ‘class DS1307’ has no member named ‘hour’
-
Serial.print(RTclock.hour, DEC);*
-
^~~~*
PCF85063TP_RTC:54:26: error: ‘class DS1307’ has no member named ‘minute’; did you mean ‘setMinutes’?
-
Serial.print(RTclock.minute, DEC)s*
-
^~~~~~*
-
setMinutes*
PCF85063TP_RTC:56:26: error: ‘class DS1307’ has no member named ‘second’
-
Serial.print(RTclock.second, DEC);*
-
^~~~~~*
PCF85063TP_RTC:58:26: error: ‘class DS1307’ has no member named ‘month’; did you mean ‘setMonth’?
-
Serial.print(RTclock.month, DEC);*
-
^~~~~*
-
setMonth*
PCF85063TP_RTC:60:26: error: ‘class DS1307’ has no member named ‘dayOfMonth’; did you mean ‘setMonth’?
-
Serial.print(RTclock.dayOfMonth, DEC);*
-
^~~~~~~~~~*
-
setMonth*
PCF85063TP_RTC:62:26: error: ‘class DS1307’ has no member named ‘year’
-
Serial.print(RTclock.year + 2000, DEC);*
-
^~~~*
PCF85063TP_RTC:64:26: error: ‘class DS1307’ has no member named ‘dayOfMonth’; did you mean ‘setMonth’?
-
Serial.print(RTclock.dayOfMonth);*
-
^~~~~~~~~~*
-
setMonth*
PCF85063TP_RTC:66:21: error: ‘class DS1307’ has no member named ‘dayOfWeek’
-
switch (RTclock.dayOfWeek) { // Friendly printout the weekday*
-
^~~~~~~~~*
PCF85063TP_RTC:67:14: error: ‘MON’ was not declared in this scope
-
case MON:*
-
^~~*
PCF85063TP_RTC:70:14: error: ‘TUE’ was not declared in this scope
-
case TUE:*
-
^~~*
Y:\2021_Images\Arduino\PCF85063TP_RTC\PCF85063TP_RTC.ino:70:14: note: suggested alternative: ‘JUNE’
-
case TUE:*
-
^~~*
-
JUNE*
PCF85063TP_RTC:73:14: error: ‘WED’ was not declared in this scope
-
case WED:*
-
^~~*
PCF85063TP_RTC:76:14: error: ‘THU’ was not declared in this scope
-
case THU:*
-
^~~*
PCF85063TP_RTC:79:14: error: ‘FRI’ was not declared in this scope
-
case FRI:*
-
^~~*
PCF85063TP_RTC:82:14: error: ‘SAT’ was not declared in this scope
-
case SAT:*
-
^~~*
PCF85063TP_RTC:85:14: error: ‘SUN’ was not declared in this scope
-
case SUN:*
-
^~~*
Y:\2021_Images\Arduino\PCF85063TP_RTC\PCF85063TP_RTC.ino:85:14: note: suggested alternative: ‘JUNE’
-
case SUN:*
-
^~~*
-
JUNE*
exit status 1
‘class DS1307’ has no member named ‘GetTime’; did you mean ‘setTime’?
This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.
I have tried using the suggested change, but this just creates further error messages.
Thank you for your help, March.