ostaquet / Arduino-MQ131-driver

Arduino driver for gas sensor MQ131 (Ozone / O3)
MIT License
65 stars 19 forks source link

Two sensors MQ131: LOW and HIGH concentration in project #40

Closed Chris722 closed 3 years ago

Chris722 commented 3 years ago

Hello ostaquet,

I'd like to connect two MQ131 sensors to Arduino UNO: first - LOW_CONCENTRATION to A0 input and second HIGH_CONCENTRATION to A1 input. How should I declare them in the program?

Best regards, KAD

ostaquet commented 3 years ago

As you can see in the header file, the sensor is created through the instance of MQ131Class.

In order to have multiple instance of the driver, you just have to instantiate the class more than once.

Per example:

MQ131Class lowSensor = new MQ131Class();
MQ131Class highSensor = new MQ131Class();

lowSensor->begin(...);
highSensor->begin(...);
[...]
tbmart16 commented 3 years ago

Hi ostaquet,

I have a similar goal of using both a high concentration and low concentration sensor in my program. I see your response above and I tried to implement it into my Arduino code, but I get an error. Should I put your example above before the void setup() or inside of the void setup()?

Chris722 commented 3 years ago

Hi tbmart16,

This code works for me:

include

MQ131Class highSensor = new MQ131Class(8000); # Load resistance RL of 8kOhms (8000 Ohms) MQ131Class lowSensor = new MQ131Class(1000000); # Looad resistance RL of 1MOhms (1000000 Ohms)

void setup() { Serial.begin(115200);

highSensor.begin(2,A0, HIGH_CONCENTRATION, 8000, (Stream *)&Serial); [...]