Show the error.
My guess is that you are using an operating system that does not differentiate between upper and lower case, like Windows which can create a conflict issue between a system file called time.h and and the library file called Time.h (Those are NOT the same file)
i.e. Windows treats the filenames Time.h and time.h the same, even though they are not the same file so if there is a system file called time.h , which there is for some Arduino cores, then Windows will fail to build things correctly since it can grab time.h instead of Time.h which will cause problems since it is the wrong header file.
This is not really a problem with the library and it is not a problem for other operating systems that don't ignore the case of letters in filenames. It is a Windows problem in the way Windows handles filenames.
To work around this Windows issue, a file called TimeLib.h was created in the Time library.
So if you are using Windows, you will need to include TimeLib.h and not Time.h
Simple as that.
Also, using TimeLib.h will work for all the other operating systems that don't have this case issue.
bperrybap:
i.e. Windows treats the filenames Time.h and time.h the same, even though they are not the same file so if there is a system file called time.h , which there is for some Arduino cores, then Windows will fail to build things correctly since it can grab time.h instead of Time.h which will cause problems since it is the wrong header file.
You have understand that the Time library has been out for quite some time, long before there was any Arduino core that contained its own version of a time library that had a file called time.h
So, for MANY years there was no conflict. It was only recently that there was an issue. And also keep in mind that this is only an issue for certain cores and certain operating systems. So not everyone will see the issue.
AND don't forget that as soon as this issue showed up on Windows a fix was put into the Time library by adding the header file TimeLib.h to fix it for those operating systems (Windows for the most part) that are using a core that contains a time.h header file.
The reason that Paul didn't remove Time.h from the library when TimeLib.h was added is it would have potentially broken lots of existing code that is still working. And so while the library and the examples were fixed to support and use TimeLib.h, the old Time.h header file was left in to try to preserve backward compatibility so as not to break existing code that is still working.
One thing I will say is that I would highly discourage using the Arduino include library function from the IDE.
It can add incorrect header files to your code.
I recommend reading the documentation and looking at the examples to see what headers need to be included and add the necessary includes yourself.
[/quote]
For your simple application, that would be best, as it seems that all you were using it for was measuring delays and actually trying or needed to do epoch based time tracking.
There are other several libraries that are designed to solve what you are doing that would be much better to use than the Time library.
But to be more pendantic, the real issue here is in the IDE, the IDE is placing the search for system headers before the -I entries for the libraries. This is wrong. Normally when the compiler tools are installed properly, you don't have to use a -I options to tell the compiler where the system headers are.
And if you use -I options for other header directories, they are searched before the system headers.
The problem with the IDE is that it uses a set of compiler tools that are not installed properly, so it must use a -I option to tell the compiler where the system headers are located.
However, it places that -I up front ahead of all the other -I options for the Arduino libraries, this changes the normal/default behavior of how other -I options behave.
In the case of the Arduino IDE, what this means is that the compiler system headers will be searched first instead of last.
If the IDE were corrected to search the system headers last instead of first, this issue of time.h vs Time.h would go away on Windows since the compiler would find Time.h before it found time.h since it would search for a non case sensitive file in the Time library and find it before it would look in the system header area.
if you're using the same time library I am, which it seems like you are because I had the same questions when I first implemented it....then the time.h file in the time-master folder only has one line code in it and that is
I found referenced to time.h in the Arduino installation file. Also, Time.h just uses an #include TimeLib.h without any Time.cpp file. It seems that we don't need to use #include Time.h along with #include TimeLib.h. I modified the Time-master library to remove references to Time.h (see below) in TimeLib.h. All my programs that use TimeLib appear to work ok, including the MKR1500. This mod might be a way aroung the Windows blindness to capitalization. Here's my approach (BTW, make a safe copy of Time.h adn TimeLib.h before you make any changes). And remember to restart the IDE after making changes to any library files for these to take effect.
In .ino files, only use #include TimeLib.h, remove and #include time.h
Someone out there probably understands compiler operation better and might know whether this is an appropriate fix and why #include Time.h is causing problems sometimes. Comments welcome.
A bit related, but a different potential issue:
Anytime there is a libraries subdirectory like "libraryname-master" or "libraryname-##.##.##", that is a library that was not installed properly.
That is usually an indication that the library was installed using a zip file from github and it either the IDE used the github to level directory name in the zip file (which is incorrect) or the file was manually extracted into the libraries directory which again created an incorrect subdirectory name for the library.
This can cause issues with multiple versions of the library being installed if using versions from github tags.
I would recommend renaming the directory to be just the library name which is what is what it should be.
If you include in Arduino code when compiling on windows, you can end up getting from the gcc tools that came with the IDE instead of the from the Arduino Time library. This is is not what is wanted.
The reverse can also happen depending on IDE version and core.
I can not confirm your findings that adjustTime(300) "doesn't work". I added that call to the TimeSerial library example so that it is called every time seconds()==15, and the time will advance by 5 minutes.
After searching my Windows PC for a while, I finally found what I think is the file that #include includes on my installation: C:\Users\Brad\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.2\firmwares\wifishield\wifiHD\src\time.h or perhaps C:\Users\Brad\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino5\avr\include\time.h
If you want to use Paul Stoffregen's Time library, download and install it from If instead you wish to use Michael Margolis' Time library, you can find and install it in the Arduino IDE, under Tools / Manage Libraries... and entering "Time" (without quotes) in the search term.
As others have pointed out, the Arduino environment doesn't always know the current date and time. The functions mills() and micros(), return the number of milliseconds or microseconds, respectively, since the Arduino booted. For just looking at the passage of time, most people use millis() or micros() instead of a more complex library.
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 version.
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.
As you can see, the time is incrementing every second. Thus, once the time is set, this library can maintain it, and the best part is that it can interface with various time sources like GPS, RTC, NTP, etc. You are encouraged to go through the documentation of this library and also the examples that come along with this library.
But what if the Internet connection goes down? The solutioncould be using TimeLib library as backup.
And NTP server to update TimeLib from time to time.
I did that for ESP8266 but for ESP32 I had no success.
Thanks, Rui!
This library allows an Arduino/Genuino 101 control and use the internal RTC (Real Time Clock). A real-time clock is a clock that keeps track of the current time and that can be used in order to program actions at a certain time. Most RTCs use a crystal oscillator whose frequency is 32.768 kHz (same frequency used in quartz clocks and watches). Namely this the frequency equal to 2^15 cycles per second and so is a convenient rate to use with simple binary counter circuits. Furthermore the RTC can continue to operate in any sleep mode, so it can be used to wake up the device from sleep modes in a programmed way. Every time the board is powered, the RTC is reset and starts from a standard date. To keep the time and the RTC running it is necessary to keep the board powered.
First, configure the library in your code, then start the serial port, now be polite and send some heartbeats (I know, I told you they are useless). In the code you will see what are the parameters used for. The constants you will see are encoded in the mavlink.h library. You can see there their values and some explanations.
Now you have a lot, I repeat, a lot of data comming through your serial link with the Pixhawk. It is time to focus on what messages we are interested in and how to decode them. You have seen in the main loop this function comm_receive(). Again, it is not a library function, it is something you must write.
35fe9a5643