strange-v / MHZ19

Arduino library for MH-Z19/MH-Z19B CO2 sensor
GNU General Public License v3.0
57 stars 12 forks source link

Thank you for the good information. I have a question. #5

Closed rimmomo closed 5 years ago

rimmomo commented 5 years ago

I'm using my hardware. (ESP32) How do I set the range?

include

HardwareSerial mhz19(1); MHZ19 mhz(&mhz19);

void setup() { Serial.begin(9600); delay(800); mhz19.begin(9600);

 mhz.setAutoCalibration(false);
 mhz.setRange(3);

}

void main() { MHZ19_RESULT response = mhz.retrieveData(); if (response == MHZ19_RESULT_OK) { Serial.print(F("CO2: ")); Serial.println(mhz.getCO2()); Serial.print(F("Temperature: ")); Serial.println(mhz.getTemperature()); Serial.print(F("Accuracy: ")); Serial.println(mhz.getAccuracy()); } else { Serial.print(F("Error, code: ")); Serial.println(response); } }

I'm a beginner, so I don't know. Thank you for the good information.

strange-v commented 5 years ago

What range value do you want to set? In any case, you have to use enum defined in MHZ19.h, e.g. for range 3000 ppm code will be like this: mhz.setRange(MHZ19_RANGE_3000);

This is the list of valid ranges: MHZ19_RANGE_1000, MHZ19_RANGE_2000, MHZ19_RANGE_3000, MHZ19_RANGE_5000, MHZ19_RANGE_10000

rimmomo commented 5 years ago

What range value do you want to set? In any case, you have to use enum defined in MHZ19.h, e.g. for range 3000 ppm code will be like this: mhz.setRange(MHZ19_RANGE_3000);

This is the list of valid ranges: MHZ19_RANGE_1000, MHZ19_RANGE_2000, MHZ19_RANGE_3000, MHZ19_RANGE_5000, MHZ19_RANGE_10000

Thank you!