I have followed the instructions in the course, as far as I can tell, but when I try to upload it, I get errors I can’t understand. It appears to be looking for a library which isn’t in the code or the platformio.ini file. The end of the upload process is shown here:-
Generating partitions .pio\build\esp32doit-devkit-v1\partitions.bin
Compiling .pio\build\esp32doit-devkit-v1\lib4f0\Adafruit BME280 Library\Adafruit_BME280.cpp.o
Archiving .pio\build\esp32doit-devkit-v1\libFrameworkArduinoVariant.a
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\Esp.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\FunctionalInterrupt.cpp.o
In file included from .pio\libdeps\esp32doit-devkit-v1\Adafruit BME280 Library\Adafruit_BME280.cpp:31:0:
.pio\libdeps\esp32doit-devkit-v1\Adafruit BME280 Library\Adafruit_BME280.h:26:29: fatal error: Adafruit_Sensor.h: No such
file or directory
*************************************************************************
* Looking for Adafruit_Sensor.h dependency? Check our library registry!
*
* CLI > platformio lib search “header:Adafruit_Sensor.h”
* Web > https://platformio.org/lib/search?query=header:Adafruit_Sensor.h
*
*************************************************************************
compilation terminated.
*** [.pio\build\esp32doit-devkit-v1\lib4f0\Adafruit BME280 Library\Adafruit_BME280.cpp.o] Error 1
=============================================== [FAILED] Took 6.35 seconds ===============================================The terminal process “C:\Users\Test\.platformio\penv\Scripts\platformio.exe ‘run’, ‘–target’, ‘upload'” terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
I have no idea what to do next. Can anyone help, please?
Hi Sara & thanks for your help. Here is the platformio.ini file:
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
monitor_speed = 115200
lib_deps = ESP Async WebServer
Hope this helps.
Tony
Hi.
You do not include all the needed libraries. Your file should be like this:
[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
monitor_speed = 115200
lib_deps = ESP Async WebServer
arduino-libraries/Arduino_JSON @ 0.1.0
adafruit/Adafruit BME280 Library @ ^2.1.0
adafruit/Adafruit Unified Sensor @ ^1.1.4
See page 355.
Let me know if this solves the issue.
Regards,
Sara
Ah, OK, thanks. I copied it from p156 as that is the exercise I’m on.
Why do I need to reference libraries that are not used in the sketch I’m writing? Do all libraries have to be referenced whether you are using them in the sketch or not?
It failed again:
Processing esp32doit-devkit-v1 (platform: espressif32; board: esp32doit-devkit-v1; framework: arduino)
————————————————————————————————————————–Verbose mode can be enabled via `-v, –verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32doit-devkit-v1.html
PLATFORM: Espressif 32 (3.1.0) > DOIT ESP32 DEVKIT V1
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
– framework-arduinoespressif32 3.10005.210223 (1.0.5)
– tool-esptoolpy 1.30000.201119 (3.0.0)
– tool-mkspiffs 2.230.0 (2.30)
– toolchain-xtensa32 2.50200.97 (5.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 30 compatible libraries
Scanning dependencies…
Dependency Graph
|– <Adafruit BME280 Library> 2.1.2
Building in release mode
Compiling .pio\build\esp32doit-devkit-v1\lib4f0\Adafruit BME280 Library\Adafruit_BME280.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\HardwareSerial.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\IPAddress.cpp.o
Compiling .pio\build\esp32doit-devkit-v1\FrameworkArduino\IPv6Address.cpp.o
In file included from .pio\libdeps\esp32doit-devkit-v1\Adafruit BME280 Library\Adafruit_BME280.cpp:31:0:
.pio\libdeps\esp32doit-devkit-v1\Adafruit BME280 Library\Adafruit_BME280.h:26:29: fatal error: Adafruit_Sensor.h: No such
file or directory
*************************************************************************
* Looking for Adafruit_Sensor.h dependency? Check our library registry!
*
* CLI > platformio lib search “header:Adafruit_Sensor.h”
* Web > https://platformio.org/lib/search?query=header:Adafruit_Sensor.h
*
*************************************************************************
compilation terminated.
*** [.pio\build\esp32doit-devkit-v1\lib4f0\Adafruit BME280 Library\Adafruit_BME280.cpp.o] Error 1
=============================================== [FAILED] Took 5.11 seconds ===============================================The terminal process “C:\Users\Test\.platformio\penv\Scripts\platformio.exe ‘run’, ‘–target’, ‘upload'” terminated with exit code: 1.
Hi again.
I’m sorry. I misunderstood the issue. I read that you were on project 3_1, instead of project 1_1.
You should not include libraries that you are not using.
So, you just need to include the library that you mentioned previously.
Are you sure you are running the right project? Because it seems to be looking for a BME280 library.
Check that you are running the code on page 157 and not another project that might be on the workspace. Close other projects that you might have on the same workspace.
I’m sorry for the confusion.
Regards,
Sara
No problem.
I’ve loaded the same code using Arduino IDE, without any extra libraries and it ran first time, so it must be something to do with VS Code or Platformio, but I have no idea where to start looking. It is so much more complicated than Arduino IDE, but I’m reluctant to give up on it at this stage as I’m sure it will have benefits further down the road.
I have 2 other projects in the same workspace, one is Blink_LED and the other is a project using an ESP8266 with an ADS1115, but I’ve been careful to make sure I’m loading the right one. Neither of these use a BME280..
I’ll remove both of these projects from the workspace and try again.
Can you only have one project at a time in the workspace?
Regards,
Tony
I’ve now created a new, blank project having deleted the previious file. Immediately, before entering any code, I get the following warnings appear in the PROBLEMS box:
{}c_cpp_properties.json .vscode 2
Cannot find “C:\Users\Test\.platformio\packages\framework-arduinoespressif32\tools\sdk\include\nimble”.
Cannot find “C:\Users\Test\.platformio\packages\framework-arduinoespressif32\tools\sdk\include\nimble”.
They seem to refer to something in the .vscode folder, but I haven’t put anything in there. It is put there when you set up a new project.and there are dire warnings not to change anything.
Do I need to reinstall something and if so, what?
Regards,
Tony
I’ve ignored these warnings and the code has now uploaded successfully. I’ve downloded the code example zip file provided with the course, put that in the platformio projects folder, having deleted everything else and it uploads to the ESP32 without error. The two above warnings above are still there, however.
Thanks for your help. I’ll keep trying with VS Code a little longer & see if I can find my way around it
Hi again.
In my opinion, VS Code is a bit complicated when we’re using it for the first time. After getting used to it, you won’t want to go back using Arduino IDE.
Nonetheless, I understand that people might get frustrated and want to use Arduino IDE instead for its simplicity. That’s why we also give instructions on how to use Arduino IDE.
You can have more than one project in the workspace. I recommend that you have only one because when we’re not used to VSCode, we might be writing code on the wrong files (files from the other project).
That’s a warning highlighted in yellow, right? You can ignore that warning. It seems to be an issue related to some espressif updates. Everything continues to work fine. At least for me. I also get that error. It should go away in a few days.
You can see a discussion of that problem here: https://community.platformio.org/t/cannot-find-nimble-since-espressif32-update-a-few-days-ago/19721/2
Try to follow that project from the start and see if you can get it working.
Regards,
Sara
Great!
I’m glad it is working now.
I’ll mark this issue as resolved.
If you need further help, you just need to open a new question in our forum.
Regards,
Sara