Hello everyone !
I working on this code below, I would like to send the UID from a TAG to an HTML page,
With this code I already connect my phone to a SSID and I can find the UID from a TAG (look at the picture).
Does somebody can help me thank you !
#include <ESP8266WiFi.h>
#include <SPI.h>
#include "MFRC522.h"
/* wiring the MFRC522 to ESP8266 (ESP-12)
RST = GPIO0
SDA(SS) = GPIO2
MOSI = GPIO13
MISO = GPIO12
SCK = GPIO14
GND = GND
3.3V = 3.3V
*/
#define RST_PIN 0 // RST-PIN für RC522 - RFID - SPI - Modul GPIO0
#define SS_PIN 2 // SDA-PIN für RC522 - RFID - SPI - Modul GPIO2
const char *ssid = "ESP8266"; // change according to your Network - cannot be longer than 32 characters!
const char *pass = ""; // change according to your Network
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
void setup() {
Serial.begin(115200); // Initialize serial communications
delay(250);
Serial.println(F("Booting...."));
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522
WiFi.begin(ssid, pass);
int retries = 0;
while ((WiFi.status() != WL_CONNECTED) && (retries < 10)) {
retries++;
delay(500);
Serial.print(".");
}
if (WiFi.status() == WL_CONNECTED) {
Serial.println(F("WiFi connected"));
}
Serial.println(F("Ready!"));
Serial.println(F("======================================================"));
Serial.println(F("Scan for Card and print UID:"));
}
void loop() {
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent()) {
delay(50);
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial()) {
delay(50);
return;
}
// Show some details of the PICC (that is: the tag/card)
Serial.print(F("Card UID:"));
dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);
Serial.println();
}
// Helper routine to dump a byte array as hex values to Serial
void dump_byte_array(byte *buffer, byte bufferSize) {
for (byte i = 0; i < bufferSize; i++) {
Serial.print(buffer[i] < 0x10 ? " 0" : " ");
Serial.print(buffer[i], HEX);
}
}