I connected two RFID readers (RC522) to the SPI bus of a NodeMCU and use the rc522_spi component in the yaml to configure them. One reader uses D8 for chip select, the other D4. The yaml compiles without any warnings but in the runtime logs I see:
The RC522 component keeps soft-resetting and repeats the SPI setup always ending in the same error message. When I only configure a single device in the yaml, everything works perfectly fine. So, the issue is only visible, when I have multiple rc522_spi devices configured.
Despite using different ids for both readers, it seems like the code that registers SPIDevices to the SPI bus references the same object for both readers. (Here is the line that logs the error in the spi component.)
I am not familiar with esphome code generation, yet, but it seems, the ids of the readers are used here to generate handles for the different instances (var), run the setup of rc522, and register them as spi devices. (Does cg.new_Pvariable(config[CONF_ID]) generate a new pointer to a RC522Spi object? I couldn't find any documentation for the code generation so I am just guessing here.)
I compared this code to the code generation for a max6675 which is also an SPIDevice but I don't see anything suspicious in the rc522_spi code. I have no idea why this doesn't work.
The problem
I connected two RFID readers (RC522) to the SPI bus of a NodeMCU and use the
rc522_spi
component in the yaml to configure them. One reader uses D8 for chip select, the other D4. The yaml compiles without any warnings but in the runtime logs I see:The RC522 component keeps soft-resetting and repeats the SPI setup always ending in the same error message. When I only configure a single device in the yaml, everything works perfectly fine. So, the issue is only visible, when I have multiple
rc522_spi
devices configured.Despite using different ids for both readers, it seems like the code that registers SPIDevices to the SPI bus references the same object for both readers. (Here is the line that logs the error in the
spi
component.)I am not familiar with esphome code generation, yet, but it seems, the ids of the readers are used here to generate handles for the different instances (
var
), run the setup ofrc522
, and register them asspi
devices. (Doescg.new_Pvariable(config[CONF_ID])
generate a new pointer to aRC522Spi
object? I couldn't find any documentation for the code generation so I am just guessing here.)I compared this code to the code generation for a max6675 which is also an SPIDevice but I don't see anything suspicious in the
rc522_spi
code. I have no idea why this doesn't work.Any help is highly appreciated!
Which version of ESPHome has the issue?
2023.9.1
What type of installation are you using?
Home Assistant Add-on
Which version of Home Assistant has the issue?
2023.9.1
What platform are you using?
ESP8266
Board
nodemcu
Component causing the issue
rc522_spi
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
No response