0

I am using the code below to interface the Arduino nano and android cell phone to enable serial communication through the USB port. I downloaded the filter library from GitHub https://github.com/JonHub/Filters

I am getting an error saying thet the library is not found. I would really appreciate some suggestions on this.

Here is my code:

 //This code is for arduino communicating to android phone through USb serial port.
 //For arduino nano

 #include <Filters.h>   //implements digital filters which mimic the analog filter, keep track of variable statistics in realtime

char data_read; //character datatype takes up to 1 byte of memory
unsigned int analog_out;
unsigned long time;
float filterFrequency = 10.0;
FilterOnePole lowpassFilter( LOWPASS, filterFrequency );//implements digital RC type filter; both highpass and lowpass

 void setup()
 {
  Serial.begin(115200); //open the serial port and set the baud rate for communication
  // create a one pole (RC) lowpass filter

 }
 void loop()
 {
 }

 void serialEvent() { //Used when data is unavailable yet
 if (Serial.available()) //checks the number of bytes available for reading from the serial port
 {
data_read = Serial.read();

if (data_read == '0') {
  Serial.print("#");

  //Serial.print("10100");
  analog_out = lowpassFilter.input( analogRead(0) );
  Serial.print(analog_out + 10000);

  Serial.print(":");

  //Serial.print("20200");
  analog_out = lowpassFilter.input( analogRead(1) );
  Serial.print(analog_out + 20000);

  Serial.print(":");

  //Serial.print("30300");
  analog_out = lowpassFilter.input( analogRead(2) );
  Serial.print(analog_out + 30000);

  Serial.print("p");
}
/*if(data_read == '0' || data_read == '1' || data_read == '2' || data_read == '3' || data_read == '4' || data_read == '5'){
  analog_out = lowpassFilter.input( analogRead( data_read-48 ) );
  Serial.print((analog_out)+(data_read-48)*10000);
  Serial.print(":");
  }else if(data_read =='p'){
  Serial.print("p");
  }*/
   }
 }

Here is my error message:

  Arduino: 1.8.5 (Windows 10), Board: "Arduino Nano, ATmega328P"

  C:\Users\daphn\Documents\Arduino\Analog_Serial_out\Analog_Serial_out.ino:4:129: fatal error: Filters.h: No such file or directory

  #include <Filters.h>   //implements digital filters which mimic the analog filter, keep track of variable statistics in realtime

                                                                                                                                 ^

  compilation terminated.

  exit status 1
  Error compiling for board Arduino Nano.

  This report would have more information with
  "Show verbose output during compilation"
   option enabled in File -> Preferences.
2
  • And where did you put the library? – gre_gor Mar 5 '18 at 18:39
  • I've included the library in the same folder where I had saved my code – DaphFab Mar 5 '18 at 18:39
1

You have to put the folder with the library files in the folder libraries under your sketchbook folder. Then the IDE should be able to find them.

I think there is also a possibility to save them in the same folder as your .ino file, but it I don't know how exactly you have to do this.

7
  • I did try including the filters.h header file under the main libraries folder, but still I get the same error. I am wondering if there is any mistake with the source of the header file itself. Usually, when I include external libraries, I place it in the same folder as the code itself and it works. – DaphFab Mar 5 '18 at 19:08
  • I tested it with your code and the linked library and it works for me. Check in the IDEs settings, to where the sketchbook folder is set – chrisl Mar 5 '18 at 19:45
  • The library is more than a .h file. You need ALL the files, and all placed in a folder named Filters within your libraries folder in your sketchbook. Nothing else will do. – Majenko Mar 5 '18 at 20:29
  • @Majenko What do you mean by ALL the files? – DaphFab Mar 5 '18 at 22:25
  • @DaphFab All the files for the library. Everything in that github repository. All the .h files, all the .cpp files, etc. There's 11 of them, plus examples. – Majenko Mar 5 '18 at 22:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.