firmware_check.ino 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * --------------------------------------------------------------------------------------------------------------------
  3. * Example sketch/program to test your firmware.
  4. * --------------------------------------------------------------------------------------------------------------------
  5. * This is a MFRC522 library example; for further details and other examples see: https://github.com/miguelbalboa/rfid
  6. *
  7. * This example test the firmware of your MFRC522 reader module, only known version can be checked. If the test passed
  8. * it do not mean that your module is faultless! Some modules have bad or broken antennas or the PICC is broken.
  9. *
  10. * @author Rotzbua
  11. * @license Released into the public domain.
  12. *
  13. * Typical pin layout used:
  14. * -----------------------------------------------------------------------------------------
  15. * MFRC522 Arduino Arduino Arduino Arduino Arduino
  16. * Reader/PCD Uno/101 Mega Nano v3 Leonardo/Micro Pro Micro
  17. * Signal Pin Pin Pin Pin Pin Pin
  18. * -----------------------------------------------------------------------------------------
  19. * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST
  20. * SPI SS SDA(SS) 10 53 D10 10 10
  21. * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16
  22. * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14
  23. * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15
  24. *
  25. * More pin layouts for other boards can be found here: https://github.com/miguelbalboa/rfid#pin-layout
  26. */
  27. #include <SPI.h>
  28. #include <MFRC522.h>
  29. #define RST_PIN 9 // Configurable, see typical pin layout above
  30. #define SS_PIN 10 // Configurable, see typical pin layout above
  31. MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
  32. /**
  33. * Check firmware only once at startup
  34. */
  35. void setup() {
  36. Serial.begin(9600); // Initialize serial communications with the PC
  37. while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
  38. SPI.begin(); // Init SPI bus
  39. mfrc522.PCD_Init(); // Init MFRC522 module
  40. Serial.println(F("*****************************"));
  41. Serial.println(F("MFRC522 Digital self test"));
  42. Serial.println(F("*****************************"));
  43. mfrc522.PCD_DumpVersionToSerial(); // Show version of PCD - MFRC522 Card Reader
  44. Serial.println(F("-----------------------------"));
  45. Serial.println(F("Only known versions supported"));
  46. Serial.println(F("-----------------------------"));
  47. Serial.println(F("Performing test..."));
  48. bool result = mfrc522.PCD_PerformSelfTest(); // perform the test
  49. Serial.println(F("-----------------------------"));
  50. Serial.print(F("Result: "));
  51. if (result)
  52. Serial.println(F("OK"));
  53. else
  54. Serial.println(F("DEFECT or UNKNOWN"));
  55. Serial.println();
  56. }
  57. void loop() {} // nothing to do