I have just added the ESP32 toolchain to the Arduino IDE (v1.8.0) on Windows 10. To get the IDE to allow me to select ESP32 chips I had to place the Espressif folder in "D:\Program Files(x86)\Arduino\hardware" (Yes my C drive is called D, its a long story)
I managed to compile and run Blink and after several minutes of celebration I tried the ESP32 Example Wifi->WifiScan. It failed to compile because
WARNING: Category '' in library OneWire is not valid. Setting to 'Uncategorized'
In file included from D:\Program Files (x86)\Arduino\libraries\WiFi\src\utility\spi_drv.cpp:21:0:
D:\Program Files (x86)\Arduino\libraries\SPI/SPI.h:16:26: fatal error: avr/pgmspace.h: No such file or directory
compilation terminated.
Multiple libraries were found for "WiFi.h"
Used: D:\Program Files (x86)\Arduino\libraries\WiFi
Not used: D:\Program Files (x86)\Arduino\hardware\espressif\ESP32\libraries\WiFi
Multiple libraries were found for "SPI.h"
Used: D:\Program Files (x86)\Arduino\libraries\SPI
Not used: D:\Program Files (x86)\Arduino\hardware\espressif\ESP32\libraries\SPI
exit status 1
Error compiling for board ESP32 Dev Module.
If I am reading this correctly, there are a couple of duplicate libraries, Arduino versions and ESP32 versions and the IDE picked the Arduino versions.
Is there a way of telling the IDE to prefer the ESP32 libraries rather than Arduino ones? I suspect all I need to do is change the order of the -I and -L commands, but I don't have a clue how, or if that's the right thing to do.
2 Answers 2
#include "filename.h"
will look in the sketch folder
#include <filename.h>
will look in the path, defined in File | Preferences, edit preferences.txt, search for sketchbook.path
-
1So the system library path (-L) is defined in perferances.txt, thanks for that.Code Gorilla– Code Gorilla2017年08月05日 12:24:08 +00:00Commented Aug 5, 2017 at 12:24
-
#include <filename.h> will only look in the path, defined in File | Preferences, edit preferences.txt, search for sketchbook.path
this is wrong. Thelibraries
subfolder of the sketchbook is only one of 6 folders in the include path in a standard hardware package, none of which are configured in preferences.txt. There is no need to edit preferences.txt, you can just do File > Preferences > Sketchbook location. Also, take a second to actually view your answer before submitting it to see how the markdown is being rendered.per1234– per12342017年08月05日 19:31:24 +00:00Commented Aug 5, 2017 at 19:31
The problem is that you have incorrectly installed the ESP32 hardware package. If you look at the official installation instructions:
https://github.com/espressif/arduino-esp32/blob/master/README.md#installation-instructions
you'll see that the architecture folder should be named esp32, not ESP32 as you have named your folder.
When multiple libraries contain a header file of the same name, one of the factors the Arduino IDE uses to decide which gets precedence is architecture matching. The architecture of the selected board is determined by the name of the architecture folder of the hardware package of that board. So because you named your architecture folder ESP32, that's the architecture value of the selected board. The architecture of the library is determined by the architectures
property value found in the library.properties file of the library. In this case that value is set to esp32
:
architectures=esp32
So because the architecture value of the library in the ESP32 hardware package doesn't match the architecture of the selected board, the SPI library found in the Arduino IDE installation folder is used instead.
If you rename the architecture folder to esp32 the correct library will be used.
A few other notes:
For some reason you have put a copy of the SPI library at D:\Program Files (x86)\Arduino\libraries\SPI. This makes no sense because that library is architecture specific. Each hardware package has its own version of the SPI library bundled.
In addition to using the incorrect architecture folder name in your installation of the ESP32 hardware package, you installed it to the Arduino IDE installation folder instead of the sketchbook folder, as recommended in the instructions.
You seem to have a bad habit of messing with your Arduino IDE installation folder. You should never modify or add files to the Arduino IDE installation folder. The reason is that all changes you make to that location will be lost anytime you upgrade to a new version of the Arduino IDE and it also makes troubleshooting more difficult since you are working with a non-standard installation. Instead you should always install libraries and hardware packages to the sketchbook folder where they will persist through IDE updates. I recommend you to move any customized files out of the Arduino IDE installation folder and then reinstall the IDE to make sure you are working with a stock installation.
-
per1234, I'm sorry but you are wrong. I have never altered anything in the Arduino install folder. Everything that is in there was installed in there by the installer or the board manager.Code Gorilla– Code Gorilla2017年08月05日 13:21:15 +00:00Commented Aug 5, 2017 at 13:21
-
To get the IDE to allow me to select ESP32 chips I had to place the Espressif folder in "D:\Program Files(x86)\Arduino\hardware"
"D:\Program Files(x86)\Arduino\hardware" is your Arduino IDE installation folder, correct?per1234– per12342017年08月05日 19:24:45 +00:00Commented Aug 5, 2017 at 19:24 -
Then where do you have the Arduino IDE installed?per1234– per12342017年08月16日 19:59:09 +00:00Commented Aug 16, 2017 at 19:59
D:\Users\***\Documents\Arduino\hardware\espressif\esp32
and again, the same result the IDE does not pick up the ESP32 boards, but does pick up the esp8266 boards. If I move the libraries toD:\Program Files (x86)\Arduino\hardware
then the IDE detects the boards and when I compile the example I get a duplicate WIFI.h BUT it now picks the esp32 version. I think the problem is why doesn't it work when the esp32 folder is in My document?