Closed cdjost closed 2 years ago
Could you kindly test the following source code line instead?
MHZ::MHZ co2(MH_Z19_RX, MH_Z19_TX, MHZ19B);
Can you please provide more details? From the first glance, it seems you try to pass incorrect parameters to the class constructor. Have you updated your library via Arduino library manager to 1.3.1? Have you modified your header files in any way? The latest version is fully compatible with the previous version, and user don't need to make any changes, it should work right out-of-the-box without adding additional constructor arguments. (because there is a default last argument for PWM which is not shown during class initialization and in case you want to change it , it has to be or RANGE_2K or RANGE_5K , like so: MHZ co2(MH_Z19_RX, MH_Z19_TX, CO2_IN, MHZ19B, RANGE_2K); ).
I have the same issue like below.
#include <MHZ.h>
#define RX_PIN 16
#define TX_PIN 17
MHZ co2(RX_PIN, TX_PIN, MHZ19C);
mhz19c.h:12:31: error: call of overloaded 'MHZ(int, int, const int&)' is ambiguous
MHZ co2(RX_PIN, TX_PIN, MHZ19C);
^
In file included from C:\Users\username\Documents\Arduino\mysketch\mhz19c.h\mhz19c.h.ino:1:0:
C:\Users\username\Documents\Arduino\libraries\MH-Z_CO2_Sensors/MHZ.h:36:3: note: candidate: MHZ::MHZ(uint8_t, uint8_t, uint16_t)
MHZ(uint8_t pwmpin, uint8_t type, uint16_t range = RANGE_5K);
^
C:\Users\username\Documents\Arduino\libraries\MH-Z_CO2_Sensors/MHZ.h:35:3: note: candidate: MHZ::MHZ(uint8_t, uint8_t, uint8_t)
MHZ(uint8_t rxpin, uint8_t txpin, uint8_t type);
^
exit status 1
call of overloaded 'MHZ(int, int, const int&)' is ambiguous
SoftwareSerial.h
is needed.MHZ
to MHZ::MHZ
, another error was emitted:
mhz19c.h:12:1: error: 'MHZ::MHZ' names the constructor, not the type
MHZ::MHZ co2(RX_PIN, TX_PIN, MHZ19C);
^
exit status 1
'MHZ::MHZ' names the constructor, not the type
Thank you for developing the useful tool!
Yep, the bug was reproduced, working on it.
The bug is fixed in this PR: https://github.com/tobiasschuerg/MH-Z-CO2-Sensors/pull/38 @tobiasschuerg can you please review and merge it as soon as you can.
@drleavsy Thank you for the very quick fix!
It's merged , thanks for the fix!
Compiler can not distinguish between HZ::MHZ(uint8_t, uint8_t, uint8_t) and MHZ::MHZ(uint8_t, uint8_t, uint16_t)