Hello everybody.
I don't know if I posted in the right place and I apologize in advance if I'm wrong.
I use and really enjoy using the wokwi simulator.
" https://wokwi.com "
It has always worked correctly.
I'm not a "club" user, but a (free) user.
As I did not find on the site a place to report occurrences,
I'm using the Arduino forum for this purpose.
Today when testing a sketch I had difficulty with a library.
I summarized the sketch as much as possible:
#include <DS1307RTC.h>
void setup() {
}
void loop() {
// put your main code here, to run repeatedly:
}
In the "Library Manager" tab, include the DS1307RTC.h library.
When running I got the error message:
In file included from sketch.ino:2:0:
/libraries/DS1307RTC/DS1307RTC.h:9:10: fatal error: TimeLib.h: No such file or directory
#include <TimeLib.h>
^~~~~~~~~~~~
terminated compilation.
Error during build: exit status 1
I tried to include this library, but it didn't allow it because it doesn't exist in the list of libraries for "free" users.
I ask, what is the point of making a free library available to the user but who needs another library that is not free?
Thank you in advance
edit: never mind, didn't read carefully...
You don't need to be a club member to have an account, still free. Maybe you have an account.
I had no trouble on my GF's machine as an anonymous user:
Go to the library manager tab, hit the big purple plus button and start typing the name of a library you want to use.
DS1307
was enough to show up the DS1307RTC library.
HTH
a7
Does the WokWi simulator pretend that the DS1307 can keep accurate time, or does it model realistically poor performance?
LOL! I suspect it does not bother to be crappy, and I bet no one runs it long enough in simulation for it to make a difference.
The wokwi is realistic about some things, like switch bounce.
I think the RTC implementations also suffer from coming up with the current date and time automatically...
Some things like playing with the backup battery or what exactly happens over a power cycle (or over many hours or months, for that matter) will have to be done IRL.
a7
It does exist. Even though it is common, not all library names match the header filename. In this case, the library is named "Time", not "TimeLib". So search the Library Manager for "Time", add it to your project, and you'll be set.
2 Likes
Tks @ptillisch ,
I used the Time library and it worked.
Hi @alto777 ,
I think I was not clear in my description.
The library " DS1307RTC " I was able to select,
but when running the sketch I got the error message asking for the library " TimeLib ".
This one I couldn't find.
1 Like
No, I was just not reading carefully and was more concerned about the idea that wokwi has any class barriers.
a7
You are welcome. I'm glad it is working now.
Since the name is defined in the library's metadata , the library author can choose any arbitrary name they like (though it is encouraged as best practices to make the name and primary header filename match ).
In this specific case, there actually is an interesting technical explanation for the mismatch: The primary header filename of this popular library was Time.h for many years. Eventually a problem arose with this name. The toolchain contains a header file named time.h which has priority over the Arduino libraries for #include directive resolution. On the case sensitive file system of Linux, this was no problem because Time.h and time.h are two different filenames. However, on the case insensitive file systems of Windows and macOS, this is a problem because the two are equivalent. So the #include directives in code with a dependency on the "Time " library would instead end up resolving to using this incompatible time.h header instead:
opened 08:51PM - 07 Nov 15 UTC
closed 10:36PM - 26 Dec 15 UTC
There seems to be a new conflict between the ctime time.h and the Arduino Time.h… library.
Reproduce by building TimeTeensy3 example. This is on Mac, where the filesystem is ignores case, which may be part of the cause. Verbose build results below.
```
Arduino: 1.6.6 (Mac OS X), TD: 1.26-beta3, Board: "Teensy 3.2 / 3.1, Serial + Keyboard + Mouse + Joystick, 72 MHz optimized, US English"
/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware "/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/hardware" -hardware "/Users/dean/Library/Arduino15/packages" -tools "/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/tools-builder" -tools "/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/hardware/tools/avr" -tools "/Users/dean/Library/Arduino15/packages" -built-in-libraries "/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/libraries" -libraries "/Users/dean/Documents/Arduino/libraries" -fqbn=teensy:avr:teensy31:usb=serialhid,speed=72opt,keys=en-us -ide-version=10606 -build-path "/var/folders/w1/0xxlqytr8xg565001s7pswz80000gn/T/build98fee79b5753e07289d9cb5c4db23e65.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "/Users/dean/Documents/Arduino/libraries/TimeLib/examples/TimeTeensy3/TimeTeensy3.ino"
/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/arduino-builder -compile -logger=machine -hardware "/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/hardware" -hardware "/Users/dean/Library/Arduino15/packages" -tools "/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/tools-builder" -tools "/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/hardware/tools/avr" -tools "/Users/dean/Library/Arduino15/packages" -built-in-libraries "/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/libraries" -libraries "/Users/dean/Documents/Arduino/libraries" -fqbn=teensy:avr:teensy31:usb=serialhid,speed=72opt,keys=en-us -ide-version=10606 -build-path "/var/folders/w1/0xxlqytr8xg565001s7pswz80000gn/T/build98fee79b5753e07289d9cb5c4db23e65.tmp" -warnings=none -prefs=build.warn_data_percentage=75 -verbose "/Users/dean/Documents/Arduino/libraries/TimeLib/examples/TimeTeensy3/TimeTeensy3.ino"
WARNING: Spurious .git folder in 'Adafruit GFX Library' library
WARNING: Spurious .git folder in 'PID' library
WARNING: Spurious .git folder in 'Audio' library
WARNING: Spurious .git folder in 'FastLED' library
WARNING: Spurious .git folder in 'ILI9341_t3' library
WARNING: Spurious .git folder in 'SparkFun APDS9960 RGB and Gesture Sensor' library
"/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/hardware/tools/avr/../arm/bin/arm-none-eabi-g++" -M -MG -MP -x c++ -w -fno-exceptions -felide-constructors -std=gnu++0x -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=126 -DARDUINO=10606 -DF_CPU=72000000 -DARDUINO_ARCH_AVR -DUSB_SERIAL_HID -DLAYOUT_US_ENGLISH "-I/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "/var/folders/w1/0xxlqytr8xg565001s7pswz80000gn/T/build98fee79b5753e07289d9cb5c4db23e65.tmp/sketch/TimeTeensy3.ino.cpp"
"/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/hardware/tools/avr/../arm/bin/arm-none-eabi-g++" -M -MG -MP -x c++ -w -fno-exceptions -felide-constructors -std=gnu++0x -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=126 -DARDUINO=10606 -DF_CPU=72000000 -DARDUINO_ARCH_AVR -DUSB_SERIAL_HID -DLAYOUT_US_ENGLISH "-I/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "/var/folders/w1/0xxlqytr8xg565001s7pswz80000gn/T/build98fee79b5753e07289d9cb5c4db23e65.tmp/sketch/TimeTeensy3.ino.cpp"
"/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/hardware/tools/avr/../arm/bin/arm-none-eabi-g++" -M -MG -MP -x c++ -w -fno-exceptions -felide-constructors -std=gnu++0x -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=126 -DARDUINO=10606 -DF_CPU=72000000 -DARDUINO_ARCH_AVR -DUSB_SERIAL_HID -DLAYOUT_US_ENGLISH "-I/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "/var/folders/w1/0xxlqytr8xg565001s7pswz80000gn/T/build98fee79b5753e07289d9cb5c4db23e65.tmp/sketch/TimeTeensy3.ino.cpp"
"/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/hardware/tools/avr/../arm/bin/arm-none-eabi-g++" -M -MG -MP -x c++ -w -fno-exceptions -felide-constructors -std=gnu++0x -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=126 -DARDUINO=10606 -DF_CPU=72000000 -DARDUINO_ARCH_AVR -DUSB_SERIAL_HID -DLAYOUT_US_ENGLISH "-I/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "/var/folders/w1/0xxlqytr8xg565001s7pswz80000gn/T/build98fee79b5753e07289d9cb5c4db23e65.tmp/sketch/TimeTeensy3.ino.cpp"
"/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/hardware/tools/avr/../arm/bin/arm-none-eabi-g++" -M -MG -MP -x c++ -w -fno-exceptions -felide-constructors -std=gnu++0x -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=126 -DARDUINO=10606 -DF_CPU=72000000 -DARDUINO_ARCH_AVR -DUSB_SERIAL_HID -DLAYOUT_US_ENGLISH "-I/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "/var/folders/w1/0xxlqytr8xg565001s7pswz80000gn/T/build98fee79b5753e07289d9cb5c4db23e65.tmp/sketch/TimeTeensy3.ino.cpp"
"/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/hardware/tools/avr/../arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -MMD -nostdlib -fno-exceptions -felide-constructors -std=gnu++0x -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=126 -DARDUINO=10606 -DF_CPU=72000000 -DARDUINO_ARCH_AVR -DUSB_SERIAL_HID -DLAYOUT_US_ENGLISH "-I/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "/var/folders/w1/0xxlqytr8xg565001s7pswz80000gn/T/build98fee79b5753e07289d9cb5c4db23e65.tmp/sketch/TimeTeensy3.ino.cpp"
"/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/tools-builder/ctags/5.8-arduino2/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns "/var/folders/w1/0xxlqytr8xg565001s7pswz80000gn/T/build98fee79b5753e07289d9cb5c4db23e65.tmp/preproc/ctags_target.cpp"
"/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/tools-builder/ctags/5.8-arduino2/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns "/var/folders/w1/0xxlqytr8xg565001s7pswz80000gn/T/build98fee79b5753e07289d9cb5c4db23e65.tmp/preproc/ctags_target.cpp"
"/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/hardware/tools/avr/../arm/bin/arm-none-eabi-g++" -c -O -g -Wall -ffunction-sections -fdata-sections -MMD -nostdlib -fno-exceptions -felide-constructors -std=gnu++0x -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=126 -DARDUINO=10606 -DF_CPU=72000000 -DARDUINO_ARCH_AVR -DUSB_SERIAL_HID -DLAYOUT_US_ENGLISH "-I/Users/dean/Downloads/Arduino-1.6.6.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "/var/folders/w1/0xxlqytr8xg565001s7pswz80000gn/T/build98fee79b5753e07289d9cb5c4db23e65.tmp/sketch/TimeTeensy3.ino.cpp" -o "/var/folders/w1/0xxlqytr8xg565001s7pswz80000gn/T/build98fee79b5753e07289d9cb5c4db23e65.tmp/sketch/TimeTeensy3.ino.cpp.o"
/Users/dean/Documents/Arduino/libraries/TimeLib/examples/TimeTeensy3/TimeTeensy3.ino: In function 'void setup()':
/Users/dean/Documents/Arduino/libraries/TimeLib/examples/TimeTeensy3/TimeTeensy3.ino:11:33: error: 'setSyncProvider' was not declared in this scope
setSyncProvider(getTeensy3Time);
^
/Users/dean/Documents/Arduino/libraries/TimeLib/examples/TimeTeensy3/TimeTeensy3.ino:16:18: error: 'timeStatus' was not declared in this scope
if (timeStatus()!= timeSet) {
^
/Users/dean/Documents/Arduino/libraries/TimeLib/examples/TimeTeensy3/TimeTeensy3.ino:16:22: error: 'timeSet' was not declared in this scope
if (timeStatus()!= timeSet) {
^
/Users/dean/Documents/Arduino/libraries/TimeLib/examples/TimeTeensy3/TimeTeensy3.ino: In function 'void loop()':
/Users/dean/Documents/Arduino/libraries/TimeLib/examples/TimeTeensy3/TimeTeensy3.ino:28:16: error: 'setTime' was not declared in this scope
setTime(t);
^
/Users/dean/Documents/Arduino/libraries/TimeLib/examples/TimeTeensy3/TimeTeensy3.ino: In function 'void digitalClockDisplay()':
/Users/dean/Documents/Arduino/libraries/TimeLib/examples/TimeTeensy3/TimeTeensy3.ino:37:21: error: 'hour' was not declared in this scope
Serial.print(hour());
^
/Users/dean/Documents/Arduino/libraries/TimeLib/examples/TimeTeensy3/TimeTeensy3.ino:38:22: error: 'minute' was not declared in this scope
printDigits(minute());
^
/Users/dean/Documents/Arduino/libraries/TimeLib/examples/TimeTeensy3/TimeTeensy3.ino:39:22: error: 'second' was not declared in this scope
printDigits(second());
^
/Users/dean/Documents/Arduino/libraries/TimeLib/examples/TimeTeensy3/TimeTeensy3.ino:41:20: error: 'day' was not declared in this scope
Serial.print(day());
^
/Users/dean/Documents/Arduino/libraries/TimeLib/examples/TimeTeensy3/TimeTeensy3.ino:43:22: error: 'month' was not declared in this scope
Serial.print(month());
^
/Users/dean/Documents/Arduino/libraries/TimeLib/examples/TimeTeensy3/TimeTeensy3.ino:45:21: error: 'year' was not declared in this scope
Serial.print(year());
^
/Users/dean/Documents/Arduino/libraries/TimeLib/examples/TimeTeensy3/TimeTeensy3.ino: In function 'long unsigned int processSyncMessage()':
/Users/dean/Documents/Arduino/libraries/TimeLib/examples/TimeTeensy3/TimeTeensy3.ino:61:29: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
if(Serial.find(TIME_HEADER)) {
^
exit status 1
'year' was not declared in this scope
```
The problem was commonly associated with the Arduino IDE 1.6.6 release because it included an updated version of the bundled "Arduino AVR Boards" platform which contained the problematic time.h file, but actually the problem already affected other boards platforms with this file in their toolchain, and also affected users of previous IDE versions who updated their "Arduino AVR Boards" platform via Boards Manager, so it wasn't so much coupled to the IDE version.
The workaround that was employed by the library maintainer Paul Stoffregen was to add a header file with a unique name TimeLib.h and recommend that all #include directives be changed from Time.h to TimeLib.h:
committed 05:29PM - 11 Nov 15 UTC
The use of TimeLib.h is now enforced by the complete removal of Time.h after it was judged that sufficient time had passed to allow the dependent code to transition to using TimeLib.h:
committed 11:35AM - 21 Jun 21 UTC
1 Like
Tks @ptillisch .
Thank you very much for the solution and the explanation of the reasons.
system
Closed
April 16, 2023, 1:58pm
11
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.