# Spi Bad connect

**URL:** <https://forum.arduino.cc/t/spi-bad-connect/1410142>\
**Category:** Networking, Protocols, and Devices\
**Created:** [October 21, 2025, 6:45pm UTC](https://forum.arduino.cc/t/spi-bad-connect/1410142 "2025-10-21T18:45:46Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![antik9421](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/antik9421/32/1143358_2.png) [@antik9421](https://forum.arduino.cc/u/antik9421)\
**Post date:** [October 21, 2025, 6:45pm UTC](https://forum.arduino.cc/t/spi-bad-connect/1410142/1 "2025-10-21T18:45:46Z")

</div>

Hello.  
I'm trying to run this project on my own hardware. My project consists of 6 RFID tags and a relay.  
I've assembled it and it works.

Here's a prototype without a lock; I wrote the RC522 simulation module for wokwi myself to test my work.

> **[for README.md - MFRC522\_chip\_simulation multiply - Wokwi ESP32, STM32,...](https://wokwi.com/projects/436744920653539329)**
>
> Run IoT and embedded projects in your browser: ESP32, STM32, Arduino, Pi Pico, and more. No installation required!

However, I encountered the following problems on real hardware:

1. Soldering the SPI channel reliably turned out to be difficult. There are 6 wires in a bundle; they often break. Furthermore, I discovered that only 3-4 sensors work reliably each time I turn it on. Even at the VersionReg stage, I see unknown symbols from time to time. I think this is interference due to a poor connection. Any ideas on how to connect the wires reliably and without interference? 2. I've read many articles, and some of them recommend changing the logic of the extraneous signals to 3V, supposedly to avoid interference. I didn't find any point in this.

2. I followed the advice of placing a 1000 uf capacitor between 3V and GND to smooth out the spikes, but it didn't help.

3. Some people recommend installing an additional power supply, but I've measured the turn-on current with an ammeter, and it doesn't even exceed 50 mA (30-35 mA). I ​​also discovered that if the 3V line is interrupted, the sensors continue to work, but not all of them (parasitic power supply).

Sometimes everything works like clockwork, but that's 1 time out of 10.

No action, simple on/off. 3 different result.

 ![Screenshot_2025-10-21-23-43-09-852_com.miui.gallery](https://europe1.discourse-cdn.com/arduino/original/4X/9/5/6/956fec921851e2e16972c9e7b06e836d1ee01076.jpeg)  
 ![Screenshot_2025-10-21-23-42-36-902_com.miui.gallery](https://europe1.discourse-cdn.com/arduino/original/4X/3/4/1/341ab4d771938253a859ab30dfbc1fb28acec7fe.jpeg)  
 ![Screenshot_2025-10-21-23-42-12-969_com.miui.gallery](https://europe1.discourse-cdn.com/arduino/original/4X/7/5/7/75763e990d8d92ed4916b517e0242d4f9d2fcf8a.jpeg)

My 4-digit display decoding:  
1st digit: RC522 chip successfully reads VersionReq. This is done once in setup() . Later, I moved it to the loop and discovered some instability.  
2nd digit: card inserted  
3rd digit: card inserted and UID tag in place  
4th digit: relay status  
Each segment has its own RFID sensor

---

<div class="post-metadata">

**Author:** ![sonofcy](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sonofcy/32/1283617_2.png) [@sonofcy](https://forum.arduino.cc/u/sonofcy)\
**Post date:** [October 21, 2025, 7:28pm UTC](https://forum.arduino.cc/t/spi-bad-connect/1410142/2 "2025-10-21T19:28:30Z")

</div>

The first thing to do is to read the pinned post re 'How to get the most from the forum'. There you will learn that photos.videos aren't always a good choice, especially from what appears to be a phone screen.  
Remember, we can't see what you see.

---

<div class="post-metadata">

**Author:** ![gilshultz](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gilshultz](https://forum.arduino.cc/u/gilshultz)\
**Post date:** [October 21, 2025, 8:31pm UTC](https://forum.arduino.cc/t/spi-bad-connect/1410142/3 "2025-10-21T20:31:47Z")

</div>

Post your annotated schematic, showing all connections, power sources and links to technical information on the hardware items. Also post your code using code tags. If you follow @sonofcy recommendation that explains what we need and how to post. Remember without the needed information we can only guess, and I do not like that game, somebody always unhappy.

---

<div class="post-metadata">

**Author:** ![antik9421](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/antik9421/32/1143358_2.png) [@antik9421](https://forum.arduino.cc/u/antik9421)\
**Post date:** [October 22, 2025, 7:04am UTC](https://forum.arduino.cc/t/spi-bad-connect/1410142/4 "2025-10-22T07:04:08Z")

</div>

Hello everyone from Tashkent.  
Yes, I apologize, the problem is critical, and I was a bit hasty with my question on the forum.

1. I provide the full source code [arduino-box-unlocker/src at main · anton21m/arduino-box-unlocker · GitHub](https://github.com/anton21m/arduino-box-unlocker/tree/main/src)

2. I also created a prototype in wokwi [https://wokwi.com/projects/437202456035501057](https://wokwi.com/projects/437202456035501057) (always choose 1 card to solve the puzzle)

3. Demonstration of work  
[https://youtube.com/shorts/f8VYgHAoIOI](https://youtube.com/shorts/f8VYgHAoIOI)  
[https://youtube.com/shorts/8vSvEa8msG8](https://youtube.com/shorts/8vSvEa8msG8)  
[https://youtu.be/tpcwLTZFWBQ](https://youtu.be/tpcwLTZFWBQ)

4. And I just pulled out the debug logs here. Code messages, as you can see, they are different, but nevertheless, the cards work, but not all of them, although 6 cards are installed.

```arduino
MFRC522 Access Control Initialize.
Puzzle state reset (card data cleared).
Reader 0: Code 134 WARNING: Communication failure, is the MFRC522 properly connected?
Reader 1: Code 130 WARNING: Communication failure, is the MFRC522 properly connected?
Reader 2: Code 142 WARNING: Communication failure, is the MFRC522 properly connected?
Reader 3: Code 130 WARNING: Communication failure, is the MFRC522 properly connected?
Reader 4: Code 128 WARNING: Communication failure, is the MFRC522 properly connected?
Reader 5: Code 132 WARNING: Communication failure, is the MFRC522 properly connected Initialized 0 / 6 readers.
Puzzle state reset (card data cleared).
Card on Reader 0: UID: 77 18 40 05
Unknown Tag on Reader 0
Card on Reader 1: UID: AD 25 3B 05
Unknown Tag on Reader 1
Card on Reader 2: UID: 04 2D 3E 05
Card on Reader 3: UID: 89 C2 48 05 
Unknown Tag on Reader 3
:ERR Version: on id: 5-> 132
System needs 5 more correct cards. Door is LOCKED.
Cards Present: 4 Cards Correct: 1
Puzzle state reset (card data cleared).
Card on Reader 0: UID: 77 18 40 05
Unknown Tag on Reader
Card on Reader 1: UID: AD 25 3B 05 
Unknown Tag on Reader 1
Card on Reader 2: UID: 04 2D 3E 05
Card on Reader 3: UID: 89 C2 48 05 
Unknown Tag on Reader 3
:ERR Version: on id: 5-> 132
System needs 5 more correct cards. Door is LOCKED.

```

4.I modified the program a little (Other files are the same)

```arduino
#include <SPI.h>
#include "config.h"
// Forward declarations for functions defined in functions.ino
void InitializePuzzleState();
void updateDisplay();
void dump_byte_array(byte * buffer, byte bufferSize);

void setup() {
  delay(1000);

  pinMode(RST_PIN, OUTPUT); 
  digitalWrite(RST_PIN, LOW); 
  delay(5);                   
  digitalWrite(RST_PIN, HIGH); 
  delay(1000); 
  
  Serial.begin(9600);
  SPI.begin();
  
  Serial.println(F("MFRC522 Access Control Initialize."));
  
 
  pinMode(ACCESS_RELAY_PIN, OUTPUT);
  
  digitalWrite(ACCESS_RELAY_PIN, LOW); 
  display.clear();
  display.brightness(3); 

  InitializePuzzleState();
  
  // repeat initialization
  for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
    bool success = false;
    byte version = 0x00;
    int attempt = 0;
    
    
    while (!success && attempt < 5) { 
      mfrc522[reader].PCD_Init(ssPins[reader], RST_PIN);
      version = mfrc522[reader].PCD_ReadRegister(MFRC522::VersionReg);
      
      if (version == 0x92) {
        success = true;
      } else {
        attempt++;
        Serial.print(F("Reader "));
        Serial.print(reader);
        Serial.print(F(": Attempt "));
        Serial.print(attempt);
        Serial.print(F(" failed (Code "));
        Serial.print(version);
        Serial.println(F("). Retrying..."));
        
        delay(200); 
      }
    }
    
    // Result
    if (success) {
      Serial.print(F("Reader "));
      Serial.print(reader);
      Serial.print(F(": "));
      mfrc522[reader].PCD_DumpVersionToSerial();
      initializedReadersCount++;
      readerInitialized[reader] = true;
    } else {
      Serial.print(F("Reader "));
      Serial.print(reader);
      Serial.println(F(": FAILED after 5 attempts."));
      readerInitialized[reader] = false;
    }
    delay(50);
  }
  
  Serial.print(F("Initialized "));
  Serial.print(initializedReadersCount);
  Serial.print(F(" / "));
  Serial.print(NR_OF_READERS);
  Serial.println(F(" readers."));
  
  updateDisplay();

  delay(100);
}

void loop() {
  // Фиксированная задержка между полными циклами сканирования.
  // Обратите внимание: эта задержка замедляет опрос считывателей.
  delay(1000);

  // Сбрасываем состояние головоломки для каждой итерации
  InitializePuzzleState();

  // Сканирование всех считывателей
  for (uint8_t reader_idx = 0; reader_idx < NR_OF_READERS; reader_idx++) {

    // Проверка связи со считывателем в каждом цикле
    byte version = mfrc522[reader_idx].PCD_ReadRegister(MFRC522::VersionReg);
    if (version != 0x92) {
      Serial.print(":ERR Version: on id: ");
      Serial.print(reader_idx);
      Serial.print("-> ");
      Serial.println(version);
      readerInitialized[reader_idx] = false;
    } else {
      readerInitialized[reader_idx] = true;
    }

    // Включаем антенну только для текущего считывателя
    mfrc522[reader_idx].PCD_AntennaOn();
    delay(30); // Короткая пауза для стабилизации поля

    // Сразу проверяем наличие карты и читаем её UID
    if (mfrc522[reader_idx].PICC_IsNewCardPresent() && mfrc522[reader_idx].PICC_ReadCardSerial()) {
      readerHasCard[reader_idx] = true;
      Serial.print("Card on Reader ");
      Serial.print(reader_idx);
      Serial.print(F(": UID:"));
      dump_byte_array(mfrc522[reader_idx].uid.uidByte, mfrc522[reader_idx].uid.size);
      Serial.println();

      bool uidMatch = true;
      for (int i = 0; i < mfrc522[reader_idx].uid.size; i++) {
        if (mfrc522[reader_idx].uid.uidByte[i] != tagarray[reader_idx][i]) {
            uidMatch = false;
            break;
          }
      }

      if (uidMatch) {
        readerHasCorrectCard[reader_idx] = true;
      } else {
        Serial.println("Unknown Tag on Reader " + String(reader_idx));
      }

      mfrc522[reader_idx].PICC_HaltA();
      mfrc522[reader_idx].PCD_StopCrypto1();
    }

    // Выключаем антенну, чтобы она не мешала другим считывателям
    mfrc522[reader_idx].PCD_AntennaOff();
    }

  // Агрегация данных после сканирования всех считывателей
  for (uint8_t i = 0; i < NR_OF_READERS; i++) {
    if (readerHasCard[i]) {
      currentTotalCardsPresent++;
    }
    if (readerHasCorrectCard[i]) {
      currentTotalCorrectCards++;
    }
  }

  // Обновляем флаг puzzleSolved
  puzzleSolved = (currentTotalCorrectCards == NR_OF_READERS);

  // Логика управления единственным реле (ACCESS_RELAY_PIN)
  // Согласно схеме и желаемой логике:
  // ACCESS_RELAY_PIN HIGH (реле ВКЛ) -> COM на NO -> led-open (зеленый) горит (ДВЕРЬ РАЗБЛОКИРОВАНА)
  // ACCESS_RELAY_PIN LOW (реле ВЫКЛ) -> COM на NC -> lock-magnet (красный) горит (ДВЕРЬ ЗАБЛОКИРОВАНА)
  if (puzzleSolved) {
    // Если головоломка решена, ДВЕРЬ РАЗБЛОКИРОВАНА (зеленый LED ON)
    digitalWrite(ACCESS_RELAY_PIN, HIGH); // Реле ВКЛ -> РАЗБЛОКИРОВАНО
    Serial.println("Welcome! All tags correct. Door is now UNLOCKED.");
  } else {
    // Если головоломка НЕ решена, ДВЕРЬ ЗАБЛОКИРОВАНА (красный LED ON)
    digitalWrite(ACCESS_RELAY_PIN, LOW); // Реле ВЫКЛ -> ЗАБЛОКИРОВАНО
    Serial.println("System needs " + String(NR_OF_READERS - currentTotalCorrectCards) + " more correct cards. Door is LOCKED.");
  }

  Serial.print("Cards Present: ");
  Serial.print(currentTotalCardsPresent);
  Serial.print(" Cards Correct: ");
  Serial.println(currentTotalCorrectCards);

  updateDisplay(); // Обновление дисплея
}

```

and now I received the following, different codes but 1 and the same request

```arduino
MFRC522 Access Control Initialize.
Puzzle state reset (card data cleared).
Reader 0: Attempt 1 failed (Code 234). Retrying... 
Reader 0: Attempt 2 failed (Code 162). Retrying... 
Reader 0: Attempt 3 failed (Code 226). Retrying... 
Reader 0: Attempt 4 failed (Code 130). Retrying... 
Reader 0: Attempt 5 failed (Code 130). Retrying... 
Reader : FAILED after 5 attempts.
Reader 1: Attempt 1 failed (Code 238). Retrying... 
Reader 1: Attempt 2 failed (Code 130). Retrying... 
Reader 1: Attempt 3 failed (Code 130). Retrying... 
Reader 1: Attempt 4 failed (Code 128). Retrying... 
Reader 1: Attempt 5 failed (Code 130). Retrying... 
Reader 1: FAILED after 5 attempts.
Reader 2: Attempt 1 failed (Code 128). Retrying... 
Reader 2: Attempt 2 failed (Code 138). Retrying... 
Reader 2: Attempt 3 failed (Code 128). Retrying... 
Reader 2: Attempt 4 failed (Code 138). Retrying... 
Reader 2: Attempt 5 failed (Code 238). Retrying...

```

---

<div class="post-metadata">

**Author:** ![jim-p](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jim-p/32/922840_2.png) [@jim-p](https://forum.arduino.cc/u/jim-p)\
**Post date:** [October 22, 2025, 11:19am UTC](https://forum.arduino.cc/t/spi-bad-connect/1410142/5 "2025-10-22T11:19:27Z")

</div>

Are you actually using an Arduino Uno and RC522 readers exactly as you show in the diagram?

---

<div class="post-metadata">

**Author:** ![antik9421](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/antik9421/32/1143358_2.png) [@antik9421](https://forum.arduino.cc/u/antik9421)\
**Post date:** [October 24, 2025, 5:27am UTC](https://forum.arduino.cc/t/spi-bad-connect/1410142/6 "2025-10-24T05:27:38Z")

</div>

Yes, schema true

---

<div class="post-metadata">

**Author:** ![jim-p](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jim-p/32/922840_2.png) [@jim-p](https://forum.arduino.cc/u/jim-p)\
**Post date:** [October 24, 2025, 11:13am UTC](https://forum.arduino.cc/t/spi-bad-connect/1410142/7 "2025-10-24T11:13:53Z")

</div>

@antik9421

Contrary to popular belief the I/Os of the RC522 are **not** 5V tolerant, so you will need voltage shifters/translators on all the signal lines.

The RC522 can draw a lot of current so you need a separate 3.3V power supply for the RFID readers.

Soldering all connections will provide the most reliable hardware set-up

FYI: The woki simulator does not care about voltages and currents so it will work even if you exceed the actual design values

---

<div class="post-metadata">

**Author:** ![Paul\_KD7HB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paul_kd7hb/32/1127958_2.png) [@Paul\_KD7HB](https://forum.arduino.cc/u/Paul_KD7HB)\
**Post date:** [October 24, 2025, 4:37pm UTC](https://forum.arduino.cc/t/spi-bad-connect/1410142/8 "2025-10-24T16:37:59Z")

</div>

> [@antik9421](#):
>
> Soldering the SPI channel reliably turned out to be difficult. There are 6 wires in a bundle; they often break.

This was discovered when lead-free solder was first introduced, so many years ago. If you cannot use lead based solder, then the wires must be fixed to the circuit board so they cannot be moved. Use RTV or hot-glue or some other way to eliminate movement of the soldered part of the wires.

---

<div class="post-metadata">

**Author:** ![gilshultz](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gilshultz](https://forum.arduino.cc/u/gilshultz)\
**Post date:** [October 24, 2025, 9:30pm UTC](https://forum.arduino.cc/t/spi-bad-connect/1410142/9 "2025-10-24T21:30:28Z")

</div>

Sorry I did not understand the language in the link. Without a schematic I do not feel I or many others can help you.

---

<div class="post-metadata">

**Author:** ![b707](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/b707/32/854321_2.png) [@b707](https://forum.arduino.cc/u/b707)\
**Post date:** [October 24, 2025, 9:49pm UTC](https://forum.arduino.cc/t/spi-bad-connect/1410142/10 "2025-10-24T21:49:53Z")

</div>

> [@antik9421](#):
>
> Soldering the SPI channel reliably turned out to be difficult. There are 6 wires in a bundle

If you using a 6 RFID modules, it will needs a 9 SPI wires rather than 6 - Miso, Mosi, Sck and 6 x CS

---

<div class="post-metadata">

**Author:** ![b707](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/b707/32/854321_2.png) [@b707](https://forum.arduino.cc/u/b707)\
**Post date:** [October 24, 2025, 10:04pm UTC](https://forum.arduino.cc/t/spi-bad-connect/1410142/11 "2025-10-24T22:04:41Z")

</div>

@antik9421  
To be warned that a generally bad idea to use more than one .ino file in the project because it is difficult to predict how the IDE will process them. If you need to split a code to the pieces - the better way is using a standard C++ approach with .h and .cpp pairs.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [April 22, 2026, 10:05pm UTC](https://forum.arduino.cc/t/spi-bad-connect/1410142/12 "2026-04-22T22:05:26Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
