RFID based attendance monitoring system

change this in the code:

#define RST_PIN         D3        // Configurable, see typical pin layout above
#define SS_PIN          D8

sigue sin leer tarjetas

now place your UID on the reader

lo primero que note cambio de color negro a azul y si ya lee las targetas

hago lo mismo en el codigo cayenne?

[quote=“riegosnaturales, post:45, topic:5674”]
?
[/quote] ya estan definidos d3 y d8 en cayenne_rfi_ donde es el lugar correcto para pegar los renglones que me enviaste ayer?

try this code as you are getting some error.

#include <SPI.h>
#include <MFRC522.h>
 
constexpr uint8_t RST_PIN = D3;     // Configurable, see typical pin layout above
constexpr uint8_t SS_PIN = D8;     // Configurable, see typical pin layout above
 
MFRC522 rfid(SS_PIN, RST_PIN); // Instance of the class
 
MFRC522::MIFARE_Key key; 
 
// Init array that will store new NUID 
byte nuidPICC[4];
 
void setup() { 
  Serial.begin(115200);
  SPI.begin(); // Init SPI bus
  rfid.PCD_Init(); // Init MFRC522 
 
  for (byte i = 0; i < 6; i++) {
    key.keyByte[i] = 0xFF;
  }
 
  Serial.println(F("This code scan the MIFARE Classsic NUID."));
  Serial.print(F("Using the following key:"));
  printHex(key.keyByte, MFRC522::MF_KEY_SIZE);
}
 
void loop() {
 
  // Look for new cards
  if ( ! rfid.PICC_IsNewCardPresent())
    return;
 
  // Verify if the NUID has been readed
  if ( ! rfid.PICC_ReadCardSerial())
    return;
 
  Serial.print(F("PICC type: "));
  MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak);
  Serial.println(rfid.PICC_GetTypeName(piccType));
 
  // Check is the PICC of Classic MIFARE type
  if (piccType != MFRC522::PICC_TYPE_MIFARE_MINI &&  
    piccType != MFRC522::PICC_TYPE_MIFARE_1K &&
    piccType != MFRC522::PICC_TYPE_MIFARE_4K) {
    Serial.println(F("Your tag is not of type MIFARE Classic."));
    return;
  }
 
  if (rfid.uid.uidByte[0] != nuidPICC[0] || 
    rfid.uid.uidByte[1] != nuidPICC[1] || 
    rfid.uid.uidByte[2] != nuidPICC[2] || 
    rfid.uid.uidByte[3] != nuidPICC[3] ) {
    Serial.println(F("A new card has been detected."));
 
    // Store NUID into nuidPICC array
    for (byte i = 0; i < 4; i++) {
      nuidPICC[i] = rfid.uid.uidByte[i];
    }
   
    Serial.println(F("The NUID tag is:"));
    Serial.print(F("In hex: "));
    printHex(rfid.uid.uidByte, rfid.uid.size);
    Serial.println();
    Serial.print(F("In dec: "));
    printDec(rfid.uid.uidByte, rfid.uid.size);
    Serial.println();
  }
  else Serial.println(F("Card read previously."));
 
  // Halt PICC
  rfid.PICC_HaltA();
 
  // Stop encryption on PCD
  rfid.PCD_StopCrypto1();
}
 
 
/**
 * Helper routine to dump a byte array as hex values to Serial. 
 */
void printHex(byte *buffer, byte bufferSize) {
  for (byte i = 0; i < bufferSize; i++) {
    Serial.print(buffer[i] < 0x10 ? " 0" : " ");
    Serial.print(buffer[i], HEX);
  }
}
 
/**
 * Helper routine to dump a byte array as dec values to Serial.
 */
void printDec(byte *buffer, byte bufferSize) {
  for (byte i = 0; i < bufferSize; i++) {
    Serial.print(buffer[i] < 0x10 ? " 0" : " ");
    Serial.print(buffer[i], DEC);
  }
}

felicidades que buen trabajo si ha leído todas mis tarjetas te lo agradezco mucho ahora ire a buscar un sensor de lluvia para una tarjeta sw5100 espero encontrarla pronto
saludos amigo

Now that you have the UID of each RFID , you need to add my project code.

1 Like

si lo quiero donde lo encuentro


Libre de virus. www.avast.com

what are you referring to?

Thank sir, i really appreciate your effort, cause i try it work perfect but the channel does not start which 0

not sure what you are sending but those value looks odd, can you share the code.

#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>

// WiFi network info.
char ssid = “”;
char wifiPassword = “”;

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username = ";
char password = “”;
char clientID = “”;

#include <SPI.h>
#include <MFRC522.h>
#include <EEPROM.h>

#define RST_PIN D3 // Configurable, see typical pin layout above
#define SS_PIN D8 // Configurable, see typical pin layout above

MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.

String read_rfid;
String ok_rfid_1 = “c25b661a”;
String ok_rfid_2 = “b0eee9a9”;
String ok_rfid_3 = “c293231a”;
String ok_rfid_4 = “b2a8741a”;
//String ok_rfid_2=“b28d6d1a”; //add as many as you need.

unsigned long lastMillis = 0;

int a;
int b;
int c;
int d;

int EEaddress0 = 1;
int EEaddress2 = 4;
int EEaddress4 = 8;
int EEaddress6 = 12;/*
Initialize.
*/
void setup() {
Serial.begin(9600);
EEPROM.begin(32);
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 card
a = EEPROM.get(EEaddress0, a);
Serial.println(a);
b = EEPROM.get(EEaddress2, b);
Serial.println(b);
c = EEPROM.get(EEaddress4, c);
Serial.println©;
d = EEPROM.get(EEaddress6, d);
Serial.println(d);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
Serial.println(“connected”);
pinMode(D4, OUTPUT);
}

/*
Helper routine to dump a byte array as hex values to Serial.
*/
void dump_byte_array(byte *buffer, byte bufferSize) {
read_rfid = “”;
for (byte i = 0; i < bufferSize; i++) {
read_rfid = read_rfid + String(buffer[i], HEX);
}
}

void check1() {
a++;
Serial.println(a);
EEPROM.put(EEaddress0, a);
EEPROM.commit();
digitalWrite(D4, LOW);
delay(2000);
}
void check2() {
b++;
Serial.println(b);
EEPROM.put(EEaddress2, b);
EEPROM.commit();
digitalWrite(D4, LOW);
delay(2000);
}
void check3() {
c++;
Serial.println©;
EEPROM.put(EEaddress4, c);
EEPROM.commit();
digitalWrite(D4, LOW);
delay(2000);
}
void check4() {
d++;
Serial.println(d);
EEPROM.put(EEaddress6, d);
EEPROM.commit();
digitalWrite(D4, LOW);
delay(2000);
}

void loop() {
digitalWrite(D4, HIGH);
Cayenne.loop();

//Publish data every 10 seconds (10000 milliseconds). Change this value to publish at a different interval.
if (millis() - lastMillis > 10000) {
lastMillis = millis();
//Write data to Cayenne here. This example just sends the current uptime in milliseconds.
Cayenne.virtualWrite(0, a);
Cayenne.virtualWrite(1, b);
Cayenne.virtualWrite(2, c);
Cayenne.virtualWrite(3, d);
//Some examples of other functions you can use to send data.
//Cayenne.celsiusWrite(1, 22.0);
//Cayenne.luxWrite(2, 700);
//Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);
}
Serial.println(“reading”);
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
return;

// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
return;

dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size);

if (read_rfid == ok_rfid_1) {
check1();
}
if (read_rfid == ok_rfid_2) {
check2();
}
if (read_rfid == ok_rfid_3) {
check3();
}
if (read_rfid == ok_rfid_4) {
check4();
}

}

that is the exact same code i used, not sure why are those values.
what i would suggest is, see if can get the RFID code and eeprom code to work individually without the cayenne code.

ok, Sir

i try it is work prefect, but if i connect it with cayenne it show that value and if i swap my card/tag is increasing ( my problem how to remove that value)

thank u sir once again

Sir this is the serial output
image

not sure, what you are doing but how do you come to know that the value is incrementing?

example if the value is 1949655883 ,if i swap my registered card/tag it will increase to 1949655884 the more i swap my my tag the more it increase.

how can i make it to start from 0