Buenas tardes, a ver si me podeis ayudar, por favor.
Estoy haciendo un par de puzzles para escape room utilizando PN5180 y arduino Mega. Con el primero no tuve ningún problema, usé 4 PN5180 y todo perfecto.
Pero en este nuevo utilizo 5 y a ka hora de ejecutar el código me salta este error:
Reader #0
Initialising...
Resetting...
Enabling RF field...
Reader #1
Initialising...
Resetting...
Enabling RF field...
Reader #2
Initialising...
Resetting...
Enabling RF field...
Reader #3
Initialising...
Resetting...
Enabling RF field...
Reader #4
Initialising...
Resetting...
Enabling RF field...
Setup Complete
*** FATAL: Reading more than 508 bytes is not supported!
*** FATAL: Reading more than 508 bytes is not supported!
No se si el problema puede ser a algún Level Shifter o que, pero no logro solucionarlo.
// INCLUDES
// Download from https://github.com/playfultechnology/PN5180-Library
#include <PN5180.h>
#include <PN5180ISO15693.h>
// CONSTANTS
// The number of PN5180 readers connected
const byte numReaders = 5;
// What is the "correct" UID that should be detected by each reader
uint8_t correctUid[][8] = {
{0x31,0xA7,0xFD,0x31,0x8,0x1,0x4,0xE0}, //CEPILLO
{0x7F,0xA1,0xFD,0x31,0x8,0x1,0x4,0xE0}, //RELOJ
{0xD3,0xAA,0xFD,0x31,0x8,0x1,0x4,0xE0}, //PITILLERA
{0xFB,0xAF,0xFD,0x31,0x8,0x1,0x4,0xE0}, //PIPA
{0xD1,0xAB,0xFD,0x31,0x8,0x1,0x4,0xE0}, //ESPEJO
};
// If any of the readers detect this tag, the puzzle will be reset
uint8_t resetUid[8] = {0x36,0x5E,0xE4,0xF6,0x50,0x1,0x4,0xE0};
uint8_t noUid[8] = {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0};
// This pin will be driven LOW when the puzzle is solved
// Este pin se bajará cuando se resuelva el rompecabezas.
const byte relayPin1 = A2; // LIBERA ELECTROIMAN
const byte controlPin = 22;
// GLOBALS
// Each PN5180 reader requires unique NSS (VERDE), BUSY (BLANCO), and RESET (AMARILLO) pins,
// as defined in the constructor below
PN5180ISO15693 nfc[] = {
PN5180ISO15693(10,9,8), // works
PN5180ISO15693(7,6,5), // works
PN5180ISO15693(4,3,2), // works
PN5180ISO15693(14,15,16), // works
PN5180ISO15693(17,18,19), // works
};
// Array to record the value of the last UID read by each reader
uint8_t lastUid[numReaders][8];
bool juegoResuelto=false;
void setup() {
// Configura el pin del relé
pinMode(relayPin1, OUTPUT);
digitalWrite(relayPin1, HIGH);
// Initialise serial connection
Serial.begin(9600);
// Print out the file and the date at which it was last compiled
Serial.println(__FILE__ __DATE__);
for(int i=0; i<numReaders; i++){
Serial.print("Reader #");
Serial.println(i);
Serial.println(F("Initialising..."));
nfc[i].begin();
Serial.println(F("Resetting..."));
nfc[i].reset();
Serial.println(F("Enabling RF field..."));
nfc[i].setupRF();
}
Serial.println(F("Setup Complete"));
}
void loop() {
//while (!juegoResuelto) {
if (digitalRead(controlPin) == HIGH) {
Serial.println("CONTROL ------------------------------------------------------");
onPuzzleSolved();
}
for(int i=0; i<numReaders; i++) {
// Variable to store the ID of any tag read by this reader
uint8_t thisUid[8];
// Try to read a tag ID (or "get inventory" in ISO15693-speak)
ISO15693ErrorCode rc = nfc[i].getInventory(thisUid);
// If the result code was that a card had been read
if(rc == ISO15693_EC_OK) {
// If this is the same ID as we read last frame
if(memcmp(thisUid, lastUid[i], 8) == 0) {
// Nothing to do - move on to the next reader
continue;
}
// If it's a different ID
else {
// Update the array that keeps track of most recent ID
memcpy(lastUid[i], thisUid, 8);
// Display current state of all sensors
showCurrentStatus();
// Has placing this card solved the puzzle?
checkIfPuzzleSolved();
}
}
// If a card cannot be read
else {
// Test if we previously knew about a card (in which case it's just been removed
// The most significant (last) byte of a valid UID should always be 0xE0. e.g. E007C4A509C247A8
if(lastUid[i][7] == 0xE0){
// Update the array that keeps track of last known ID
memset(lastUid[i], 0, 8);
// Display current state of all sensors
showCurrentStatus();
}
}
// Slight delay before checking the next reader
delay(10);
}
//}
}
void showCurrentStatus() {
for(int i=0; i<numReaders; i++) {
Serial.print(F("Reader #"));
Serial.print(i);
Serial.print(": ");
if(memcmp(lastUid[i], noUid, 8) == 0) {
Serial.print(F("---"));
}
else {
for (int j=0; j<8; j++) {
// If single byte, pad with a leading zero
if(lastUid[i][j]<0x10) { Serial.print("0"); }
Serial.print(lastUid[i][j], HEX);
}
if(memcmp(lastUid[i], correctUid[i], 8) == 0) {
Serial.print(F(" - CORRECT"));
}
}
Serial.println("");
}
Serial.println(F("---"));
}
// Action to take when the puzzle is solved
void onPuzzleSolved() {
// Activate the relay
Serial.println("LIBERA ELECTROIMAN");
digitalWrite(relayPin1, LOW);
// Loop until reset card is detected
bool resetDetected = false;
while(!resetDetected) {
for(int i=0; i<numReaders; i++) {
// Variable to store the ID of any tag read by this reader
uint8_t thisUid[8];
// Try to read a tag ID (or "get inventory" in ISO15693-speak)
ISO15693ErrorCode rc = nfc[i].getInventory(thisUid);
// If a card is read with the same ID as the reset card UID
if(rc == ISO15693_EC_OK && memcmp(thisUid, resetUid, 8) == 0) {
resetDetected = true;
digitalWrite(relayPin1, HIGH); // Enciende chimenea
}
delay(100);
}
}
Serial.println(F("RESET"));
Serial.println(F("---"));
}
// Check whether all PN5180s have detected the correct tag
void checkIfPuzzleSolved() {
// Test each reader in turn
for(int i=0; i<numReaders; i++){
// If this reader hasn't detected the correct tag
if(memcmp(lastUid[i], correctUid[i], 8) != 0){
// Exit
return;
}
}
onPuzzleSolved();
}