Hello, first of all, thank you for trying to help me out.
I'm going through an Arduino book and stuck with a library issue.
I was going through a book and got to a chapter that measures air quality using MQ135 sensor.
I had to connect the sensor to Arduino with 5v, GND and A0 pin, download the library, and run the following code.
The library page:
The code:
#include <MQ135.h>
MQ135 gasSensor = MQ135(A0);
void setup() {
Serial.begin(9600);
}
void loop() {
// Read out the calibration value with below code
//float rzero = gasSensor.getRZero();
float ppm = gasSensor.getPPM(); // 센서 값 측정 및 농도 변환
Serial.print("CO2(ppm) = ");
Serial.println(ppm);
delay(350);
}
I kept getting error highlighting the #include <MQ135.h> part Red and saying
"MQ135.h: No such file or directory"
I tried adding the library with zip, putting the library directly into the Arduino library folder in documents and tried other libraries on the internet, but they all gave me the same error. (I changed the folder name to MQ135)
I pass the chapter and continue. One part I had to make tones with buzzer. It included a sketch with a library defining pitches attached with a different tab. I didn't have to download the library and it worked just fine.
Using the servo library worked fine as well.
I got to the point that the book explains the sensors. The first one was using DHT11.
After I downloaded the library and ran the code, the same error popped up like the gas sensor library.
I went back to the gas sensor, but couldn't find a solution.
This code on the bottom is the MQ135.h file opened in Wordpad.
I tried adding _H part to the sketch-like:
MQ135_H gasSensor = MQ135(A0);
but didn't work.
I can't find what is wrong with me and my computer.
I've never wanted to see the air quality of my room this bad.
I'd really appreciate your help.
/**************************************************************************/
/*!
@file MQ135.h
@author G.Krocker (Mad Frog Labs)
@license GNU GPLv3
First version of an Arduino Library for the MQ135 gas sensor
TODO: Review the correction factor calculation. This currently relies on
the datasheet but the information there seems to be wrong.
@section HISTORY
v1.0 - First release
*/
/**************************************************************************/
#ifndef MQ135_H
#define MQ135_H
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
/// The load resistance on the board
#define RLOAD 10.0
/// Calibration resistance at atmospheric CO2 level
#define RZERO 76.63
/// Parameters for calculating ppm of CO2 from sensor resistance
#define PARA 116.6020682
#define PARB 2.769034857
/// Parameters to model temperature and humidity dependence
#define CORA 0.00035
#define CORB 0.02718
#define CORC 1.39538
#define CORD 0.0018
/// Atmospheric CO2 level for calibration purposes
#define ATMOCO2 397.13
class MQ135 {
private:
uint8_t _pin;
public:
MQ135(uint8_t pin);
float getCorrectionFactor(float t, float h);
float getResistance();
float getCorrectedResistance(float t, float h);
float getPPM();
float getCorrectedPPM(float t, float h);
float getRZero();
float getCorrectedRZero(float t, float h);
};
#endif