I'm developing on a NodeMCU board retrieving epoch from a time server (NTP). Everything was working as expected until I added: #include <Time.h> so that I could get the date from Unix time.
The sketch fails to compile with: 'day' was not declared in this scope
I tried adding #include <TimeLib.h> but that causes a whole stack of errors about multiple libraries. This also happens if I add both libraries. As soon as I remove Time.h my project builds/runs fine.
I thought Time.h was a standard Arduino lib. Not sure if I can properly or reliably extract the date myself without using this library.
ToddL1962:
Serial does not have a 'printf' member function so the code you presented cannot possibly compile.
actually you are not right on that one. printf() is part of the default libraries on a ESP8286 or ESP32 (because there is enough memory to have the full library)
J-M-L:
actually you are not right on that one. printf() is part of the default libraries on a ESP8286 or ESP32 (because there is enough memory to have the full library)
I tried re-installing Time by Michael Margolis, but no difference. Current version installed is 1.5.0. Even if I comment out the Time library my project won't compile now.
Below is the compile error message. Strange - without the Time library it compiled yesterday. Now it's failing. So frustrating trying to get this basic sketch working
COMPILE ERROR:
Arduino: 1.8.10 (Windows 10), TD: 1.48, Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled (new can abort), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"
C:\Users\ross\AppData\Local\Arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-4-b40a506/bin/xtensa-lx106-elf-ar: unable to rename 'libraries\ESP8266WiFi\ESP8266WiFi.a'; reason: File exists
Multiple libraries were found for "ArduinoJson.h"
Used: C:\Users\ross\Documents\Arduino\libraries\ArduinoJson
Multiple libraries were found for "ESP8266WiFi.h"
Used: C:\Users\ross\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.2\libraries\ESP8266WiFi
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).
UPDATE - Strange that this works, but I don't know why.
In the Arduino IDE I opened the example Blink sketch for ESP8266 and changed LED_BUILTIN to D7.
The sketch compiled and uploaded to the NodeMCU board, and when I connect an LED between D7 & GND it blinks as expected.
I then re-opened my initial NTP sketch (with TimeLib.h included) and now it compiles and uploads without issue, with the following output:
Multiple libraries were found for "ESP8266WiFi.h"
Used: C:\Users\ross\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.2\libraries\ESP8266WiFi
exit status 1
You are obviously using core 2.6.2 (i didn't know that was already available)
The sketch compiled and uploaded to the NodeMCU board, and when I connect an LED between D7 & GND it blinks as expected.
I hope you added a small resistor in between as well to limit the current, also keep in mind that it is better to make LED's active LOW, (though for the pin you used it doesn't matter) to prevent accidentally changing the boot-mode. The actual builtin led on GPIO2 is active LOW.
I'm not that smart with electronics but I do know how to use a resistor with an LED.
I'm having so much trouble with my NodeMCU I'm not sure it's going to be feasible. Sometimes the sketch compiles and sometimes it doesn't - even with no changes to the code.
For example, now I'm getting another error message and again it won't compile: Fatal error: can't create libraries\ESP8266WiFi\BearSSLHelpers.cpp.o: Permission denied
10 minutes later I tried again and now this error is gone!
I'm not that smart with electronics but I do know how to use a resistor with an LED.
One never knows, very smart people can make obvious mistakes.
I'm having so much trouble with my NodeMCU I'm not sure it's going to be feasible
I suspect you have more than 1 core installed somehow. (or another weird happening) anyway i suggest you go to Tools -> Board -> Board Manager and find the ESP (probably all the way at the bottom) and uninstall whatever version you have installed (hit remove), check again to see if there is nothing installed if there is remove that, until there is no ESP core installed. Then go to Used: C:\Users\ross\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\(if that still exists, and remove whatever you find there. Close the IDE & re-open it (actually just in case, reboot the computer, so we know for sure any Java- process has been completed) and now through the boards manager install the ESP core, and i suggest first to try v2.4.2 (2.5.2 should also be stable and even 2.6.1 should be, but i've bee having issues with those)
Multiple libraries were found for "ArduinoJson.h"
Used: C:\Users\ross\Documents\Arduino\libraries\ArduinoJson
Multiple libraries were found for "ESP8266WiFi.h"
the ESP8266WiFi.h is a builtin library, there should only be 1. The ArduinoJson.h is not builtin i think, but it would be better to make sure no multiple versions exist side by side. Best is to remove both and re-install to your sketch\libraries folder.
Oh 1 more thing, with IDE built 1.8.x i noticed that the progress bar fills up all the way to the end, way before the compilation is complete. The compilation process is not complete until the compiler answers back at you either with error messages & terminated or completed. It may take quite a while depending on your hw-configuration, but refrain from hitting the compile or upload button while it's compiling.
I uninstalled ESP8266 board and re-installed using version 2.4.2. Now I'm looking into the duplicate libraries issue. Is there a "default" location where all libraries should be installed?. I seem to have libraries in two locations:
Now I'm looking into the duplicate libraries issue. Is there a "default" location where all libraries should be installed?. I seem to have libraries in two locations:
there are actually 3 main locations, The second you see is the ESP-core specific location, those libraries are builtin to the core installation. (AVR has a folder for that as well) The first is the Location for libraries that are builtin to the IDE install (but not core specific) and as a subfolder to your main-sketch folder you can install user or custom libraries that you will want to retain if you upgrade the IDE.
I think I only had one version of ESP8266 installed (see pic below).
I was basing that on the error msg, that involved a file in ...\tools\2.5.0.. to which access was denied, maybe that is just being used by 2.6.2 as well.
'class axTLS::WiFiClientSecure' has no member named 'setInsecure'
If I remove "client.setInsecure();" it fails to connect to my IIS web service which uses SSL.
I guess the "setInsecure" method was added in a later version.
i guess, yes in a later version of WifiClientSecure() though the function it actually is a patch for something else, you don't add the fingerprint to the cypher (it can be nearly impossible to get that to work properly) so the https connection is rejected but by setting insecure you can access it as http. You could just stick to core 2.4.2 and update <WiFiClientSecure.h> if all else fails. (or you can try and see if you can get the fingerprint thing to work properly)
I continued to have a lot of compile errors despite trying different versions of the library. The duplicate library errors were not correct. For example, my sketch would not compile, so I'd then upload a basic blink sketch, then re-open my sketch and it would compile without error. After making changes and trying to upload again, the errors returned.
I ended up switching to an ESP32 Esspressif board which is working perfectly with no issues and it's pretty much the same code.