Salut (surtout à ce qui me voit échouer pour une troisième raisons différente sur le même circuit haha)
J'ai actuellement ce circuit
Faisant tourner ce code:
#include <Debug.h>
#include <PN5180.h>
#include <PN5180ISO15693.h>
/*
*/
const int ledred = 7;
const int ledgreen = 6;
// The number of PN5180 readers connected
const byte numReaders = 3; /// A MODIFIER
// What is the "correct" UID that should be detected by each reader
uint8_t correctUid[][8] =
{
{0x8A,0x9F,0x9D,0xA4,0x50,0x1,0x4,0xE0}, //TAG 1
{0xB,0x8A,0xC6,0x6A,0x0,0x1,0x4,0xE0} //TAG 2
};
//Si ce tag est lu par un des lecteurs, le puzzle sera reset
uint8_t resetUid[][8] = {{0xD1,0xD2,0x48,0x2A,0x50,0x1,0x4,0xE0}}; //TAG 1}
//Valeur par défaut quand il n'y a pas de tag
uint8_t noUid[][8] = {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}; //TAG 1}
//Serial.println("Etape 1");
// GLOBALS
// Each PN5180 reader requires unique NSS, BUSY, and RESET pins,
// as defined in the constructor below
PN5180ISO15693 nfc[] = {
PN5180ISO15693(22,24,26), // Pins correspondants aux fonstions des lecteurs
PN5180ISO15693(28,30,32), // works
PN5180ISO15693(34,36,38), // works
//MISO BLEU 50
//MOSI VERT 51
//SCK JAUNE 52
};
// Array to record the value of the last UID read by each reader
uint8_t lastUid[numReaders][8];
// the setup function runs once when you press reset or power the board
void setup() {
Serial.begin(9600);
Serial.println("Etape 1");
pinMode(ledred,OUTPUT);// Led rouge
pinMode(ledgreen,OUTPUT);// Led verte
Serial.println("RFID Tirroir, escape pirate");
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"));
}
// the loop function runs over and over again forever
void loop() {
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 {
Serial.print(F("New Card Detected on Reader "));
Serial.print(i);
Serial.print(F("... "));
for (int j=0; j<sizeof(thisUid); j++) {
Serial.print(thisUid[j],HEX);
Serial.print(" ");
}
Serial.println();
// Update the array that keeps track of most recent ID
memcpy(lastUid[i], thisUid, sizeof(lastUid[i][0])*8);
// 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){
Serial.print("Card ");
for (int j=0; j<sizeof(lastUid[i]); j++) {
Serial.print(lastUid[i][j], HEX);
}
Serial.print(" removed from Reader ");
Serial.println(i);
// Update the array that keeps track of last known ID
memset(lastUid[i], 0, sizeof(lastUid[i][0])*8);
}
#ifdef DEBUG
Serial.print(F("Error in getInventory: "));
Serial.println(nfc[i].strerror(rc));
#endif
}
// Slight delay before checking the next reader
delay(10);
}
// digitalWrite(ledgreen, LOW);
// digitalWrite(ledred, HIGH);
// delay(1000);
// digitalWrite(ledred, LOW);
// digitalWrite(ledgreen, HIGH);
}
void onPuzzleSolved() {
// Activate the relay
digitalWrite(ledred, LOW);
digitalWrite(ledgreen, HIGH);
Serial.print(" Bonne carte ");
// Loop forever
while(true) { delay(1000); }
}
// 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
digitalWrite(ledred, HIGH);
return;
}
}
onPuzzleSolved();
}
Le soucis que j'ai maintenant et que je me demande s'il n'y a pas un soucis de masse ou un truc du genre. Car lorsque je lance mon programme et regarde le moniteur série, celui-ci bloque à un endroit précis de l'initialisation des lecteur RFID:
Le truc c'est que lorsque je touche la nappes de fils surlignés ici en jaune
Le programme se débloque soudainement et me permet de lire les cartes RFID placé en face des lecteurs.... Tant que je touche la nappe de fil!
Je me suis dit au début que c'était une erreur de soudure, ou un faux contact, mais j'ai fait des test de continuité et tout est bien relié. De plus je n'ai même pas besoin de faire bouger les câbles en les touchant, juste les toucher suffit à faire marcher le circuit. J'ai meme poser une pince à sertir sur les cables pour les maintenir dans la position de quand je les tenait. Rien. Mais si je touche la partie métallique de la pince qui fait contact avec les cables, encore une fois ça marche aussi.
Je précise que les cables sont neuf, pas dénudés, que le circuit est alimenté en USB par mon ordinateur et le tout posé sur un chiffon pour l'isoler au dessus de ma tour.
Du coup je ne sais pas d'où vient le problème, mais dés que je rentre en contact avec la nappe suspecte, bam ça marche.
Merci à vous (encore une fois)