Conflicting "Filters" library files referenced by IDE

In an attempt to utilize the filters.h library files necessary for the sketch referenced in this tutorial:

I ran into a situation where there seems to be two different "filters" library sources:

You can install through "Manage Libraries" a 'Filters.h' which is authored by Hideakitai.

If you follow the links in the above referenced article it takes you to:

playground.arduino.cc/Code/Filters

In turn that link references the GitHub link:

This is authored by Jon Hub and when you select "Code:" it gives you access to a download zip file named: Filters-master.zip

When you extract that into the Arduino libraries folder it is named "Filters-master".
When you compile the Instructables' author's sketch code (downloaded as
F7NOLCXIMKTOH3M.ino) AC_Sensor_Example in the IDE you get 'filters' related errors because the IDE is not looking at the correct library file. You have to rename the library folders or change the "#include <Filters.h>' to "Filters-master". This was confusing me for a bit. Did I
overlook something or go about it incorrectly in adding to the IDE library? And can I just add the contents of the Filters-master folder into the Filters folder previously established by the IDE's 'Manage Library' function? I hope I have not thoroughly confused those who read this thread. Lol

#include <Filters.h>

float testFrequency = 60;                     // test signal frequency (Hz)
float windowLength = 20.0/testFrequency;     // how long to average the signal, for statistist
int sensorValue = 0;
float intercept = -0.1129; // to be adjusted based on calibration testing
float slope = 0.0405; // to be adjusted based on calibration testing
float current_amps; // estimated actual current in amps

unsigned long printPeriod = 1000; // in milliseconds
// Track time in milliseconds since last reading 
unsigned long previousMillis = 0;

void setup() {
  Serial.begin( 57600 );    // start the serial port
}

void loop() {
  RunningStatistics inputStats;                 // create statistics to look at the raw test signal
  inputStats.setWindowSecs( windowLength );
   
  while( true ) {   
    sensorValue = analogRead(A0);  // read the analog in value:
    inputStats.input(sensorValue);  // log to Stats function
        
    if((unsigned long)(millis() - previousMillis) >= printPeriod) {
      previousMillis = millis();   // update time
      
      // display current values to the screen
      Serial.print( "\n" );
      // output sigma or variation values associated with the inputValue itsel
      Serial.print( "\tsigma: " ); Serial.print( inputStats.sigma() );
      // convert signal sigma value to current in amps
      current_amps = intercept + slope * inputStats.sigma();
      Serial.print( "\tamps: " ); Serial.print( current_amps );
    }
  }
}

Error message:

Arduino: 1.8.19 (Linux), Board: "Arduino Uno WiFi Rev2, None (ATMEGA4809)"

/tmp/arduino_modified_sketch_395090/UNO_AC_Current_Example.ino: In function 'void loop()':
UNO_AC_Current_Example:21:3: error: 'RunningStatistics' was not declared in this scope
   RunningStatistics inputStats;                 // create statistics to look at the raw test signal
   ^~~~~~~~~~~~~~~~~
UNO_AC_Current_Example:22:3: error: 'inputStats' was not declared in this scope
   inputStats.setWindowSecs( windowLength );
   ^~~~~~~~~~
/tmp/arduino_modified_sketch_395090/UNO_AC_Current_Example.ino:22:3: note: suggested alternative: 'PinStatus'
   inputStats.setWindowSecs( windowLength );
   ^~~~~~~~~~
   PinStatus
Multiple libraries were found for "Filters.h"
 Used: /home/ed/Arduino/libraries/Filters
 Not used: /home/ed/Arduino/libraries/Filters-master
exit status 1
'RunningStatistics' was not declared in this scope

Library folder screenshot:

You cannot mix and match parts of one library with another library even if they have the same name

If you have code that you know uses a particular then I suggest that you delete all folders associated with both libraries and reinstall just the one that you want

I discovered when the IDE searches for a library file called
by an "#include" directive that it will pickup on a folder that
has the "searched for" name included in another folder name if the exact folder name is not
located.
I can understand why you suggest deleting folders and reinstalling just what you need.

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