User avatar
By OldBikerPete
#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.

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()) {
Serial.println("The DS1307 is stopped. Please run the SetTime");
Serial.println("example to initialize the time and begin running.");
Serial.println();
} else {
Serial.println("DS1307 read error! Please check the circuitry.");
Serial.println();
}
delay(9000);
}
delay(1000);
}

void print2digits(int number) {
if (number >= 0 && number < 10) {
Serial.write('0');
}
Serial.print(number);
}
User avatar
By picstart
#48203 Well,
There are lots of dependencies not only in the Arduino code but also with the esp8266 core modules.
I've found it best to place the folder Portable into the Arduino directory. It prevents oozing into Windows common file area's like users\..Applications etc. but most of all since all the gizillions of files are contained in a single folder like Arduino 1.6.5 or Arduino 1.6.9 it ensures the versions are self contained and can run independent of each other. It makes for a more obvious single folder backup and makes transfers of your Arduino environment to another machine a breeze. Most don't share their PC with other users so most of this common area oozing is unneeded and can lead to errors when the installation of new software overlays proven code in the common area forcing a restore to recover working code.