Error with Arduino Cloud controlled Keyboard

Hi,
I was trying to make a Arduino Cloud controlled keyboard using my Nano ESP32.
Code:

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled 5"
  https://create.arduino.cc/cloud/things/ea476a39-6dc3-43db-8cb5-c97afbd74fe2 

  Arduino IoT Cloud Variables description

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

  String text;

  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 "USB.h"
#include "USBHIDKeyboard.h"
USBHIDKeyboard Keyboard;  
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();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  Keyboard.begin();
  USB.begin(); 
  /*
     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 
  
  
}

/*
  Since Text is READ_WRITE variable, onTextChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onTextChange()  {
  Keyboard.print(text);
  // Add your code here to act upon Text change
}

Error:

loading library from /var/run/arduino/custom-libraries/ArduinoCore-avr: invalid library: no header files found
In file included from /run/arduino/directories-data/packages/arduino/hardware/esp32/2.0.13/cores/esp32/Arduino.h:223,
                 from /var/run/arduino/user-cache/sketches/D590E94DEE009D99D6A1EE0436949017/sketch/Untitled_5_may02a.ino.cpp:1:
/run/arduino/directories-data/packages/arduino/hardware/esp32/2.0.13/cores/esp32/io_pin_remap.h:47:61: error: 'digitalPinToGPIONumber' is not a type
 #define pinMode(pin, mode)                          pinMode(digitalPinToGPIONumber(pin), mode)
                                                             ^~~~~~~~~~~~~~~~~~~~~~
/var/run/arduino/custom-libraries/WiFiNINA/src/utility/wifi_drv.h:299:17: note: in expansion of macro 'pinMode'
     static void pinMode(uint8_t pin, uint8_t mode);
                 ^~~~~~~
In file included from /var/run/arduino/custom-libraries/WiFiNINA/src/WiFiStorage.h:23,
                 from /var/run/arduino/custom-libraries/WiFiNINA/src/WiFi.h:38,
                 from /var/run/arduino/directories-user/libraries/Arduino_ConnectionHandler/src/WiFiConnectionHandler.h:45,
                 from /var/run/arduino/directories-user/libraries/Arduino_ConnectionHandler/src/Arduino_ConnectionHandler.h:37,
                 from /var/run/arduino/directories-user/libraries/ArduinoIoTCloud/src/ArduinoIoTCloud.h:27,
                 from /run/arduino/sketches/Untitled_5_may02a/thingProperties.h:3,
                 from /run/arduino/sketches/Untitled_5_may02a/Untitled_5_may02a.ino:17:
/var/run/arduino/custom-libraries/WiFiNINA/src/utility/wifi_drv.h:300:12: error: 'PinStatus' does not name a type
     static PinStatus digitalRead(uint8_t pin);
            ^~~~~~~~~
In file included from /run/arduino/directories-data/packages/arduino/hardware/esp32/2.0.13/cores/esp32/Arduino.h:223,
                 from /var/run/arduino/user-cache/sketches/D590E94DEE009D99D6A1EE0436949017/sketch/Untitled_5_may02a.ino.cpp:1:
/run/arduino/directories-data/packages/arduino/hardware/esp32/2.0.13/cores/esp32/io_pin_remap.h:46:66: error: 'digitalPinToGPIONumber' is not a type
 #define digitalWrite(pin, val)                      digitalWrite(digitalPinToGPIONumber(pin), val)
                                                                  ^~~~~~~~~~~~~~~~~~~~~~
/var/run/arduino/custom-libraries/WiFiNINA/src/utility/wifi_drv.h:301:17: note: in expansion of macro 'digitalWrite'
     static void digitalWrite(uint8_t pin, uint8_t value);
                 ^~~~~~~~~~~~
/run/arduino/directories-data/packages/arduino/hardware/esp32/2.0.13/cores/esp32/io_pin_remap.h:29:64: error: 'digitalPinToGPIONumber' is not a type
 #define analogRead(pin)                             analogRead(digitalPinToGPIONumber(pin))
                                                                ^~~~~~~~~~~~~~~~~~~~~~
/var/run/arduino/custom-libraries/WiFiNINA/src/utility/wifi_drv.h:302:21: note: in expansion of macro 'analogRead'
     static uint16_t analogRead(uint8_t adc_channel);
                     ^~~~~~~~~~
/run/arduino/directories-data/packages/arduino/hardware/esp32/2.0.13/cores/esp32/io_pin_remap.h:25:49: error: 'digitalPinToGPIONumber' is not a type
 #define analogWrite(pin, value)     analogWrite(digitalPinToGPIONumber(pin), value)
                                                 ^~~~~~~~~~~~~~~~~~~~~~
/var/run/arduino/custom-libraries/WiFiNINA/src/utility/wifi_drv.h:303:17: note: in expansion of macro 'analogWrite'
     static void analogWrite(uint8_t pin, uint8_t value);
                 ^~~~~~~~~~~
Multiple libraries were found for "WiFiClientSecure.h"
  Used: /run/arduino/directories-data/packages/arduino/hardware/esp32/2.0.13/libraries/WiFiClientSecure
  Not used: /run/arduino/directories-data/internal/Seeed_Arduino_rpcWiFi_1.1.0_a93a349668c69c81
Multiple libraries were found for "SPI.h"
  Used: /run/arduino/directories-data/packages/arduino/hardware/esp32/2.0.13/libraries/SPI
  Not used: /run/arduino/directories-data/internal/EventEthernet_1.0.0_bd9dd894ef7641f8
Multiple libraries were found for "WiFi.h"
  Used: /run/arduino/custom-libraries/WiFiNINA
  Not used: /run/arduino/directories-data/internal/VEGA_WiFiNINA_1.0.1_ab2db6059607e9f4
  Not used: /run/arduino/directories-data/internal/DA16200_Wi-Fi_Library_for_Arduino_1.1.0_9d156d307009fe30
  Not used: /run/arduino/directories-data/internal/BetterWiFiNINA_1.4.1_f1b425a2b2caf410
  Not used: /run/arduino/directories-data/internal/WiFiNINA_1.9.1_7cc9ca1b1de1ea6a
  Not used: /run/arduino/directories-data/internal/NINA-Wi-Fi_1.0.1_8b5f9e1dc71eca55
  Not used: /run/arduino/directories-data/internal/Seeed_Arduino_rpcWiFi_1.1.0_a93a349668c69c81
  Not used: /run/arduino/directories-data/internal/WiFiEspAT_1.5.0_5169a7bcde168205
  Not used: /run/arduino/directories-data/internal/indhilib_3.0.5_645ae16078e566f4
  Not used: /run/arduino/directories-data/internal/WiFi_1.2.7_c357666d3257ae8a
  Not used: /run/arduino/directories-data/packages/arduino/hardware/esp32/2.0.13/libraries/WiFi

Thanks,
Isaac

I see the problem here:

Your sketch program (including the code of the libraries used by the sketch) specifies the header files of libraries by filename, like this:

#include <WiFi.h>

The problem is that, for any common name like "WiFi", multiple libraries might contain a file of that name. In this case, the Arduino sketch build system must decide with of the multiple libraries it should use when compiling your sketch. It uses a sophisticated algorithm to make this decision. One of the factors in the decision is whether one of the prospective libraries is a "Custom" library that you imported to your Arduino Cloud account. These "Custom" libraries are given higher priority by the algorithm than the libraries that are pre-installed on the Arduino Cloud server.

You imported a copy of the "WiFiNINA" library to your Arduino Cloud account. That library happens to contain a header file named WiFi.h, so the sketch build system chose the WiFiNINA library. However, the WiFiNINA library is not compatible with the Nano ESP32 board, so this causes the compilation to fail. The correct library is the "WiFi" library that is bundled with the platform for the Nano ESP32 board:

So the solution for the error is to cause the sketch build system to select the appropriate ESP32 "WiFi" library instead of the WiFiNINA library.

The most simple way to accomplish that would be to remove the copy of the WiFiNINA library you imported to your account.

If this is truly a "custom" copy of the library to which you have made some special modifications that you need for some other project then that solution will not be suitable, so just let me know I will provide an alternative solution. However, the standard "WiFiNINA" library is already pre-installed on the Arduino Cloud server, so if you imported a standard copy of the library then it serves no purpose and is only using up some of your account's storage allocation.

I'll provide instructions you can follow to remove the "Custom" "WiFiNINA" library from your account:

  1. If you are not already, log in to your Arduino account:
    https://login.arduino.cc/login

  2. Click the following link to open the list of your Arduino Cloud sketches in the web browser:
    https://app.arduino.cc/sketches

  3. Click on any sketch, or use the CREATE > New sketch button to create a new sketch.
    The sketch will open in Arduino Cloud Editor.

  4. Click the icon that looks like shelved books ("Libraries") in the bar on the left side of the Cloud Editor page.
    The "Libraries" panel will open.

  5. Select the "Custom" tab from the "Libraries" panel.

  6. You will see text near the top of the panel:

    Show libraries for:
    <board name>

    (where <board name> is the name of the board you have selected in Arduino Cloud Editor)
    Click the board name in that text.
    The text will now change to:

    Show libraries for:
    ALL DEVICES

  7. Scroll down through the list of custom libraries until you find the entry for the "WiFiNINA" library.

  8. Click the icon to the right of the library name.
    A menu will open.

  9. Select "Delete Library" from the menu.
    A "Delete custom library" dialog will open.

  10. Click the "YES, DELETE" button in the dialog.

Now try compiling or uploading your sketch again. Hopefully this time it will work as expected.


Please let me know if you have any questions or problems while following those instructions.

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