Bonjour je souhaiterais faire un verrou automatique pour ma porte avec lecteur RFID RC522 et ESP8266. Mais voilà tous les Tutos et documents sont fait pour Arduino et je suis équipé d'un ESP 8266. Des idées de programmes?
Pour info mon UID est :
// 43 A2 4B A7
Mon montage comporte:
une led verte Pin 1
une led rouge Pin 2
un relais pour activer le verrou Pin4
RST Pin 0
SDA Pin 8
J'utilise ce programme mais il ne fonctionne pas, un message d erreur apparait...
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 0 // Configurable, see typical pin layout above
#define SS_PIN 8 // Configurable, see typical pin layout above
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
void setup() {
Serial.begin(9600); // Initialize serial communications with the PC
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522
delay(4); // Optional delay. Some board do need more time after init to be ready, see Readme
mfrc522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details
Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
}
void loop() {
{
int refus = 0; // quand cette variable n'est pas nulle, c'est que le code est refusé
if (rfid.PICC_IsNewCardPresent()) // on a dédecté un tag
{
if (rfid.PICC_ReadCardSerial()) // on a lu avec succès son contenu
{
for (byte i = 0; i < rfid.uid.size; i++) // comparaison avec le bon UID
{
if (rfid.uid.uidByte[i] != bonUID[i]) {
refus++;
}
}
if (refus == 0) // UID accepté
{
// allume LED verte et active relais pendant 3 secondes
digitalWrite(pinLEDVerte, HIGH);
digitalWrite(relais, HIGH);
delay(3000);
digitalWrite(pinLEDVerte, LOW);
digitalWrite(relais, LOW);
}
else { // UID refusé
// allume LED rouge et active buzzer pendant 3 secondes
digitalWrite(pinLEDRouge, HIGH);
digitalWrite(buzzer, HIGH);
delay(3000);
digitalWrite(pinLEDRouge, LOW);
digitalWrite(buzzer, LOW);
}
}
}
}
Non… vous utilisez mfrc522…
Uniquement pour la variable.
Mettez ce projet de côté et prenez un peu de temps pour vous former à la programmation… là c’est vraiment la base… Si vous avez une variable qui s’appelle Toto, Vous ne pouvez pas utiliser Tutu Et espérer que ça fonctionne….
#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 0 // Configurable, see typical pin layout above
#define SS_PIN 8 // Configurable, see typical pin layout above
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
void setup() {
Serial.begin(9600); // Initialize serial communications with the PC
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
SPI.begin(); // Init SPI bus
MFRC522.PCD_Init(); // Init MFRC522
delay(4); // Optional delay. Some board do need more time after init to be ready, see Readme
MFRC522.PCD_DumpVersionToSerial(); // Show details of PCD - MFRC522 Card Reader details
Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
}
void loop() {
{
int refus = 0; // quand cette variable n'est pas nulle, c'est que le code est refusé
if (rfid.PICC_IsNewCardPresent()) // on a dédecté un tag
{
if (rfid.PICC_ReadCardSerial()) // on a lu avec succès son contenu
{
for (byte i = 0; i < rfid.uid.size; i++) // comparaison avec le bon UID
{
if (rfid.uid.uidByte[i] != bonUID[i]) {
refus++;
}
}
if (refus == 0) // UID accepté
{
// allume LED verte et active relais pendant 3 secondes
digitalWrite(pinLEDVerte, HIGH);
digitalWrite(relais, HIGH);
delay(3000);
digitalWrite(pinLEDVerte, LOW);
digitalWrite(relais, LOW);
}
else { // UID refusé
// allume LED rouge et active buzzer pendant 3 secondes
digitalWrite(pinLEDRouge, HIGH);
digitalWrite(buzzer, HIGH);
delay(3000);
digitalWrite(pinLEDRouge, LOW);
digitalWrite(buzzer, LOW);
}
}
}
}