MG135 library, please answer

Hello everyone, first of all! Thank you for giving me this place to answer my question.

I am facing a problem with the library MG135.

I downloaded it correctly and ensured that it was in the library folder, and I checked the bath of the Arduino libraries.
everything is fine!!
the code still saying:
" C:\Users\sulmu\OneDrive\المستندات\Arduino\myproject\myproject.ino:5:10: fatal error: MQ135.h: No such file or directory
compilation terminated.
exit status 1
Compilation error: MQ135.h: No such file or directory

my circuit is here:

the code is :

#define RLOAD 120
#include <Wire.h>
#include "MQ135.h"
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for SSD1306 display connected using software SPI (default case):
#define OLED_MOSI   9
#define OLED_CLK   10
#define OLED_DC    11
#define OLED_CS    12
#define OLED_RESET 13
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire);
MQ135 gasSensor = MQ135(A0);
int val;
int sensorPin = A0;
int sensorValue = 0;
void setup() {
  Serial.begin(9600);
  pinMode(sensorPin, INPUT);
  pinMode(D3, OUTPUT);
  display.begin(SSD1306_SWITCHCAPVCC);
  display.clearDisplay();
  display.display();
}
void loop() {
  display.clearDisplay();
  val = analogRead(A0);
  Serial.print ("raw = ");
  Serial.println (val);
 // float zero = gasSensor.getRZero();
 // Serial.print ("rzero: ");
  //Serial.println (zero);
  float ppm = gasSensor.getPPM();
  Serial.print ("ppm: ");
  Serial.println (ppm);
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.setCursor(18,43);
  display.println("CO2");
  display.setCursor(63,43);
  display.println("(PPM)");
  display.setTextSize(2);
  display.setCursor(28,5);
  display.println(ppm);
  display.display();
  delay(2000);
  if(ppm > 1000) {
    digitalWrite(D3, HIGH); // Turn on the LED if ppm is greater than the threshold
  } else {
    digitalWrite(D3, LOW); // Turn off the LED if ppm is less than or equal to the threshold
  }
}

Please this is argent. It is my project i have to finish it.

Welcome to the forum

Which folder is MQ135.h in ?

unfortunately I think it's due to the "المستندات" in the path
can you rename that with just plain ASCII characters like "AlMustanadat" and not use unicode extended character set?

i download this one.
https://github.com/GeorgK/MQ135

i cannot rename it. it means documents in english.
it depends in my laptop language

Once you had downloaded it how did you install it ?

What is the path to the folder where MQ135.h is located ?

it located in the Arduino folder in my documents, inside the libraries folder.
after i downloaded the folder from gethub. i uploaded it in the sketch as a zip folder

under C:\Users\sulmu\OneDrive\المستندات ?

yes

flagging to @ptillisch for input on the use of unicode in the path. Not sure if this is an issue but I think to remember it was.

i am sure that the library is installed as shown:
Screenshot 2024-05-01 162758

Hi @sultanah199. Unfortunately there is a bug in the sketch compiler that causes it to fail to find the library when it is installed under a path that contains this sort of character:

The workaround will be to configure Arduino IDE to use a different path to store libraries. I'll provide instructions you can follow to do that:

  1. Select File > Preferences... (or Arduino IDE > Settings... for macOS users) from the Arduino IDE menus.
    The "Preferences" dialog will open.
  2. Click the "BROWSE" button on the right side of the "Sketchbook location" field.
    The "Select a new sketchbook location" dialog will open.
  3. Select a folder in any location that contains only basic ASCII characters (the characters A-z, 0-9, _, -, . are safe).
    :warning: Make sure to pick a location that will be safe to store your files since, in addition to containing installed libraries, the sketchbook is a convenient location to save your sketches.
  4. Click the "Choose" button in the "Select a new sketchbook location" dialog.
  5. Click the "OK" button in the "Preferences" dialog.
  6. Move all the files from the folder at the path of the old sketchbook location:
    C:\Users\sulmu\OneDrive\المستندات\Arduino
    
    to the folder at the path of the new sketchbook location you set in the Arduino IDE preferences.

Once you have finished performing the instructions above, try compiling your sketch again. Hopefully the compilation will be successful this time.

the same :smiling_face_with_tear:

C:\Users\sulmu\OneDrive\المستندات\libraries\myproject\myproject.ino:5:10: fatal error: MQ135.h: No such file or directory
compilation terminated.
exit status 1

Compilation error: MQ135.h: No such file or directory

Did you follow step 3 above exactly ?

What is the path to your sketchbook folder ?

1 Like

Check for Typos: Ensure that there are no typos in the #include directive for the MQ135 library in your code. It maybe should be #include <MQ135.h>.

he is using #include "MQ135.h" which will look first in the local directory and then in the same directories as if he had used the <MQ135.h> version. So it should not matter

@ptillisch gave you clear instructions on how to change the sketchbook location

But you do not seem to have done that

i just changed the folder, but they both in the documents.
am i wrong?

you can't be under

C:\Users\sulmu\OneDrive\المستندات

any chance you move everything to C:\Users\sulmu/ArduinoStuff ? or you just don't have access to that and user home directory are actually over OneDrive and you can't use the local drive ?