Lib_deps- can't get PlatformIO to recognize these libraries

Can’t wait to get past this.

It’s driving me crazy. I can’t run any of my Arduino scripts- I can’t put an OLED in my new scripts, because the libraries are missing.

I’ve downloaded them and put them in the lb folder.
I’ve pasted the github URL into the .ini file.

It’s not working. WHY???

;

; 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

lib_deps =

https://github.com/espressif/esp-iot-solution/blob/master/components/features/touchpad/include/iot_touchpad.h

A library is defined by its name, id or the link to the repository. You put a link to the Github front-end to a header file inside the project there. That’s not going to work :sweat_smile:. See docs and PlatformIO Registry.

Also you have specified framework = arduino and attempt the inclusion of what looks like an ESP-IDF derivative (from the esp-iot-solution description page). That’s also not going to work since then you’d need framework = espidf (docs).

Are you sure you want to work with the esp-iot-solution framework? Since this uses framework = espidf, you would have to follow the documentation on integrating the components into your project.

Since you’re talking about running your Arduino “scripts” however I think you’re just looking for how to get an Arduino-ESP32 + OLED project going. The repository mentions the SSD1306, so you can use the PlatformIO Registry library for Arduino to be able to do that.

If you want to get your existing “scripts” running you’ll need to use the same library, of course. Since you haven’t shown any code I can’t identifiy which library that code needs though :sweat_smile:.

1 Like

I think you’ve helped me before. I appreciate your presence.

There are two things, as usual. The first thing I need to learn, in order to get up to my Arduino speed in PlatformIO is how to include a library.

The first photo is the #includes. The second is the lib folder, where those .h files sit.

I pasted the URL in the .ini, following posted instructions, without being careful about the actual file linked. I figured it wouldn’t work until I fiddle with it.

lib

I used the Libraries utility. The .h file is usually in it, but I got these from GitHub.

I see, you’re using https://github.com/espressif/esp-iot-solution/blob/master/examples/oled_screen_module/main/main.cpp. This code isn’t targeted at Arduino though (no #include <Arduino.h>).

https://github.com/espressif/esp-iot-solution/blob/master/examples/oled_screen_module/main/main.cpp#L12

Are you really sure you need esp-iot-solution and thus ESP-IDF instead of Arduino? The example firmware above expects a APDS-9960 gesture sensor (https://www.sparkfun.com/products/12787), an HTS221 humidity and tmperature sensor, a capacitive touch screen and a SSD1306 I2C OLED display. Is that your hardware setup?

Of course you can get the firmware to compile after adding each component (link was above) (not via lib/ for ESP-IDF), but I’m just checking with you whether that firmware and framework makes any sense at all for what you want to do.

Oh yeah- the framework. Let’s assume I’m working in Arduino. I just started messing around with the ESP stuff.

The other problem is stuff I know is in the libraries not recognized:

I can strip out all of those sensors. Forget about the framework, and please forget about this individual script (a script is a set of instructions. That’s the word for EVERY computer program.) This is all about me learning how to use libraries in PlatformIO.

This is a very reproducible error- it’s the only thing I can do above Blink.

I believe if I understand libraries better, I’ll be able to figure out why commands that work in Arduino won’t work in PlatformIO.

I know Arduino does a lot of hand-holding, so I think this is a good problem for me to have now.

Thanks for that 1306 link.
This has been the hangup:

Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &Wire);

Where is this code from?

Can’t tell you. This is the header of the file in the images, but this problem of mine isn’t file specific. It’s about getting the library in, and then getting the commands in those libraries to work in PlatformIO instead of Arduino.
.:

/*********************************************************************

 * 

 * This example is for a 128x64 size display using I2C to communicate

 * 3 pins are required to interface (2 I2C and one reset)

 * 

 *********************************************************************/

Is there a resource: “The little things nobody told you” ?

Of course I’m adding Arduino.h to everything, but it isn’t helping. I added it to this script and still get the not-recognized nonsense.

I’m just going to keep picking at this library stuff. I can’t be far. That’s the most frustrating part.

Seriously: What the heck is going on???

Your Gateway to Embedded Software Development Excellence — PlatformIO latest documentation in general and especially Redirecting... as I have linked above. Also the FAQ. There are also loads of example projects.

You may also find it interesting to add lib_extra_dirs (docs) to your platformio.ini configuration as e.g.

[env]
; default arduino IDE library path for windows
lib_extra_dirs = ${sysenv.HOMEDRIVE}${sysenv.HOMEPATH}\Documents\Arduino\libraries

this will make all your previously installed Arduino IDE libraries visible PlatformIO, though it is recommended to do per-project library management via lib_deps to avoid global state.

Please paste code as text in Markdown format so that people can simply copy paste them.

I have no problems compiling this code in PlatformIO with

platformio.ini

[env:uno]
platform = atmelavr
board = uno
framework = arduino
lib_deps = 
    Adafruit SSD1306
    Adafruit GFX Library

src\main.cpp

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Fonts/FreeSerif9pt7b.h>

#define SCREEN_WIDTH 128 
#define SCREEN_HEIGHT 64

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);

void setup() {
  Serial.begin(115200);

  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  delay(2000);
  display.clearDisplay();

  display.setFont(&FreeSerif9pt7b);
  display.setTextColor(WHITE);
  display.setCursor(5, 15);
  // Display static text
  display.println("28 May, 4:22pm");
  display.println("23C, 0% Hum");
  display.println("Hello world!");
  display.display();
}

void loop() { }

1 Like

Next time, try scrolling up the compile log, as you might get more info as to the reason for the error…

e.g. Assuming your error in the online Arduino IDE was caused for the same reason mine was, it’s because it used the wrong library. :face_vomiting: :man_facepalming:

By trial and error, it seems you need to format the library includes this way and then the correct library will be installed (figured it out after seeing how the online library manager added the comment above the library include) when using Arduino Create … but even then it seems a bit hit and miss as to whether it will work or not not work. Wonder how you’re supposed to know this… hit the monitor with your head enough times?

// Adafruit GFX Library - Version: 1.9.0
#include <Adafruit_GFX.h>
// Adafruit SSD1306 - Version: 2.3.1
#include <Adafruit_SSD1306.h>

No wonder I use PlatformIO + VSCode! :laughing:

1 Like

Thank you very much for your help. It’s been hard to articulate exactly what the problems are, because I think it’s all the same problem manifest in different symptoms. I’m going to take what you wrote and fiddle with it. I know that’s where the problem is, but my knowledge of what’s supposed to happen isn’t big enough. I can’t tell when I’m doing something right.

You may have cleared it up for me. If not, I figured out a way to present it in an orderly way.
Thanks again.

1 Like