PlatformIO Community

Grand Unified Libraries... Question?

There is something wrong here. My experience does not agree with the Official Experience. I’m in lab manager mode. This is a lab meeting. We need to know why the mice are dying.

I think I’ve learned how to use PlatformIO.
I’ve used the Arduino IDE before, and I’ve used a different compiler I can’t remember, and after watching it in PIO, I think I know how to use a compiler.
I’ve learned almost enough about C++.

So I’ve learned how to use it, but I can’t make it work because libraries can never be found.
When I started, I just installed the library using the PIO tool. I didn’t stop to think I might be installing them globally, but the PIO Community saw the cause of one of my library problems in a library known to be full of conflicts for another library I had to use. So it only kinda worked.

Then I put a copy of the library folder into the project’s /lib folder, and that kinda worked. But my cache of libraries is stale. I know I was using outdated libraries, and that led to conflicts. But many, many of my attempted uploads failed because of a missing library that was sitting comfortably in the /lib folder.
Today I wonder if this would have been more reliable if I’d download a fresh copy every time I included it. I like having a collection of libraries for the examples, so I’m going to have them anyway. May as well use them.

I learned that the compiler should read everything in /src, so I tried putting libraries in there. That didn’t work once, after a small handful of trials.

Norman lobbies very hard for lib_deps, so I tried that. Then I learned that this is one place in C++ where a space is tolerated. So when I removed the underscore from Adafruit_GFX, it was discovered. (Not sure which ones I tried first, but I was able to compile and upload a file to my R32.) So Lib_deps worked. I did a little dance. I got into other stuff, probably restarted the computer. When I returned, lib_deps no longer worked- across the three files I’ve been working with, which had only x minutes earlier worked. None of the lib_deps libraries were found.

When I type “Adafruit Something” under lib_deps, what happens?

I see a handful of places on the PC where libraries are downloaded. Is PIO pulling that file from its online location or from a local copy?

What am I actually seeing? Is there a log file somewhere? How does the lib_deps reference unmount? It goes from ‘connecting main.cpp with lib_dep = Adafruit BME680.h’ to ‘not connecting’. The memory addresses don’t change, do they?

Could my installation do this?
I’m pretty sure I already reinstalled. An installation could have a default storage location that doesn’t agree with another.

Is there a setting for “Make it fail 83% of the time” ?

Are there other questions with answers I should be asking?
Not interested in new questions with no answers. My known knows and known unknowns can’t comprise the whole thing. Unknown unknowns could outnumber the knowns, but they shouldn’t. This absolutely must boil down to something simple, finite.

I can’t be the only one to have this problem. I know this isn’t the general public, but people have to stat using PlatformIO pretty often, relative to the demographic.
But I’d really like to put this to bed. I feel like I’m wasting a resource.

Because this is what happens:
Untitled

Hi @Monsterthews (Joe).

When I looked at your project, I found problems, like these:

  • Header files for libraries in lib, but no sources - eg the Time library. In Scotland, where I’m from, we call that a half arsed install. :wink:

  • The lib folder was full of downloaded stuff. None of which was necessary. I deleted everything from the lib directory on receipt of your project.

  • We know about the spaces in the library names already, but I fixed those. I removed the built in ones not needed by the Uno, but which are needed by your other board.

  • I fixed the #include statement to replace angle brackets with double quotes.

Ok, the above, plus others I might have omitted, were what we Jocks (Scots) call PICNICs. (Problem In Chair, Not In Computer! :grin:)

The other problem I see with Arduino “migrants” is how much confusion the Arduino Environment generates due to doing lots of “stuff” in the background. (This is why I wrote my first book. No names here, search Apress.com if you are interested!)

Also, quite a few people are confused by the lib directory!

Looking at your code in the screenshot above, I see you have corrected the #include statements. But you are still getting errors. This is weird, so a few questions:

  • Did you clean out the contents of the project’s lib directory? If no, please do it now!

  • Did you delete the build and libdeps directories in the .pio directory? If not, please do it now.

  • Did you run a “clean” before building but after deleting the above? If not, you should do one. It’s the dustbin/trash can icon on the botton toolbar.

  • Uploads do not fail due to a missing/broken library. Are you using the upload tool button to compile then upload the sketch? If so, any compilation errors will simply upload the existing version of firmware.hex (or equivalent for your mictocontroller) . You should use the build tool button (a tick/check mark) not the upload one. That way you get the errors displayed and no wasted uploads (which reduce the lifespan of your controller’s flash RAM by the way).

Answer me all that, run the answers above and try another build, not upload. Let us know how you got on. It should work, plus, your Uno version of the project compiled perfectly time after time with my fixes as documented in your other thread.

If it compiles once for you, but not subsequently, something weird is going on in Windows 10 that I’m not seeing in Linux.

Cheers,
Norm.

1 Like

This morning the first thing I did was create a new project. I pasted in the code and made the lib_deps.

The libraries specified in lib_deps are missing and preventing compile.

This code was running on the WeMos last week. It uploaded using the improper methods I piled atop each other before converting to lib_deps, which doesn’t work here.

How can it not work HERE ?

It’s MS VS Code, which ought to work on a brand-new go-fast Windows 10 machine.

The file that wouldn’t compile is the one that was running on the WeMos.
The virgin project won’t compile either- I was expecting to find a ghost haunting that first file.

There are a whole lot of settings. I found a section with ‘multiple declarations’ and ‘multiple implementations’. They were set to ‘peek’. I changed it to ‘goto’.

Then I found this:
C_Cpp › Default: System Include Path

( Sync: Ignored)

The value to use for the system include path. If set, it overrides the system include path acquired via “compilerPath” and “compileCommands” settings.

It opens settings.json with a new line and a space for me to type in ‘goto’.

How badly did I just wreck it? There are more include path settings for me to mess up, but I’m going to stop here.

I’ve added a project to the jam: OTA firmware updates for the Esp32 machines. If I can get it uploaded to my DOIT Devkit, it will become much easier to use that device. As is, nobody can say how to reliably get it into upload mode.

Where does PIO live on my PC?

How do I uninstall it?

Ok, what does your ini file look like? What are the error messages please?

You are saying that using lib_deps, which works for lots of people, without problems, is not working for you. Then one of four things is possibly wrong:

  • There’s a bug in PlatformIO. Possible but unlikely given the numbers of people not having problems.

  • Your installation of either VSCode and/or the PlatformIO extension is borked. Again, possible.

  • Something you are doing is not 100% correct.

  • The libraries are not actually suitable for your device.

So, what is it? Post your ini file and errors for the compile, that would help.

“Who knows” is my honest answer. Which files have you been randomly changing things in? Do you know what you were changing? Or are you channeling my good lady wife and pressing buttons/changing stuff at random without knowing what is going on? :grin:

You always mention “upload”. Have you tried hitting the build icon/tool button first? I get the impression that you don’t do:

  1. Build
  2. Upload
  3. Test

Instead, you just do:

  1. Upload

Build the code first. Check the error messages, understand them, fix problems, get a clean compile, then and only then upload.

Have you tried the command line?

pio run -t clean cleans out any previously compiled object files etc.

pio run executed from within the project folder, will compile the code, downloading any framework files, libraries as necessary.

pio run -t upload will upload the compiled firmware.xxx file to the device. xxx varies according to platform.

If the above works, then the problem is in VSCode. If not, who knows! :frowning_face:

On Windows, probably C:\users\joe\.platformio.

Delete it. Empty recycle bin.

Recompile your new blank project. That will download the latest platform/framework/libraries as necessary.

Cheers,
Norm.

Thank you! I’m not going to continue investigating. I’m going to delete the folder from Users.
I’d love to be able to speak command line, but it can’t make sense so I’ll continue to avoid it. I got through setting up ESP-IDF, but it’s a black box.
But here’s a representative error::

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
---------------------------------------------------------------------------------------------------------

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 1.12.4 > Espressif ESP32 Dev Module
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.10004.200129 (1.0.4)
 - tool-esptoolpy 1.20600.0 (2.6.0)
 - toolchain-xtensa32 2.50200.80 (5.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Looking for Adafruit GFX library in registry
Warning! Library `{'name': 'Adafruit GFX', 'requirements': None}` has not been found in PlatformIO Registry.
You can ignore this message, if `{'name': 'Adafruit GFX', 'requirements': None}` is a built-in library (included in framework, SDK). E.g., SPI, Wire, etc.
Looking for Adafruit BME280 library in registry
Warning! Library `{'name': 'Adafruit BME280', 'requirements': None}` has not been found in PlatformIO Registry.
You can ignore this message, if `{'name': 'Adafruit BME280', 'requirements': None}` is a built-in library (included in framework, SDK). E.g., SPI, Wire, etc.
Found 30 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <Adafruit SSD1306> 2.4.0
|   |-- <Adafruit GFX Library> 1.10.1
|   |   |-- <Adafruit BusIO> 1.4.2
|   |   |   |-- <Wire> 1.0.1
|   |   |   |-- <SPI> 1.0
|   |   |-- <SPI> 1.0
|   |   |-- <Wire> 1.0.1
|   |-- <SPI> 1.0
|   |-- <Wire> 1.0.1
|-- <Adafruit BusIO> 1.4.2
|   |-- <Wire> 1.0.1
|   |-- <SPI> 1.0
|-- <Adafruit GFX Library> 1.10.1
|   |-- <Adafruit BusIO> 1.4.2
|   |   |-- <Wire> 1.0.1
|   |   |-- <SPI> 1.0
|   |-- <SPI> 1.0
|   |-- <Wire> 1.0.1
Building in release mode
Compiling .pio\build\esp32dev\src\main.cpp.o
src\main.cpp:10:29: fatal error: Adafruit_BME280.h: No such file or directory

*************************************************************************
* Looking for Adafruit_BME280.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:Adafruit_BME280.h"
* Web  > https://platformio.org/lib/search?query=header:Adafruit_BME280.h
*
*************************************************************************

compilation terminated.
Archiving .pio\build\esp32dev\lib0ac\libAdafruit GFX Library.a
Archiving .pio\build\esp32dev\lib7ea\libAdafruit SSD1306.a
Compiling .pio\build\esp32dev\FrameworkArduino\Esp.cpp.o
*** [.pio\build\esp32dev\src\main.cpp.o] Error 1
====================================== [FAILED]

ini:

[env:esp32dev]

platform = espressif32

board = esp32dev

framework = arduino

monitor_speed = 9600

lib_deps =

Adafruit GFX

Adafruit SSD1306

Adafruit BME280

Adafruit BusIO

The error appears to only say there’s no library.

Yeesh! >50,000 items recycled.

Just rebuilt PIO Core, and the lib_deps libraries are still unrecognized.

But only one of three libraries is giving an error.

I found the library for espressif32 at https://platformio.org/lib/show/166/Adafruit%20BME280%20Library, where it says This is a library for the BME280 humidity, temperature & pressure sensor. Designed specifically to work with the Adafruit BME280 Breakout
----> http://www.adafruit.com/products/2650

Are you using that actual device? In case it makes a difference.

You have some weird sh!t (technical term) going on there if you ask me! God only know what!

Which meand that lib_deps is working given that 3 out of 4 libraries are found and installed. Did you “clean” the project after rebuilding PlatformIO? And before running a build?

Given that I gave you the exact commands to type in, I’m puzzled by this comment.

Two thing to try:

Lose the blank lines between the names, if they are present, plus, given younare on PlatformIO 5.0.0, prefix the libraries with “adafruit/” as in:

lib_deps=
    adafruit/Adafruit GFX
    adafruit/Adafruit SSD1306
    adafruit/Adafruit BME280
    adafruit/Adafruit BusIO

Alternatively, it’s strange that the bme library cannot be found. What happens if you open a new terminal in VSCode and run this one command:

pio lib install "adafruit/Adafruit BME280 Library"

Exactly as above? This is what the lib_deps should be doing.

If it doesn’t barf with an error, use the toolbar buttons in VSCode to clean, build and upload.

Cheers,
Norm.

1- cleaned it. It says it removed things, maybe a list of eight.

2- entered your commands:
Windows PowerShell
Copyright © Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\joema\Documents\PlatformIO\Projects 1\BME280_OLED_R32> pio lib install “adafruit/Adafruit BME280 Library”
Library Storage: C:\Users\joema\Documents\PlatformIO\Projects 1\BME280_OLED_R32.pio\libdeps\esp32dev
Library Manager: Installing adafruit/Adafruit BME280 Library
Downloading [####################################] 100%
Library Manager: Adafruit BME280 Library @ 2.1.0 has been installed!
Library Manager: Installing dependencies…
Library Manager: Installing Adafruit Unified Sensor
Library Manager: Adafruit Unified Sensor @ 1.1.4 has been installed!
PS C:\Users\joema\Documents\PlatformIO\Projects 1\BME280_OLED_R32>

3- This is a BME280.

4- Given that I am trying to find the guard rails here in GUI land, now is not the time to try to bend my head in the command prompt direction too. Your instructions are probably perfect. I just don’t understand it. and until I can get libaries to load, I can’t do anything. i have three files that upload. One has only Servo as an include. and that’s a lib_deps now.

So it installed, but now I get this:

Building in release mode
Compiling .pio\build\esp32dev\src\main.cpp.o
Generating partitions .pio\build\esp32dev\partitions.bin
Compiling .pio\build\esp32dev\libba3\Wire\Wire.cpp.o
Compiling .pio\build\esp32dev\lib5a1\SPI\SPI.cpp.o
Compiling .pio\build\esp32dev\lib32c\Adafruit BusIO\Adafruit_BusIO_Register.cpp.o
Archiving .pio\build\esp32dev\lib5a1\libSPI.a
Compiling .pio\build\esp32dev\lib32c\Adafruit BusIO\Adafruit_I2CDevice.cpp.o
src\main.cpp:17:1: error: ‘Adafruit_BMP280’ does not name a type
Adafruit_BMP280 bmp;
^
src\main.cpp: In function ‘void setup()’:
src\main.cpp:21:3: error: ‘bmp’ was not declared in this scope
bmp.begin(); //Start the bmp
^
src\main.cpp: In function ‘void loop()’:
src\main.cpp:38:15: error: ‘bmp’ was not declared in this scope
float T = bmp.readTemperature(); //Read temperature in C
^
*** [.pio\build\esp32dev\src\main.cpp.o] Error 1
====================================== [FAILED] Took

This worked. It must not have BME280 installed.
‘bmp’ has to come from somewhere. It’s not in 280.h. Should I change that to ‘bme’?

But this is the declaration in this example:

“Adafruit_BMP280 bmp;”

One program that works is my Solar Tracker. Its only library is Servo.h.

And that’s on a Nano. Servo don’t do Esp32.

Morning Joe,

First up, good news the library and its dependency, got installed. And you successfully used the command line with no problems!

Given that all lib_deps does is to pass the library name(s) to a background pio lib install task, I can only assume that the adafruit/ prefix is needed on that library, for some reason.

Is you think that copying and pasting a couple of commands to test out a compile and build is difficult, best you don’t even think about C/C++ then, because that will fry your brains! :grin:

you are declaring a variable named bmp which is to be of type Adafruit_BMP280. The error is not about bmp but that the data type itself is not defined. Changing the name at random makes no difference.

Given there are no errors that the BME280 library header file(s) were not found, we should be able to safely assume that the actual data type defined is not Adafruit_BMP280. Unfortunately, the example sketch shows that it is.

I suspect missing headers? Do you have this in your sketch?

#include "Wire.h"
#include "SPI.h"
#include "Adafruit_Sensor.h"
#include "Adafruit_BME280.h"

The other bmp errors are caused by the first one. When that gets sorted, they will also vanish.

Cheers,
Norm.

But BME…

Re command prompts, the floor has fallen out again. I’m in worse shape than when I first began my PIO journey, when I didn’t know how to declare anything., because there’s a black box that won’t work. And I can’t bang on it with anything. Going into the shell is literally going out into the black darkness and adding factors of magnitude to the independent variables. Many fewer unknowns/unfamiliarities/trust zones in the GUI.

I’m going to follow up on the compatibilities angle, because we already know a lot of libraries are incompatible from Atmel to Esp.

Trouble is, all the ESP-32 documentation is from Espressif. It’s all just a bit over my head, but most in a way I can learn through translating the sentences. But it’s written for actual developers and it all ends up in the IDF.
I’ve been looking at IDF BLE scripts. I’ll find something I can lift.

But I was warned here in this forum earlier about committing this early to ESP-IDF because of the dearth of libraries.
I can make library writing a new project. It’s already been bugging me.

And then there’s the ESP Upload Tool. The Espressif utility writes your compiled files to memory addresses, and there are (as I recall) six fields for six simultaneous uploads. There’s a lot of program space, and there’s a second processor. But it has to compile.

So maybe this thing I want to do is hard because it’s hard.