Error message : Multiple libraries were found for "Servo.h"

Hey, I am making a spark parking system with ESP8266 Nodemcu and I am facing a problem compiling the code.

#include <ESP8266WiFi.h>
#include <Servo.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>


#include <FirebaseArduino.h>

#define FIREBASE_HOST "smart-parking-7f5b6.firebaseio.com"                 // the project name address from firebase id
#define FIREBASE_AUTH "suAkUQ4wXRPW7nA0zJQVsx3H2LmeBDPGmfTMBHCT"            // the secret key generated from firebase

#define WIFI_SSID "CircuitDigest"                                             // input your home or public wifi name 
#define WIFI_PASSWORD "circuitdigest101"                                    //password for Wifi
String Available = "";                                                  //availability string
String fireAvailable = "";

LiquidCrystal_I2C lcd(0x27, 16, 2);         //i2c display address 27 and 16x2 lcd display
Servo myservo;                          //servo as gate
Servo myservos;                               //servo as gate
int Empty;                            //available space integer
int allSpace = 90;
int countYes = 0;
int carEnter = D0;                      // entry sensor 
int carExited = D4;                   //exi sensor
int TRIG = D7;                  //ultrasonic trig  pin
int ECHO = D8;                // ultrasonic echo pin
int led = D3;                 // spot occupancy signal
int pos;
int pos1;

long duration, distance;     

void setup() {
  delay(1000);
  Serial.begin (9600);     // serial debugging
  Wire.begin(D2, D1);       // i2c start
  myservo.attach(D6);      // servo pin to D6
  myservos.attach(D5);       // servo pin to D5
  pinMode(TRIG, OUTPUT);      // trig pin as output 
  pinMode(ECHO, INPUT);         // echo pin as input
  pinMode(led, OUTPUT);         // spot indication
  pinMode(carExited, INPUT);    // ir as input
  pinMode(carEnter, INPUT);     // ir as input

  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);                                     //try to connect with wifi
  Serial.print("Connecting to ");
  Serial.print(WIFI_SSID);                          // display ssid
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");                          // if not connected print this
    delay(500);
  }
  Serial.println();
  Serial.print("Connected to ");
  Serial.println(WIFI_SSID);
  Serial.print("IP Address is : ");
  Serial.println(WiFi.localIP());                                            //print local IP address
  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);        // begin firebase authentication

  lcd.begin();                           //begin lcd
  lcd.home();                            
  lcd.setCursor(0, 0);                      // 0th row and 0thh column
  lcd.print("Smart Parking");    
}

void loop() {

  digitalWrite(TRIG, LOW);         // make trig pin low
  delayMicroseconds(2);
  digitalWrite(TRIG, HIGH);        // make trig pin high
  delayMicroseconds(10);
  digitalWrite(TRIG, LOW);
  duration = pulseIn(ECHO, HIGH);
  distance = (duration / 2) / 29.1;      // take distance in cm

    Serial.print("Centimeter: ");
    Serial.println(distance);

  int carEntry = digitalRead(carEnter);      // read ir input
  if (carEntry == HIGH) {                     // if high then count and send data
    countYes++;                             //increment count
    Serial.print("Car Entered = " ); Serial.println(countYes );
    lcd.setCursor(0, 1);
    lcd.print("Car Entered");
    for (pos = 140; pos >= 45; pos -= 1) {        // change servo position
      myservos.write(pos);                       
      delay(5);
    }
    delay(2000);

    for (pos = 45; pos <= 140; pos += 1) {       // change servo position
      // in steps of 1 degree
      myservos.write(pos);
      delay(5);
    }

    Firebase.pushString("/Parking Status/", fireAvailable );    // send string to firebase
    lcd.clear();
  }
  int carExit = digitalRead(carExited);              //read exit ir sensor
  if (carExit == HIGH) {                            //if high then count and send
    countYes--;                                    //decrement count
    Serial.print("Car Exited = " ); Serial.println(countYes);
    lcd.setCursor(0, 1);
    lcd.print("Car Exited");
    for (pos1 = 140; pos1 >= 45; pos1 -= 1) {         // change servo position
      myservo.write(pos1);
      delay(5);
    }
    delay(2000);

    for (pos1 = 45; pos1 <= 140; pos1 += 1) {            // change servo position
      // in steps of 1 degree
      myservo.write(pos1);
      delay(5);
    }
    Firebase.pushString("/Parking Status/", fireAvailable );  // send string to firebase
    lcd.clear();
  }
  if (distance < 6) {                      //if distance is less than 6cm then on led 
        Serial.println("Occupied ");
    digitalWrite(led, HIGH);
  }

  if (distance > 6) {                        //if distance is greater than 6cm then off led 
        Serial.println("Available ");
    digitalWrite(led, LOW);
  }

  Empty = allSpace - countYes;         //calculate available data
 
  Available = String("Available= ") + String(Empty) + String("/") + String(allSpace);       // convert the int to string
  fireAvailable = String("Available=") + String(Empty) + String("/") + String(allSpace);

  lcd.setCursor(0, 0);
  lcd.print(Available);                 //print available data to lcd

}

This is the error message:

In file included from C:\Users\Amogh\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseArduino.h:22,
Multiple libraries were found for "Servo.h"
from D:\HDD\Files\PROJECT\3 year\IOT\Files\sketch_nov13a\sketch_nov13a.ino:7:
Used: C:\Users\Amogh\Documents\ArduinoData\packages\esp8266\hardware\esp8266\3.0.2\libraries\Servo
C:\Users\Amogh\Documents\Arduino\libraries\firebase-arduino-master\src/Firebase.h:26:10: fatal error: ArduinoJson.h: No such file or directory
26 | #include <ArduinoJson.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
Not used: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.51.0_x86__mdqgnx93n4wtt\libraries\Servo
exit status 1
Error compiling for board Generic ESP8266 Module.

Hi!

There are two problems in compilation:

  1. Your program looks for "Servo.h" library and founds 2 of them. It might be a copy of the same library in one of your directories (most probably), or even another library with the same name. Try to identify which one is the correct and delete the other. This problem is just an alert and it doesn´t stop the compilation at all because Arduino chooses one of them.

  2. The library "Firebase.h" looks for another archive called "ArduinoJson.h", but this file is missing in the place where it should be. Try to locate it and put in the same directory of the other archives. Make sure that the library you´re calling "FirebaseArduino.h" is the correct one.

Have fun! :upside_down_face:

Unfortunately, due to the output coming from parallel processes, it was a little bit mixed together by the IDE. That makes them more difficult to interpret. I'll separate them out to make it easier to understand.

The first one:

The "Multiple libraries were found for" message has nothing to do with the compilation failure. It is only some helpful information the Arduino IDE provides. Generally, you can safely ignore the "Multiple libraries were found for" messages. The only time you need to pay attention to it is when the Arduino IDE picked a different library than the one you had intended.

In this case, there are two libraries installed on your computer that contain a file matching the #include directive in your sketch for Servo.h:

This one:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.51.0_x86__mdqgnx93n4wtt\libraries\Servo

is the official Arduino Servo library that comes with your installation of the Arduino IDE. That library is good for when you are using one of the official Arduino boards like the Uno. However, the Servo library uses some low level hardware specific code that must be configured specifically for each board architecture. Since Arduino doesn't make any ESP8266 boards, the official Servo library doesn't have support for the ESP8266 architecture.

So the ESP8266 boards platform authors have made their own variant of the Servo library and bundled it with the ESP8266 boards platform installation you make via the Arduino IDE's Boards Manager. Here:

C:\Users\Amogh\Documents\ArduinoData\packages\esp8266\hardware\esp8266\3.0.2\libraries\Servo

Since the platform bundled library has the same standardized API as the official Servo library, you probably wouldn't even notice that you are using a different library. The same sketches work on any board.

So all this is to say that, since the ESP8266 Servo library was used, everything is fine and you can safely ignore that message.


Now for the real error message:

When you see a "No such file or directory" error it almost always means you need to install the library that contains the missing file.

Often the code you're compiling will come with documentation (either a comment or separate document) that tells you where to get the library dependencies.

Note that libraries may have dependencies on other libraries. That is the case here. The Firebase library has a dependency on the ArduinoJson library. Even if your sketch only uses the Firebase library directly, you must install both libraries.

In other cases the author of the code will not have been so kind and you'll need to go on a hunt for the missing library.

A good place to start is the Arduino IDE's Library Manager:

  1. Select Sketch > Include Library > Manage Libraries... from the Arduino IDE's menus.
  2. In the "Filter your search..." box, type some keywords you have gleaned from the missing file name.
  3. Scroll through the results for the right library. Click on it.
  4. Click the Install button.
  5. Wait for the installation to finish.
  6. Click the Close button.
  7. Try compiling your code again.

You will find your ArduinoJson library there, but I want to help you to understand how to deal with the "No such file or directory" error in general, so I'll provide some advice about what to do when you can't find it in Library Manager:

If you have no luck in Library Manager then load up your favorite search engine and do a search for the missing filename. You will often get multiple results. If you have a lot of results you might add "arduino" as an additional search keyword. I will usually prefer results from github.com since that is where most Arduino libraries are hosted and downloading from there is fast and easy. In some cases there will be multiple libraries that contain the given filename and you'll need to do some evaluation to determine which seems the most appropriate, then try it out.

After downloading the library you found, you'll need to install it. This requires a different process than the Library Manager installation. You will find instructions here:

1 Like

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