On ESP32 I'm trying to build the Minimal I2C example of the MFRC522 library: But I get errors on the first declarations:
TwoWire i2cBus = TwoWire(0);
MFRC522_I2C dev = MFRC522_I2C(RST_PIN, 0x28, i2cBus);
MFRC522 mfrc522 = MFRC522(dev); // <--- error
Here the build output:
src/rfid.cpp:6:30: error: no matching function for call to 'MFRC522::MFRC522(MFRC522_I2C&)'
MFRC522 mfrc522 = MFRC522(dev);
^
In file included from include/rfid.h:5,
from src/rfid.cpp:1:
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:348:2: note: candidate: 'MFRC522::MFRC522(byte, byte)'
MFRC522(byte chipSelectPin, byte resetPowerDownPin);
^~~~~~~
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:348:2: note: candidate expects 2 arguments, 1 provided
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:347:2: note: candidate: 'MFRC522::MFRC522(byte)'
MFRC522(byte resetPowerDownPin);
^~~~~~~
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:347:2: note: no known conversion for argument 1 from 'MFRC522_I2C' to 'byte' {aka 'unsigned char'}
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:346:2: note: candidate: 'MFRC522::MFRC522()'
MFRC522() DEPRECATED_MSG("use MFRC522(MFRC522_BUS_DEVICE bus_device)");
^~~~~~~
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:346:2: note: candidate expects 0 arguments, 1 provided
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:343:2: note: candidate: 'MFRC522::MFRC522(MFRC522_BUS_DEVICE*)'
MFRC522(MFRC522_BUS_DEVICE * dev);
^~~~~~~
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:343:2: note: no known conversion for argument 1 from 'MFRC522_I2C' to 'MFRC522_BUS_DEVICE*'
In file included from include/rfid.h:5,
from src/rfid.cpp:1:
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:152:7: note: candidate: 'constexpr MFRC522::MFRC522(const MFRC522&)'
class MFRC522 {
^~~~~~~
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:152:7: note: no known conversion for argument 1 from 'MFRC522_I2C' to 'const MFRC522&'
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:152:7: note: candidate: 'constexpr MFRC522::MFRC522(MFRC522&&)'
.pio/libdeps/MyProject/MFRC522-spi-i2c-uart-async/src/MFRC522.h:152:7: note: no known conversion for argument 1 from 'MFRC522_I2C' to 'MFRC522&&'
Unfortunately there is no way to open an issue on the repository. Why the official example does not work?
UPDATE
Here the compatibility declaration for ESP32:
1 Answer 1
if you look, it says, "Candidate expects 2 inputs, one provided."
so in the arduino IDE hover over the function and see what it expects.
(What your putting in MFRC522(byte resetPowerDownPin);
what it expects: MFRC522(byte resetPowerDownPin, Something else);
)
-
What it expects is in the declaration of the constructor: github.com/MakerSpaceLeiden/rfid/blob/master/src/…. And is
MFRC522_BUS_DEVICE * dev
Mark– Mark02/16/2023 11:10:50Commented Feb 16, 2023 at 11:10 -
error: cannot convert 'MFRC522_I2C' to 'MFRC522_I2C*' in initialization
MFRC522 mfrc522 = MFRC522(&dev);