Previous code not verifying in sketches

I am monitoring several temperature sensors (DHT-11) via the IOT cloud that I put in place about a year ago. I would like to take advantage of the trigger/notification function when temperatures are outside certain limits so I decided to add some code to try to accomplish this.

Just to cover all of my bases before I started modifying the code, I tried re-verifying the existing code from sketches of functioning devices that are currently operational in the field, and am having issues getting the code to verify on my ESP-32 board sketches.

In the advanced editor it stops at an error 'PinStatus does not name a type'

Chat GPT indicates that there are library conflicts, so I tried eliminating each of the two libraries that I have in the code below.

below is the total debug with the code

/usr/local/bin/arduino-cli compile --fqbn esp32:esp32:nodemcu-32s:FlashFreq=80,UploadSpeed=921600,DebugLevel=none --build-cache-path /tmp --output-dir /tmp/2401822406/build --build-path /tmp/arduino-build-325DBCE83D3D27D0B396A714A64782EC --library /mnt/create-efs/webide/0d/3a/0d3a89629bd0be065d4efc919fe0d51d:fa20driver/libraries_v2/ArduinoBLE --library /mnt/create-efs/webide/0d/3a/0d3a89629bd0be065d4efc919fe0d51d:fa20driver/libraries_v2/Arduino_LSM6DS3 --library /mnt/create-efs/webide/0d/3a/0d3a89629bd0be065d4efc919fe0d51d:fa20driver/libraries_v2/DFRobot_DHT11 --library /mnt/create-efs/webide/0d/3a/0d3a89629bd0be065d4efc919fe0d51d:fa20driver/libraries_v2/DHT sensor library --library /mnt/create-efs/webide/0d/3a/0d3a89629bd0be065d4efc919fe0d51d:fa20driver/libraries_v2/DHT_nonblocking --library /mnt/create-efs/webide/0d/3a/0d3a89629bd0be065d4efc919fe0d51d:fa20driver/libraries_v2/LSM6 --library /mnt/create-efs/webide/0d/3a/0d3a89629bd0be065d4efc919fe0d51d:fa20driver/libraries_v2/RTCZero --library /mnt/create-efs/webide/0d/3a/0d3a89629bd0be065d4efc919fe0d51d:fa20driver/libraries_v2/WiFiNINA /tmp/2401822406/28_Clayton_apr28a

In file included from /mnt/create-efs/webide/0d/3a/0d3a89629bd0be065d4efc919fe0d51d:fa20driver/libraries_v2/WiFiNINA/src/WiFiStorage.h:23,

from /mnt/create-efs/webide/0d/3a/0d3a89629bd0be065d4efc919fe0d51d:fa20driver/libraries_v2/WiFiNINA/src/WiFi.h:38,

from /home/builder/Arduino/libraries/arduino_connectionhandler_0_8_1/src/Arduino_ConnectionHandler.h:151,

from /home/builder/Arduino/libraries/arduinoiotcloud_1_13_0/src/ArduinoIoTCloud.h:27,

from /tmp/2401822406/28_Clayton_apr28a/thingProperties.h:3,

from /tmp/2401822406/28_Clayton_apr28a/28_Clayton_apr28a.ino:19:

/mnt/create-efs/webide/0d/3a/0d3a89629bd0be065d4efc919fe0d51d:fa20driver/libraries_v2/WiFiNINA/src/utility/wifi_drv.h:292:12: error: 'PinStatus' does not name a type

static PinStatus digitalRead(uint8_t pin);

^~~~~~~~~

Multiple libraries were found for "WiFi.h"

Used: /mnt/create-efs/webide/0d/3a/0d3a89629bd0be065d4efc919fe0d51d:fa20driver/libraries_v2/WiFiNINA

Not used: /home/builder/opt/libraries/vega_wifinina_1_0_1

Not used: /home/builder/opt/libraries/indhilib_3_0_5

Not used: /home/builder/opt/libraries/wifi_1_2_7

Not used: /home/builder/opt/libraries/seeed_arduino_rpcwifi_1_0_6

Not used: /home/builder/opt/libraries/wifinina_1_8_14

Not used: /home/builder/opt/libraries/nina_wi_fi_1_0_1

Not used: /home/builder/opt/libraries/da16200_wi_fi_library_for_arduino_1_1_0

Not used: /home/builder/opt/libraries/wifiespat_1_4_3

Not used: /home/builder/.arduino15/packages/esp32/hardware/esp32/2.0.5/libraries/WiFi

Multiple libraries were found for "WiFiClientSecure.h"

Used: /home/builder/.arduino15/packages/esp32/hardware/esp32/2.0.5/libraries/WiFiClientSecure

Not used: /home/builder/opt/libraries/seeed_arduino_rpcwifi_1_0_6

Multiple libraries were found for "DHT.h"

Used: /mnt/create-efs/webide/0d/3a/0d3a89629bd0be065d4efc919fe0d51d:fa20driver/libraries_v2/DHT sensor library

Not used: /home/builder/opt/libraries/ukit_explore_1_2_28

Not used: /home/builder/opt/libraries/nanoplayboard_0_1_1

Not used: /home/builder/opt/libraries/dht11esp8266examples_1_0_10

Not used: /home/builder/opt/libraries/esp826611_1_0_16

Not used: /home/builder/opt/libraries/dht118266_1_0_16

Not used: /home/builder/opt/libraries/dht11esp8266_1_0_10

Not used: /home/builder/opt/libraries/grove_temperature_and_humidity_sensor_2_0_1

Not used: /home/builder/opt/libraries/dht_sensor_library_1_4_6

Not used: /home/builder/opt/libraries/dht_kxn_3_4_4

Not used: /home/builder/opt/libraries/servodht11_1_0_10

Multiple libraries were found for "SPI.h"

Used: /home/builder/.arduino15/packages/esp32/hardware/esp32/2.0.5/libraries/SPI

Not used: /home/builder/opt/libraries/eventethernet_1_0_0

Multiple libraries were found for "Adafruit_Sensor.h"

Used: /home/builder/opt/libraries/adafruit_unified_sensor_1_1_14

Not used: /home/builder/opt/libraries/arduav_1_4_2

Error during build: exit status 1

And the code:

/*
  Sketch generated by the Arduino IoT Cloud Thing "Nano"
  https://create.arduino.cc/cloud/things/798304ed-58ca-4f7e-9a0d-dddc288d6aff

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  float boardHUMID;
  float boardTEMP;
  bool redLED;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"

#include <DHT.h>
#include <DHT_U.h>

#define DHTPIN 2
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

int myLED = 13;

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500);

  // Defined in thingProperties.h
  initProperties();

  pinMode(myLED, OUTPUT);
  dht.begin();
  

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);

  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
  */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  // Your code here
delay (2000);

boardTEMP = dht.readTemperature(true);
boardHUMID = dht.readHumidity();

}

/*
  Since RedLED is READ_WRITE variable, onRedLEDChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onRedLEDChange()  {

  Serial.println(redLED);

  if (redLED) {
    digitalWrite(myLED, HIGH);

  } else {
    digitalWrite(myLED, LOW);
  }
  // Add your code here to act upon RedLED change
}

Hi @fa20driver,

not absolutely sure but it looks as if a library (/libraries_v2/WiFiNINA/src/utility/wifi_drv.h) is called that is not intended for ESP32 nodeMCU but for boards where an ESP is used as a co-controller for Wifi support.

Hi @fa20driver.

The Arduino sketch build system automatically determines which libraries are used by your sketch, and by the libraries used by those libraries. It does this by looking for a header file in the library that matches the filename from the #include directives in the code.

In some cases (especially so in Arduino Cloud, when >6000 libraries are pre-installed), multiple libraries might contain a matching file. In this case, the build system must decide which of the libraries to use. The decision is based on a sophisticated algorithm, so it usually picks the appropriate library, but in this case it did not. You can see from the informational messages in the compilation output that it used the "WiFiNINA" library:

As @ec2021 already explained, the "WiFiNINA" library is not compatible with the ESP32 board you are using. The correct library is the "WiFi" library bundled with the ESP32 boards platform:

The reason the build system gave the "WiFiNINA" library priority is because you imported that library into your Arduino Cloud account. The build system assumes that if the user imported a library then they want that library to be used by their sketches instead of any alternative pre-installed libraries.

So the solution to the problem is to persuade the build system to use the "WiFi" platform bundled library instead of the "WiFiNINA" library. The best way to accomplish that will depend on why you imported the "WiFiNINA" library.

If you didn't have any specific reason for importing it, or if your reason for importing it is no longer relevant, then the best solution will be to simply remove the imported library from your Arduino Cloud account. I can provide instructions for doing that. But if you need that imported library then we will need to find a different solution.

So please provide an explanation for why you imported the "WiFiNINA" library to your Arduino Cloud account in a reply here on the forum thread. If you weren't aware that you imported the library, that is fine, just let us know and we'll proceed accordingly.

Thank you for the in-depth explanation! I believe that I imported the WiFiNINA library for one of my other boards that I was using - probably the nano 33 IOT if I remember correctly, although I have tried a few others as well. Perhaps it isn't even needed and if not I am happy to remove the WifiNINA library. I have a few nano 33 IOT boards out in use, but could replace them with the ESP 32's if this becomes an issue.

If I delete the WiFiNINA library and the nano 33's still work then I guess we are good. I would appreciate a quick tutorial on how to do that, although I could probably look it up.

It is a bit confusing as to why everything worked fine 6 months ago, and all devices are currently working with the existing code, but I guess something in the library changed which now causes an issue/conflict?

Deleting the WiFiNINA library was easy. I tried verifying both types of board sketches after deleting the library and everything works. Thank YOU! I wasted about 4 hrs on this issue before posting the question on this forum...

It is not necessary to import the "WiFiNINA" library because it is pre-installed in Arduino Cloud. So you will still be able to compile and upload sketches for your Nano 33 IoT that use the WiFiNINA library even after removing the imported copy from your account.

The valid reasons for importing a library like "WiFiNINA" that is already pre-installed:

  • You made modifications to the library's source code.
  • The Arduino sketch build system chose a different library than intended and you want to force it to use the library

I think the reason is that there was a change to the algorithm the build system uses to decide which library to use in the case of discovery of multiple libraries. It was changed to give the imported (AKA "Custom") libraries a higher priority:

I'm glad it is working now. Great job on figuring out how to proceed on your own initiative!

You are welcome. I'm glad if I was able to be of assistance.

Regards,
Per

Quick question - I was looking at different boards and came across the Arduino Nano RP2040 Connect. I saw that the wifiNINA library is required in order to use the RGB. I assume that this is going to cause an issue with my ESP-32's.

If I were to buy the Arduino ESP-32's to replace my off brand ESP-32's, would I still have the issue with the wifiNINA library interfering with them?

No. The "WiFiNINA" library is only used with the boards that have a Wi-Fi radio module separate from the primary microcontroller (referred to as the "NINA" module by Arduino), as is necessary for a microcontroller like the RP2040 that doesn't have a native Wi-Fi capability. The ESP32 board does have native Wi-Fi capability so the ESP32 board does not use a separate radio module and thus does not use the WiFiNINA library in any way. So any information you see about control of an RGB LED via the WiFiNINA library or the NINA module is completely irrelevant to the ESP32.

Sorry, I don't think that my question was clear. I know I don't need wifiNINA for the ESP 32, but I would need it for the RP2040, correct?

IE - If I added the RP2040 to my IOT Cloud of controllers, I would need to add the wifiNINA library which would then interfere with the ESP-32 programming, correct?

No. The WiFiNINA library is pre-installed in Arduino Cloud. The copy of the library you imported was completely redundant. Even though you removed the imported copy from your account, the globally pre-installed copy of the library is still available. So you can compile sketches that depend on the WiFiNINA library right now on Arduino Cloud without any need to import the WiFiNINA library.

It was only the fact that you imported a copy of the library that caused problems when compiling for ESP32 boards. The globally pre-installed copy doesn't cause any problems because the Arduino build system is smart enough to pick the ESP32 WiFi library when compiling for ESP32 boards instead of the WiFiNINA library.

Ahhhhh, I see. Thank you.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.