PlatformIO Community

Libraries still not adding. What am I doing wrong?

This problem doesn’t go away. According to Espressif, most sensor libraries should work. There aren’t special ESP32 libraries for Adafruit sensors.

INI:


[env:wemos_d1_mini32]
platform = espressif32
board = wemos_d1_mini32
framework = arduino
monitor_speed = 9600
lib_deps=
    WiFi
    ESPAsyncWebServer
    Adafruit_Sensor
    DHT

Code:

#include <Arduino.h>

/*********
  Rui Santos
  Complete project details at https://randomnerdtutorials.com  
*********/

// Import required libraries
#include "WiFi.h"
#include "ESPAsyncWebServer.h"
#include <Adafruit/Adafruit_Sensor.h>
#include <Adafruit/DHT.h>

// Replace with your network credentials
const char *ssid = "Fishing24";
const char *password = "Fishing$602";

#define DHTPIN 1 // Digital pin connected to the DHT sensor

// Uncomment the type of sensor in use:
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE    DHT22     // DHT 22 (AM2302)
//#define DHTTYPE    DHT21     // DHT 21 (AM2301)

DHT dht(DHTPIN, DHTTYPE);

// Create AsyncWebServer object on port 80
AsyncWebServer server(80);

String readDHTTemperature()
{
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  //float t = dht.readTemperature(true);
  // Check if any reads failed and exit early (to try again).
  if (isnan(t))
  {
    Serial.println("Failed to read from DHT sensor!");
    return "--";
  }
  else
  {
    Serial.println(t);
    return String(t);
  }
}

String readDHTHumidity()
{
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  if (isnan(h))
  {
    Serial.println("Failed to read from DHT sensor!");
    return "--";
  }
  else
  {
    Serial.println(h);
    return String(h);
  }
}

const char index_html[] PROGMEM = R"rawliteral(
<!DOCTYPE HTML><html>
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
  <style>
    html {
     font-family: Arial;
     display: inline-block;
     margin: 0px auto;
     text-align: center;
    }
    h2 { font-size: 3.0rem; }
    p { font-size: 3.0rem; }
    .units { font-size: 1.2rem; }
    .dht-labels{
      font-size: 1.5rem;
      vertical-align:middle;
      padding-bottom: 15px;
    }
  </style>
</head>
<body>
  <h2>ESP32 DHT Server</h2>
  <p>
    <i class="fas fa-thermometer-half" style="color:#059e8a;"></i> 
    <span class="dht-labels">Temperature</span> 
    <span id="temperature">%TEMPERATURE%</span>
    <sup class="units">&deg;C</sup>
  </p>
  <p>
    <i class="fas fa-tint" style="color:#00add6;"></i> 
    <span class="dht-labels">Humidity</span>
    <span id="humidity">%HUMIDITY%</span>
    <sup class="units">%</sup>
  </p>
</body>
<script>
setInterval(function ( ) {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("temperature").innerHTML = this.responseText;
    }
  };
  xhttp.open("GET", "/temperature", true);
  xhttp.send();
}, 10000 ) ;

setInterval(function ( ) {
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
      document.getElementById("humidity").innerHTML = this.responseText;
    }
  };
  xhttp.open("GET", "/humidity", true);
  xhttp.send();
}, 10000 ) ;
</script>
</html>)rawliteral";

// Replaces placeholder with DHT values
String processor(const String &var)
{
  //Serial.println(var);
  if (var == "TEMPERATURE")
  {
    return readDHTTemperature();
  }
  else if (var == "HUMIDITY")
  {
    return readDHTHumidity();
  }
  return String();
}

void setup()
{
  // Serial port for debugging purposes
  Serial.begin(115200);

  dht.begin();

  // Connect to Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(1000);
    Serial.println("Connecting to WiFi..");
  }

  // Print ESP32 Local IP Address
  Serial.println(WiFi.localIP());

  // Route for root / web page
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
    request->send_P(200, "text/html", index_html, processor);
  });
  server.on("/temperature", HTTP_GET, [](AsyncWebServerRequest *request) {
    request->send_P(200, "text/plain", readDHTTemperature().c_str());
  });
  server.on("/humidity", HTTP_GET, [](AsyncWebServerRequest *request) {
    request->send_P(200, "text/plain", readDHTHumidity().c_str());
  });

  // Start server
  server.begin();
}

void loop()
{
}

If I try to use the library add GUI, it asks if I want to add it to a project. It offers me three projects, none of which are open. So I can’t ‘add it to the project.’

Oops!

Now go and change your password!

The important terms are most and should!

We seem to be going round in circles? You need the Adafruit/ bit adding to the library name in lib_deps and removing from #include.

This link, https://platformio.org/lib/show/31/Adafruit%20Unified%20Sensor, shows the command to install the library by name. Take note of the name, it appears to be adafruit/Adafruit Unified Sensor.

The link also shows examples, which show the correct header file to include. And a list of all the header files in the library.

Use the link I gave you in another thread to search for the libraries you need and you will be given the names and correct header files easily. https://platformio.org/lib/search

I checked, (searched), for this ESPAsyncWebServer platform:espressif32 and got lots of results, so you would need to pick the correct one.

When you say “libraries still not adding” what actual errors are you seeing? Assuming that the instructions above don’t fix the problem.

I can’t comment as I don’t use the GUI. However, in VSCode, open a new terminal, type pio lib install "adafruit/Adafruit Unified Sensor" and it installs into the current project is to are located in one of course!

I think you have had so many different threads on the same problems, you are not seeing or reading the replies. This is either the 3rd or 4th time I’ve told you about library names and headers, and how to find the correct details, and you still get it wrong.

lib_deps works when given correct details. That’s not to say that it is bug free of course, nothing ever is, but it’s not lib_deps which is causing your problems.

Now, go search for your required library names, and try using the details returned, to see if it now works.

Cheers,
Norm.

1 Like

Part of PlatformIO (Home, Inspect, Libraries UI, Boards UI etc.) is currently not fully integrated into Visual Studio Code. It’s basically an application that appears in a VSC window but runs separately. And it has no information about what projects are currently open. So it just displays a list of projects that have been created in the past with the project wizard.

This weak integration is unfortunate and I have proposed to improve it. I hope the PlatformIO team will find to do it. The reason for the weak integration is that the separate application is independent of the IDE (Visual Studio Code, Atom, CLion etc.).

You have two options now:

  1. Open Projects & Configurations from the QUICK ACCESS view, click Add Existing, navigate to your project and open it. PlatformIO is now aware about your project and will offer it as one of the options when you click Add to Project.

  2. Add the library manually to platformio.ini. When you search for a library and click one of the search result, several tabs are shown. One of them is Installation. It shows the exact line you need to add to platformio.ini.

1 Like

Thanks- but what’s the matter with that ssid code ? Is it the dollar sign?

I did not know where to put the adafruit/. Thanks again.

Thank you. Anything that works helps.

Nope. You just put your SSID and password on a public forum. Never a good idea.

Sound like you got it working now. The libraries I mean!

Cheers,
Norm.

1 Like

I fixed the Adafruit/, and the libraries are no longer squiggled. I get this error, and when I clikc on the linked “adafruit.Adafruit SSD1306 Library”, i see this:

Untitled

I’ve selected all of the .h files, and nothing helps it compile. How is this supposed to work?
I already added this library using the ‘add library to project’ button, but it didn’t do anything.

Processing wemos_d1_mini32 (platform: espressif32; board: wemos_d1_mini32; framework: arduino)

Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/wemos_d1_mini32.html
PLATFORM: Espressif 32 (2.0.0) > WeMos D1 MINI ESP32
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
    Library Manager: Installing adafruit/Adafruit SSD1306 Library
    KeyError: ‘versions’:
    File “C:\Users\joema.platformio\penv\lib\site-packages\platformio\builder\main.py”, line 169:
    env.SConscript("$BUILD_SCRIPT")
    File “C:\Users\joema.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Script\SConscript.py”, line 598:
    return _SConscript(self.fs

It’s the ‘Versions’ problem again. Why isn’t it just going to the newest 1306 library?
I gave up and installed it in my /lib folder with the correct size. Others get commented out.

It found 1306, so of course it’s the next one:

Archiving .pio\build\wemos_d1_mini32\lib5a1\libSPI.a
Compiling .pio\build\wemos_d1_mini32\lib9d0\Adafruit BME680 Library\Adafruit_BME680.cpp.o
Archiving .pio\build\wemos_d1_mini32\lib746\libAdafruit Unified Sensor.a
.pio\libdeps\wemos_d1_mini32\Adafruit BME680 Library\Adafruit_BME680.cpp: In member function ‘bool Adafruit_BME680::endReading()’:
.pio\libdeps\wemos_d1_mini32\Adafruit BME680 Library\Adafruit_BME680.cpp:418:20: warning: overflow in implicit constant conversion [-Woverflow]
gas_resistance = NAN;
^
Compiling .pio\build\wemos_d1_mini32\lib9d0\Adafruit BME680 Library\bme680.c.o
Compiling .pio\build\wemos_d1_mini32\lib81f\Adafruit GFX Library\Adafruit_GFX.cpp.o
Archiving .pio\build\wemos_d1_mini32\libba3\libWire.a
Compiling .pio\build\wemos_d1_mini32\lib81f\Adafruit GFX Library\Adafruit_GrayOLED.cpp.o
Compiling .pio\build\wemos_d1_mini32\lib81f\Adafruit GFX Library\Adafruit_SPITFT.cpp.o
In file included from .pio\libdeps\wemos_d1_mini32\Adafruit GFX Library\Adafruit_GrayOLED.cpp:20:0:
.pio\libdeps\wemos_d1_mini32\Adafruit GFX Library\Adafruit_GrayOLED.h:30:32: fatal error: Adafruit_I2CDevice.h: No such file or directory



compilation terminated.
Archiving .pio\build\wemos_d1_mini32\lib9d0\libAdafruit BME680 Library.a

Now it’s back to1306:
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Library Manager: Installing adafruit/Adafruit SSD1306 Library
KeyError: ‘versions’:
File “C:\Users\joema.platformio\penv\lib\site-packages\platformio\builder\main.py”, line 169:
env.SConscript("$BUILD_SCRIPT")
File “C:\Users\joema.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Script\SConscript.py”, line 598:
return _SConscript(self.fs, *files, **subst_kw)
File “C:\Users\joema.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Script\SConscript.py”, line 287:
exec(compile(scriptdata, scriptname, ‘exec’), call_stack[-1].globals)
File “C:\Users\joema.platformio\platforms\espressif32\builder\main.py”, line 223:
target_elf = env.BuildProgram()
File “C:\Users\joema.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Environment.py”, line 219:
return self.method(*nargs, **kwargs)
File “C:\Users\joema.platformio\penv\lib\site-packages\platformio\builder\tools\platformio.py”, line 62:
env.ProcessProjectDeps()
File “C:\Users\joema.platformio\packages\tool-scons\scons-local-4.0.1\SCons\Environment.py”, line 219:
return self.method(*nargs, **kwargs)
File “C:\Users\joema.platformio\penv\lib\site-packages\platformio\builder\tools\platformio.py”, line 140:
project_lib_builder = env.ConfigureProjectLibBuilder()
File "C:\Users\joema.platformi

Here’s what I did:

Sorry folks, this is a long post. @Monsterthews : Read it all please.

TL;DR

In summary, lib_deps works perfectly when you set it up correctly and when you include the correct header file names in your source code!

Gory Details, Step by Step…

mkdir -p  SourceCode/temp/Joe/Library_adding
cd SourceCode/temp/Joe/Library_adding
pio init --board wemos_d1_mini32

Next, I edited the platformio.ini file in one shell session and left it in editing mode while I carried on with the following.

Opened the Chrome Browser and navigated to https://platformio.org/lib.

Note: In all of the following, each individual library page holds details of the packages and frameworks which they are compatible with. I checked each of the libraries I chose for the “Arduino” framework - as that’s what’s you are using, and the “Espressif 32” platform. They are all compatible.

WIFI Library

WARNING: This library is apparently not needed as it is built in. See following post from @pfeerick

Search for “wifi platform:espressif32” I get lots of hits. Scroll down until I find “Wifi by Arduino”. Right click the name, open in new tab.

On the new tab I see that the installation instructions are:

pio lib install "arduino-libraries/WiFi"

This tells me that the name of the library is “arduino-libraries/WiFi” so that’s what I put into the platformio.ini file.

ESPAsyncWebServer Library

Search for “ESPAsyncWebServer platform:espressif32”. Again, lots of libraries so scroll down. I see this one “ESPAsyncWebServer-esphome by Hristo Gochkov” so I choose it ove his/her other one with a similar name as this one has more downloads. They can’t all be wrong?. Right click the name and open in new tab again.

On the new tab the instructions to install are:

pio lib install "ottowinter/ESPAsyncWebServer-esphome"

Yes, the packager’s name is different, but no worries. Copy the name “ottowinter/ESPAsyncWebServer-esphome” into platformio.ini.

Adafruit_Sensor Library

You should be seeing a pattern developing? If not, then IT and micro controllers are not for you! :wink:

Do the search for “Adafruit_sensor platform:espressif32” and the first hit is this one “Adafruit Unified Sensor by Adafruit”. Right click, open in new tab as before.

The name is given as “adafruit/Adafruit Unified Sensor”, so that goes into the platformio.ini file.

DHT Library.

You can probably guess that I searched for “DHT platform:espressif32”. The first hit is the library above, “Adafruit Sensor Library” so, it appears that we don’t need this library any more.

Delete DHT from the ini file.

After all that, your platformio.ini looks like this:

[env:wemos_d1_mini32]
platform = espressif32
board = wemos_d1_mini32
framework = arduino
monitor_speed = 9600
lib_deps=
    arduino-libraries/WiFi                  
    ottowinter/ESPAsyncWebServer-esphome
    adafruit/Adafruit Unified Sensor

Save the platformio.ini changes, and exit from the editor.

First Compile.

I copied your code into the src folder as main.cpp, saved it, and ran a test build.

pio run

So, all went well at the start, I now have the various platform and framework files installed on my system, but the code compilation itself failed. Brief extracts of the first compilation follow. I’ve not shown the bumff about installing the tools etc, just the library dependency finder and compilation. First, libraries:

Processing wemos_d1_mini32 (platform: espressif32; board: wemos_d1_mini32; framework: arduino)

...

LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Library Manager: Installing arduino-libraries/WiFi
Library Manager: WiFi @ 1.2.7 has been installed!

Library Manager: Installing ottowinter/ESPAsyncWebServer-esphome
Library Manager: ESPAsyncWebServer-esphome @ 1.2.7 has been installed!
Library Manager: Installing dependencies...
Library Manager: Installing ESPAsyncTCP-esphome
Library Manager: ESPAsyncTCP-esphome @ 1.2.3 has been installed!
Library Manager: Installing AsyncTCP-esphome
Library Manager: AsyncTCP-esphome @ 1.1.1 has been installed!

Library Manager: Installing Hash
Warning! Could not find the package with 'Hash' requirements for your system 'linux_x86_64'

Library Manager: Installing adafruit/Adafruit Unified Sensor
Library Manager: Adafruit Unified Sensor @ 1.1.4 has been installed!

Found 30 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <WiFi> 1.2.7
|   |-- <SPI> 1.0
|-- <ESPAsyncWebServer-esphome> 1.2.7
|   |-- <AsyncTCP-esphome> 1.1.1
|   |-- <FS> 1.0
|   |-- <WiFi> 1.2.7
|   |   |-- <SPI> 1.0
|-- <Adafruit Unified Sensor> 1.1.4

I’m ignoring this one for now, I’ll fix it later if I need to. I’ve seen those warnings previoulsy, and everything has been fine:

Library Manager: Installing Hash
Warning! Could not find the package with 'Hash' requirements for your system 'linux_x86_64'

Then the build itself:

Building in release mode
Compiling .pio/build/wemos_d1_mini32/src/main.cpp.o
Generating partitions .pio/build/wemos_d1_mini32/partitions.bin
Compiling .pio/build/wemos_d1_mini32/libaae/SPI/SPI.cpp.o
src/main.cpp:11:38: fatal error: Adafruit/Adafruit_Sensor.h: No such file or directory
compilation terminated.
*** [.pio/build/wemos_d1_mini32/src/main.cpp.o] Error 1
========================= [FAILED] Took 25.20 seconds =========================

So, I can see this message fatal error: Adafruit/Adafruit_Sensor.h: No such file or directory which is a dead giveaway, if you read it. That file does not exist and the reason is clear, the header file is not named `Adafruit/Adafruit_Sensor.h" it is named as it tells you on the library page we opened in a separate tab above. Look at the example code or click on the “headers” tab to see exactly what header file name you should be including:

Adafruit_Sensor.h

Fix the code:

#include "Adafruit_Sensor.h"
#include "DHT.h"

You will note double quotes - which I might have mentioned a number of times previously?

I’ve fixed the DHT header too.

Second Compile.

The second compile resulted in the following:

Processing wemos_d1_mini32 (platform: espressif32; board: wemos_d1_mini32; framework: arduino)
--------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/wemos_d1_mini32.html
PLATFORM: Espressif 32 (2.0.0) > WeMos D1 MINI ESP32
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
Found 30 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <WiFi> 1.2.7
|   |-- <SPI> 1.0
|-- <ESPAsyncWebServer-esphome> 1.2.7
|   |-- <AsyncTCP-esphome> 1.1.1
|   |-- <FS> 1.0
|   |-- <WiFi> 1.2.7
|   |   |-- <SPI> 1.0
|-- <Adafruit Unified Sensor> 1.1.4
Building in release mode
Compiling .pio/build/wemos_d1_mini32/src/main.cpp.o
Compiling .pio/build/wemos_d1_mini32/lib43e/WiFi/WiFiClient.cpp.o
src/main.cpp:12:17: fatal error: DHT.h: No such file or directory

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

Hmmm, looks like the details of the Adafruit Sensor library may have been telling porkies, and a separate DHT library is required after all. Note this bit at the end though:

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

Let’s try following the instructions. Copy the link and paste into the browser, which is still open.

The top hit is “DHT sensor library by Adafruit” and that looks to be what we are after. Follow the instructions above to open the details page in a new tab, and we can now edit our platformio.ini file to look like this:

[env:wemos_d1_mini32]
platform = espressif32
board = wemos_d1_mini32
framework = arduino
monitor_speed = 9600
lib_deps=
    arduino-libraries/WiFi
    ottowinter/ESPAsyncWebServer-esphome
    adafruit/Adafruit Unified Sensor
    adafruit/DHT sensor library

Check the “headers” tab for the libray, and/or the example code provided, and we see that we need #include "DHT.H", so that’s lucky as we already have that in src/main.cpp.

Third Compile.

The third compilation resulted in this output for the library dependency finder:

LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Library Manager: Installing adafruit/DHT sensor library
Library Manager: DHT sensor library @ 1.3.10 has been installed!
Library Manager: Installing dependencies...
Library Manager: Adafruit Unified Sensor @ 1.1.4 is already installed
Found 31 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <WiFi> 1.2.7
|   |-- <SPI> 1.0
|-- <ESPAsyncWebServer-esphome> 1.2.7
|   |-- <AsyncTCP-esphome> 1.1.1
|   |-- <FS> 1.0
|   |-- <WiFi> 1.2.7
|   |   |-- <SPI> 1.0
|-- <Adafruit Unified Sensor> 1.1.4
|-- <DHT sensor library> 1.3.10
|   |-- <Adafruit Unified Sensor> 1.1.4

So, the DHT library is installed and it’s only known dependency is already there from the first compilation. We should be good to go now.

The the actual compilation, says otherwise though:

Building in release mode
Compiling .pio/build/wemos_d1_mini32/src/main.cpp.o
Generating partitions .pio/build/wemos_d1_mini32/partitions.bin
Compiling .pio/build/wemos_d1_mini32/libaae/SPI/SPI.cpp.o
Archiving .pio/build/wemos_d1_mini32/libaae/libSPI.a
Indexing .pio/build/wemos_d1_mini32/libaae/libSPI.a
Compiling .pio/build/wemos_d1_mini32/lib43e/WiFi/WiFi.cpp.o
src/main.cpp: In function 'void setup()':
src/main.cpp:151:28: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
   WiFi.begin(ssid, password);
                            ^
In file included from src/main.cpp:9:0:
.pio/libdeps/wemos_d1_mini32/WiFi/src/WiFi.h:79:9: note:   initializing argument 1 of 'int WiFiClass::begin(char*, const char*)'
     int begin(char* ssid, const char *passphrase);
         ^
*** [.pio/build/wemos_d1_mini32/src/main.cpp.o] Error 1
========================== [FAILED] Took 3.87 seconds ==========================

No problem a simple error. The WiFi.begin() function requires a password to be not const, so we have to declare it or cast it as such. The function is, to my mind, incorrectly written as a WiFi password, and SSID, shouldn’t ever be changed, only used in a read-only manner. However, this isn’t my library, so we have to “unconst” your const. Edit src/main.cpp and change it to this:

// Replace with your network credentials
char *ssid = "Fishing24";
char *password = "Fishing$602";

Fourth Compile

Running another build, pio run, compiled “cleanly”, but with a few warnings:

src/main.cpp:15:14: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 char *ssid = "Fishing24";
              ^
src/main.cpp:16:18: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
 char *password = "Fishing$602";
                  ^

These we can worry/ignore/fix later.

These, on the other hand, do worry me:

.pio/libdeps/wemos_d1_mini32/WiFi/src/utility/spi_drv.cpp: In static member function 'static char SpiDrv::spiTransfer(char)':
.pio/libdeps/wemos_d1_mini32/WiFi/src/utility/spi_drv.cpp:36:78: warning: integer overflow in expression [-Woverflow]
 #define DELAY_SPI(X) { int ii=0; do { asm volatile("nop"); } while (++ii < (X*F_CPU/16000000)); }
                                                                              ^
.pio/libdeps/wemos_d1_mini32/WiFi/src/utility/spi_drv.cpp:37:26: note: in expansion of macro 'DELAY_SPI'
 #define DELAY_TRANSFER() DELAY_SPI(10)

These messages are warning of a potential integer overflow when the DELAY_TRANSFER macro is expanded to become DELAY_SPI(10) which expands to:

{
    int ii = 0;
    do {
        asm volatile("nop");
    } while (++ii < (10 * F_CPU / 16000000);
}

This is cr4p (:poop: :poop:) code as an int isn’t going to get as high as that. It’s an operator precedence thing - the multiply gets done before the divide. Even on an Arduino Uno, the clock (F_CPU) is 16,000,000 and 10 times that is 160,000,000. If that doesn’t fit into sizeof(int) on your device, it’s game over! I think it should be this instead:

{
    int ii = 0;
    do {
        asm volatile("nop");
    } while (++ii < (10 * (F_CPU / 16000000));
}

Which means that the define of DELAY_SPI(X) should be:

 #define DELAY_SPI(X) { int ii=0; do { asm volatile("nop"); } while (++ii < (X*(F_CPU/16000000))); }

So that the division is done first, and results in 1 for an Uno, so 10 * 1 will fit into an int whereas 10 * F_CPU will most likely not. (Uno ints are 16 bits only. Wemos d1 mini might be different?).

Anyway, it is a warning and will either work or it won’t. If your SPI doesn’t work, this is a probable cause. Change to a better library or log a bug.

There are other concerning warnings that I’d like to get rid of before committing code to silicon, but as I don’t have a Wemos D1 Mini, It’s not my problem! :grin:

The end of the compilation says this:

...
Archiving .pio/build/wemos_d1_mini32/libFrameworkArduino.a
Indexing .pio/build/wemos_d1_mini32/libFrameworkArduino.a
Linking .pio/build/wemos_d1_mini32/firmware.elf
Retrieving maximum program size .pio/build/wemos_d1_mini32/firmware.elf
Checking size .pio/build/wemos_d1_mini32/firmware.elf
Building .pio/build/wemos_d1_mini32/firmware.bin
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]   5.3% (used 17468 bytes from 327680 bytes)
Flash: [===       ]  29.2% (used 382542 bytes from 1310720 bytes)
esptool.py v2.6
========================= [SUCCESS] Took 25.87 seconds =========================

So, it works. Lib_deps just works, that’s it’s job. If it doesn’t work for you then I’m afraid, as I have shown, you are doing something incorrectly.

Cheers,
Norm.

2 Likes

Only one issue with your detail post Norman… don’t install the WiFi library… it’s a built-in library by the arduino-esp32 board support package - as opposed to the ESP8266Wifi library used on the ESP8266 BSP. Not confusing at all. :open_mouth:

Wonder if you caught a :fish: with this post, or will need to :fishing_pole_and_fish: some more… :laughing:

Thanks for that. I don’t have the device so I can’t tell if it would work. That might account for the const problem also. Thanks.

As for fishing, who knows! You know what they say:

Give a man a fish and you’ll feed him for a day.
Teach a man to fish and he’ll sit around in a boat all day drinking beer!

Cheers,
Norm.

1 Like

Thank you Norm. The ‘how we do stuff here’ parts are incredibly valuable to me, because I’m a molecular biologist who builds robots other people program. I posted a question this morning about serial gibberish in a central when the peripheral is speaking clearly. But I’m going to spend the day on your response. There’s background to it, so my superficial understandings haven’t painted the whole picture.

I’m actually going to priint it.

1 Like

Hi Joe,

If I ever have a question about molecular biology, I’ll come looking for you. :wink:

Cheers,
Norm.

It’s worse than that. I literally grew up in a radiation laboratory.

Early notes:
When i go to /lib, the only files I can see are the .ino examples. I’m given a button to add the library to PlatformIO, but that button opens the PIO installation page.

I searched for platform:espressif32 SSD1306, and I got a lot of libraries but not the straight-up Adafruit SSD1306. There’s one written for WeMos.
I know Adafruit SSD1306 Library works, because I have used it with the WeMos to display the BME680, why still isn’t working yet.

My first questions were:
“wifi platform:espressif32” - why did you choose those words? How would I choose these words?

“Wifi for Arduino” - again- Why?
I don’t see the origin of these entries, can’t connect them to anything.

The BME 680 script now compiles but won’t upload due to ‘versions’ and the 1306 library. I need that library to work, or replace it with one that does.

The versions problem is serious.
This worked:

lib_deps = 

    Arduino

    https://github.com/adafruit/Adafruit_Sensor.git

    https://github.com/adafruit/Adafruit_BME680.git

    https://github.com/adafruit/Adafruit-GFX-Library.git

    https://github.com/adafruit/Adafruit_SSD1306.git

    https://github.com/adafruit/Adafruit_BusIO.git

???

There’s nothing in lib when you install a library. They go into .pio as I documented in my long post on how and where libraries are installed. Some time back: Libraries are a huge pain almost all the time.

I created a new project for the wemos d1 mini bosrd. The generated platformio.ini file showed that `platform = espressif32" – seemed to be a no-brainer as it filters out irrelevant stuff.

The “arduino” bit is also in the ini file, `framework = arduino", so it seemed relevant, because it is relevant to the framework chosen.

Where did you search? I get it as the first hit:

Screenshot_20200916-191735_Chrome

I suspect when you get the 1306 library installed, the versions error will vanish.

Cheers,
Norm.

1 Like