- Sun May 29, 2016 2:45 am
#48188 I have connected a DS1307 Real-time clock module to a WeMOS D1 Mini via the I2C bus and (using 1.6.5 and 2.10rc2) have had 2 test programs working properly to set the clock and another to read the clock.I have upgraded to 1.6.9 and 2.2.0 and get some weird errors without changing any of the code.
- Today we are very proud to release Arduino IDE 1.6.6 and updated cores for all supported platforms (AVR 1.6.9, SAM 1.6.5, SAMD 1.6.2) This update brings an impressive 723 closed issues and 147 pull requests merged. Most intriguing features are: Long-awaited new arduino-builder: this is a p.
- Arduino Create simplifies building a project as a whole, without having to switch between different tools to manage all the aspects of whatever you're making.
Arduino 1.6.9 Version 1.6.9 is highly recommended. The newer versions have introduced complications with file inclusions, and may not be compatible with the Digilent Core.
I have the line #include <DS1307RTC.h> at the top of the code (interestingly the name does not highlight in red as all the other header names do). This header pulls in Time.h and Wire.h.Now, it doesn't matter whether I explicitly #include <Time.h> or not, I get errors saying that the type tmElements_t has not been declared WHICH IS DEFINITELY DECLARED IN Time.h - BTW I get no messages saying that Time.h cannot be found.
BUT if I copy the typedef from Time.h and paste it at the top of the .ino file, those error messages go away.
IT GETS BETTER.
Further down in my .ino file I use a macro tmYearToCalendar(Y) which is also declared in Time.h and which is now reported as not declared when I compile my .ino file.
So I copy and paste the macro into my .ino file and - I CAN'T BELIEVE IT! now the compiler is again reporting that the tmElements_t type has not been declared when there is the declaration at the top on the .ino file.
Below is the .ino file. Let me know if you also want to see the libraries involved. If so, I'll try to zip them up and attach them to a post.
-
// #include <Wire.h>
// #include <Time.h>
#include <DS1307RTC.h>
typedef struct {
uint8_t Second;
uint8_t Minute;
uint8_t Hour;
uint8_t Wday; // day of week, sunday is day 1
uint8_t Day;
uint8_t Month;
uint8_t Year; // offset from 1970;
} tmElements_t, TimeElements, *tmElementsPtr_t;
// #define tmYearToCalendar(Y) ((Y) + 1970) // full four digit year
void setup() {
Serial.begin(115200);
while (!Serial) ; // wait for serial
delay(200);
Serial.println('DS1307RTC Read Test');
Serial.println('-------------------');
}
void loop() {
tmElements_t tm;
if (RTC.read(tm)) {
Serial.print('Ok, Time = ');
print2digits(tm.Hour);
Serial.write(':');
print2digits(tm.Minute);
Serial.write(':');
print2digits(tm.Second);
Serial.print(', Date (D/M/Y) = ');
Serial.print(tm.Day);
Serial.write('/');
Serial.print(tm.Month);
Serial.write('/');
Serial.print(tmYearToCalendar(tm.Year));
Serial.println();
} else {
if (RTC.chipPresent()) {
Arduino 1.6.9 Update
Serial.println('The DS1307 is stopped. Please run the SetTime');Serial.println('example to initialize the time and begin running.');
Arduino 1.6.9
Serial.println();
} else {
Serial.println('DS1307 read error! Please check the circuitry.');
Serial.println();
}
delay(9000);
}
delay(1000);
}
void print2digits(int number) {
Arduino 1.6.8 Download
if (number >= 0 && number < 10) {
Serial.write('0');
}
Serial.print(number);
}