电子发烧友App

硬声App

0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
会员中心
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示
电子发烧友网>电子资料下载>电子资料>基于RFID的学生出勤监控系统

基于RFID的学生出勤监控系统

2023-01-30 | zip | 0.05 MB | 次下载 | 免费

资料介绍

电路板如下图:
pYYBAGPV_D2AZ07DAAA8M5r__sg755.jpg
poYBAGPV_ECASWVmAAA61qRWUv4046.jpg

组件

499
Adafruit 工业有限责任公司
x 1
ESP-WROOM-32 x 1

描述

基于 RFID 的学生出勤监控系统

在教室里,时间被浪费在点名上,因为它是手动完成的。在这个提议的系统中,被授权的学生被赋予一个 RFID 标签。通过将 RFID 标签放在阅读器上,学生或工作人员可以立即验证他们的出勤情况。因此,存储在该卡中的数据被称为该人的身份/出勤。一旦学生将卡片放在 RFID 读卡器前面,它就会读取数据并与存储的数据进行验证。蜂鸣器会在扫描 RFID 标签时发出蜂鸣声。如果数据匹配,则它会在 LCD 上显示一条消息,确认该学生的输入,否则会显示一条消息,拒绝出席。通过按下连接到微控制器的状态按钮,可以从该系统中检索学生的出勤状态。最后,他/她的日期和时间数据存储在谷歌表格中。这个特定的谷歌表格显示了日期、时间和 RFID 标签中存储的数据。因此,由于所有学生的出勤情况都直接存储在数据库中,因此节省了大量时间。它将产生一个实时考勤监控系统,供讲师、校园管理人员和家长等各方访问。

代码

RFID入口代码

阿杜诺

? #include
? #include
? //--------------------------------------------------
? //GPIO 0 --> D3
? //GPIO 2 --> D4
? const uint8_t RST_PIN = D3;
? const uint8_t SS_PIN = D4;
? int BUZZER = 2;
? //--------------------------------------------------
? MFRC522 mfrc522(SS_PIN, RST_PIN);
? MFRC522::MIFARE_Key key;
? //--------------------------------------------------
? /* Be aware of Sector Trailer Blocks */
? int blockNum = 4;
? byte block_data[16];
? /* Create array to read data from Block */
? /* Length of buffer should be 4 Bytes
? more than the size of Block (16 Bytes) */
? byte bufferLen = 18;
? byte readBlockData[18];
? //--------------------------------------------------
? MFRC522::StatusCode status;
? //--------------------------------------------------
? ?
? ?
? ?
? void setup()
? {
? //------------------------------------------------------
? //Initialize serial communications with PC
? Serial.begin(9600);
? //------------------------------------------------------
? //Initialize SPI bus
? SPI.begin();
? //------------------------------------------------------
? //Initialize MFRC522 Module
? mfrc522.PCD_Init();
? Serial.println("Scan a MIFARE 1K Tag to write data...");
? //------------------------------------------------------
? }
? ?
? ?
? ?
? /****************************************************************************************************
? * loop() function
? ****************************************************************************************************/
? void loop()
? {
? //------------------------------------------------------------------------------
? /* Prepare the ksy for authentication */
? /* All keys are set to FFFFFFFFFFFFh at chip delivery from the factory */
? for (byte i = 0; i < 6; i++){
? key.keyByte[i] = 0xFF;
? }
? //------------------------------------------------------------------------------
? /* Look for new cards */
? /* Reset the loop if no new card is present on RC522 Reader */
? if ( ! mfrc522.PICC_IsNewCardPresent()){return;}
? //------------------------------------------------------------------------------
? /* Select one of the cards */
? if ( ! mfrc522.PICC_ReadCardSerial()) {return;}
? //------------------------------------------------------------------------------
? Serial.print("\n");
? Serial.println("**Card Detected**");
? /* Print UID of the Card */
? Serial.print(F("Card UID:"));
? for (byte i = 0; i < mfrc522.uid.size; i++){
? Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
? Serial.print(mfrc522.uid.uidByte[i], HEX);
? }
? Serial.print("\n");
? /* Print type of card (for example, MIFARE 1K) */
? Serial.print(F("PICC type: "));
? MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
? Serial.println(mfrc522.PICC_GetTypeName(piccType));
? ?
? ------------------------------------------------------------------------------
? blockNum =4;
? toBlockDataArray("211EC206"); //ID
? WriteDataToBlock(blockNum, block_data);
? ReadDataFromBlock(blockNum, readBlockData);
? dumpSerial(blockNum, readBlockData);
? ?
? blockNum =5;
? toBlockDataArray("Madhumithra"); //First Name
? WriteDataToBlock(blockNum, block_data);
? ReadDataFromBlock(blockNum, readBlockData);
? dumpSerial(blockNum, readBlockData);
? ?
? blockNum =6;
? toBlockDataArray("S"); //Last Name
? WriteDataToBlock(blockNum, block_data);
? ReadDataFromBlock(blockNum, readBlockData);
? dumpSerial(blockNum, readBlockData);
? ?
? blockNum =8;
? toBlockDataArray("Shanmugavel.M"); //Father Name
? WriteDataToBlock(blockNum, block_data);
? ReadDataFromBlock(blockNum, readBlockData);
? dumpSerial(blockNum, readBlockData);
? ?
? blockNum =9;
? toBlockDataArray("24-09-2003"); //Date of Birth
? WriteDataToBlock(blockNum, block_data);
? ReadDataFromBlock(blockNum, readBlockData);
? dumpSerial(blockNum, readBlockData);
? ?
? blockNum =10;
? toBlockDataArray("8526267629"); //Phone Number
? WriteDataToBlock(blockNum, block_data);
? ReadDataFromBlock(blockNum, readBlockData);
? dumpSerial(blockNum, readBlockData);
? ?
? blockNum =12;
? toBlockDataArray("Pollachi"); //Address
? WriteDataToBlock(blockNum, block_data);
? ReadDataFromBlock(blockNum, readBlockData);
? dumpSerial(blockNum, readBlockData);
? ?
? //tone(BUZZER, 1000, 1000);
? }
? ?
? ?
? ?
? /****************************************************************************************************
? * Writ() function
? ****************************************************************************************************/
? void WriteDataToBlock(int blockNum, byte blockData[])
? {
? Serial.print("Writing data on block ");
? Serial.print(blockNum);
? //------------------------------------------------------------------------------
? /* Authenticating the desired data block for write access using Key A */
? status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, blockNum, &key, &(mfrc522.uid));
? if (status != MFRC522::STATUS_OK){
? Serial.print("Authentication failed for Write: ");
? Serial.println(mfrc522.GetStatusCodeName(status));
? return;
? }
? //------------------------------------------------------------------------------
? else {
? Serial.println("Authentication success");
? }
? //------------------------------------------------------------------------------
? /* Write data to the block */
? status = mfrc522.MIFARE_Write(blockNum, blockData, 16);
? if (status != MFRC522::STATUS_OK) {
? Serial.print("Writing to Block failed: ");
? Serial.println(mfrc522.GetStatusCodeName(status));
? return;
? }
? else
? {Serial.println("Data was written into Block successfully");}
? //------------------------------------------------------------------------------
? }
? ?
? ?
? ?
? ?
? ?
? /****************************************************************************************************
? * ReadDataFromBlock() function
? ****************************************************************************************************/
? void ReadDataFromBlock(int blockNum, byte readBlockData[])
? {
? Serial.print("Reading data from block ");
? Serial.println(blockNum);
? //------------------------------------------------------------------------------
? /* Authenticating the desired data block for Read access using Key A */
? status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, blockNum, &key, &(mfrc522.uid));
? //------------------------------------------------------------------------------
? if (status != MFRC522::STATUS_OK){
? Serial.print("Authentication failed for Read: ");
? Serial.println(mfrc522.GetStatusCodeName(status));
? return;
? }
? else {
? Serial.println("Authentication success");
? }
? //------------------------------------------------------------------------------
? /* Reading data from the Block */
? status = mfrc522.MIFARE_Read(blockNum, readBlockData, &bufferLen);
? if (status != MFRC522::STATUS_OK){
? Serial.print("Reading failed: ");
? Serial.println(mfrc522.GetStatusCodeName(status));
? return;
? }
? else {
? Serial.println("Block was read successfully");
? }
? //------------------------------------------------------------------------------
? }
? ?
? ?
? ?
? /****************************************************************************************************
? * dumpSerial() function
? ****************************************************************************************************/
? void dumpSerial(int blockNum, byte blockData[])
? {
? Serial.print("\n");
? Serial.print("Data in Block:");
? Serial.print(blockNum);
? Serial.print(" --> ");
? for (int j=0 ; j<16 ; j++){
? Serial.write(readBlockData[j]);
? }
? Serial.print("\n");Serial.print("\n");
? }
? ?
? ?
? /****************************************************************************************************
? * dumpSerial() function
? ****************************************************************************************************/
? void toBlockDataArray(String str)
? {
? byte len = str.length();
? if(len > 16) len = 16;
? for (byte i = 0; i < len; i++) block_data[i] = str[i];
? for (byte i = len; i < 16; i++) block_data[i] = ' ';
? }

RFID发布代码

阿杜诺

? #include
? #include
? #include
? #include
? #include
? ?
? #include
? #include
? LiquidCrystal_I2C lcd(0x27, 16, 2);
? //---------------------------------------------------------------------------------------------------------
? // Enter Google Script Deployment ID:
? const char *GScriptId = "AKfycbwTtq4rcL8zUaB8rjExY9KYo26q_n0hVqkiEdjS9YEBtfRg5C80OWvEVK2Hv5YUEj8ivw";
? //---------------------------------------------------------------------------------------------------------
? // Enter network credentials:
? const char* ssid = "ECE";
? const char* password = "62806280";
? //---------------------------------------------------------------------------------------------------------
? // Enter command (insert_row or append_row) and your Google Sheets sheet name (default is Sheet1):
? String payload_base ="{"command": "insert_row", "sheet_name": "Sheet1", "values": ";
? String payload = "";
? //---------------------------------------------------------------------------------------------------------
? // Google Sheets setup (do not edit)
? const char* host= "script.google.com";
? const int httpsPort = 443;
? const char* fingerprint = "";
? String url = String("/macros/s/") + GScriptId + "/exec";
? HTTPSRedirect* client = nullptr;
? //------------------------------------------------------------
? // Declare variables that will be published to Google Sheets
? String student_id;
? //------------------------------------------------------------
? int blocks[] = {4,5,6,8,9, 10, 12};
? #define total_blocks(sizeof(blocks) / sizeof(blocks[0]))
? //------------------------------------------------------------
? #define RST_PIN0//D3
? #define SS_PIN 2//D4
? #define BUZZER 4//D2
? //------------------------------------------------------------
? MFRC522 mfrc522(SS_PIN, RST_PIN);
? MFRC522::MIFARE_Key key;
? MFRC522::StatusCode status;
? //------------------------------------------------------------
? /* Be aware of Sector Trailer Blocks */
? int blockNum = 2;
? /* Create another array to read data from Block */
? /* Legthn of buffer should be 2 Bytes more than the size of Block (16 Bytes) */
? byte bufferLen = 18;
? byte readBlockData[18];
? //------------------------------------------------------------
? ?
? /****************************************************************************************************
? * setup Function
? ****************************************************************************************************/
? void setup() {
? //----------------------------------------------------------
? Serial.begin(9600);
? delay(10);
? Serial.println('\n');
? //----------------------------------------------------------
? SPI.begin();
? //----------------------------------------------------------
? //initialize lcd screen
? lcd.init();
? // turn on the backlight
? lcd.backlight();
? lcd.clear();
? lcd.setCursor(0,0); //col=0 row=0
? lcd.print("Connecting to");
? lcd.setCursor(0,1); //col=0 row=0
? lcd.print("WiFi...");
? //----------------------------------------------------------
? // Connect to WiFi
? WiFi.begin(ssid, password);
? Serial.print("Connecting to ");
? Serial.print(ssid); Serial.println(" ...");
? ?
? while (WiFi.status() != WL_CONNECTED) {
? delay(1000);
? Serial.print(".");
? }
? Serial.println('\n');
? Serial.println("Connection established!");
? Serial.print("IP address:\t");
? Serial.println(WiFi.localIP());
? //----------------------------------------------------------
? // Use HTTPSRedirect class to create a new TLS connection
? client = new HTTPSRedirect(httpsPort);
? client->setInsecure();
? client->setPrintResponseBody(true);
? client->setContentTypeHeader("application/json");
? //----------------------------------------------------------
? lcd.clear();
? lcd.setCursor(0,0); //col=0 row=0
? lcd.print("Connecting to");
? lcd.setCursor(0,1); //col=0 row=0
? lcd.print("Google ");
? delay(5000);
? //----------------------------------------------------------
? Serial.print("Connecting to ");
? Serial.println(host);
? //----------------------------------------------------------
? // Try to connect for a maximum of 5 times
? bool flag = false;
? for(int i=0; i<5; i++){
? int retval = client->connect(host, httpsPort);
? //*************************************************
? if (retval == 1){
? flag = true;
? String msg = "Connected. OK";
? Serial.println(msg);
? lcd.clear();
? lcd.setCursor(0,0); //col=0 row=0
? lcd.print(msg);
? delay(2000);
? break;
? }
? //*************************************************
? else
? Serial.println("Connection failed. Retrying...");
? //*************************************************
? }
? //----------------------------------------------------------
? if (!flag){
? //____________________________________________
? lcd.clear();
? lcd.setCursor(0,0); //col=0 row=0
? lcd.print("Connection fail");
? //____________________________________________
? Serial.print("Could not connect to server: ");
? Serial.println(host);
? delay(5000);
? return;
? //____________________________________________
? }
? //----------------------------------------------------------
? delete client;// delete HTTPSRedirect object
? client = nullptr; // delete HTTPSRedirect object
? //----------------------------------------------------------
? }
? ?
? /****************************************************************************************************
? * loop Function
? ****************************************************************************************************/
? void loop() {
? //----------------------------------------------------------------
? static bool flag = false;
? if (!flag){
? client = new HTTPSRedirect(httpsPort);
? client->setInsecure();
? flag = true;
? client->setPrintResponseBody(true);
? client->setContentTypeHeader("application/json");
? }
? if (client != nullptr){
? if (!client->connected())
? {client->connect(host, httpsPort);}
? }
? else{Serial.println("Error creating client object!");}
? //----------------------------------------------------------------
? lcd.clear();
? lcd.setCursor(0,0); //col=0 row=0
? lcd.print("Scan your Tag");
? ?
? /* Initialize MFRC522 Module */
? mfrc522.PCD_Init();
? /* Look for new cards */
? /* Reset the loop if no new card is present on RC522 Reader */
? if ( ! mfrc522.PICC_IsNewCardPresent()) {return;}
? /* Select one of the cards */
? if ( ! mfrc522.PICC_ReadCardSerial()) {return;}
? /* Read data from the same block */
? Serial.println();
? Serial.println(F("Reading last data from RFID..."));
? //----------------------------------------------------------------
? String values = "", data;
? /*
? //creating payload - method 1
? //----------------------------------------------------------------
? ReadDataFromBlock(blocks[0], readBlockData); //student id
? data = String((char*)readBlockData); data.trim();
? student_id = data;
? //----------------------------------------------------------------
? ReadDataFromBlock(blocks[1], readBlockData); //first name
? data = String((char*)readBlockData); data.trim();
? first_name = data;
? //----------------------------------------------------------------
? ReadDataFromBlock(blocks[2], readBlockData); //last name
? data = String((char*)readBlockData); data.trim();
? last_name = data;
? //----------------------------------------------------------------
? ReadDataFromBlock(blocks[3], readBlockData); //phone number
? data = String((char*)readBlockData); data.trim();
? phone_number = data;
? //----------------------------------------------------------------
? ReadDataFromBlock(blocks[4], readBlockData); //address
? data = String((char*)readBlockData); data.trim();
? address = data; data = "";
? //----------------------------------------------------------------
? values = """ + student_id + ",";
? values += first_name + ",";
? values += last_name + ",";
? values += phone_number + ",";
? values += address + ""}";
? //----------------------------------------------------------------*/
? //creating payload - method 2 - More efficient
? for (byte i = 0; i < total_blocks; i++) {
? ReadDataFromBlock(blocks[i], readBlockData);
? //*************************************************
? if(i == 0){
? data = String((char*)readBlockData);
? data.trim();
? student_id = data;
? values = """ + data + ",";
? }
? //*************************************************
? else if(i == total_blocks-1){
? data = String((char*)readBlockData);
? data.trim();
? values += data + ""}";
? }
? //*************************************************
? else{
? data = String((char*)readBlockData);
? data.trim();
? values += data + ",";
? }
? }
? //----------------------------------------------------------------
? // Create json object string to send to Google Sheets
? // values = """ + value0 + "," + value1 + "," + value2 + ""}"
? payload = payload_base + values;
? //----------------------------------------------------------------
? lcd.clear();
? lcd.setCursor(0,0); //col=0 row=0
? lcd.print("Publishing Data");
? lcd.setCursor(0,1); //col=0 row=0
? lcd.print("Please Wait...");
? //----------------------------------------------------------------
? // Publish data to Google Sheets
? Serial.println("Publishing data...");
? Serial.println(payload);
? if(client->POST(url, host, payload)){
? // do stuff here if publish was successful
? lcd.clear();
? lcd.setCursor(0,0); //col=0 row=0
? lcd.print("Student ID: "+student_id);
? lcd.setCursor(0,1); //col=0 row=0
? lcd.print("Present");
? }
? //----------------------------------------------------------------
? else{
? // do stuff here if publish was not successful
? Serial.println("Error while connecting");
? lcd.clear();
? lcd.setCursor(0,0); //col=0 row=0
? lcd.print("Failed.");
? lcd.setCursor(0,1); //col=0 row=0
? lcd.print("Try Again");
? }
? //----------------------------------------------------------------
? // a delay of several seconds is required before publishing again
? delay(5000);
? tone(BUZZER, 1000, 1000);
? }
? ?
? ?
? /****************************************************************************************************
? *
? ****************************************************************************************************/
? /****************************************************************************************************
? * ReadDataFromBlock() function
? ****************************************************************************************************/
? void ReadDataFromBlock(int blockNum, byte readBlockData[])
? {
? //----------------------------------------------------------------------------
? /* Prepare the ksy for authentication */
? /* All keys are set to FFFFFFFFFFFFh at chip delivery from the factory */
? for (byte i = 0; i < 6; i++) {
? key.keyByte[i] = 0xFF;
? }
? //----------------------------------------------------------------------------
? /* Authenticating the desired data block for Read access using Key A */
? status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, blockNum, &key, &(mfrc522.uid));
? //----------------------------------------------------------------------------s
? if (status != MFRC522::STATUS_OK){
? Serial.print("Authentication failed for Read: ");
? Serial.println(mfrc522.GetStatusCodeName(status));
? return;
? }
? //----------------------------------------------------------------------------
? else {
? Serial.println("Authentication success");
? }
? //----------------------------------------------------------------------------
? /* Reading data from the Block */
? status = mfrc522.MIFARE_Read(blockNum, readBlockData, &bufferLen);
? if (status != MFRC522::STATUS_OK) {
? Serial.print("Reading failed: ");
? Serial.println(mfrc522.GetStatusCodeName(status));
? return;
? }
? //----------------------------------------------------------------------------
? else {
? readBlockData[16] = ' ';
? readBlockData[17] = ' ';
? Serial.println("Block was read successfully");
? }
? //----------------------------------------------------------------------------
? }

pYYBAGPV_EeATsQ0AAC-dcdD7NQ567.png

?

poYBAGPV_EmAcifmAABqLBsfaks839.png

?

?

下载该资料的人也在下载 下载该资料的人还在阅读
更多 >

评论

查看更多

下载排行

本周

  1. 1山景DSP芯片AP8248A2数据手册
  2. 1.06 MB  |  532次下载  |  免费
  3. 2RK3399完整板原理图(支持平板,盒子VR)
  4. 3.28 MB  |  339次下载  |  免费
  5. 3TC358743XBG评估板参考手册
  6. 1.36 MB  |  330次下载  |  免费
  7. 4DFM软件使用教程
  8. 0.84 MB  |  295次下载  |  免费
  9. 5元宇宙深度解析—未来的未来-风口还是泡沫
  10. 6.40 MB  |  227次下载  |  免费
  11. 6迪文DGUS开发指南
  12. 31.67 MB  |  194次下载  |  免费
  13. 7元宇宙底层硬件系列报告
  14. 13.42 MB  |  182次下载  |  免费
  15. 8FP5207XR-G1中文应用手册
  16. 1.09 MB  |  178次下载  |  免费

本月

  1. 1OrCAD10.5下载OrCAD10.5中文版软件
  2. 0.00 MB  |  234315次下载  |  免费
  3. 2555集成电路应用800例(新编版)
  4. 0.00 MB  |  33566次下载  |  免费
  5. 3接口电路图大全
  6. 未知  |  30323次下载  |  免费
  7. 4开关电源设计实例指南
  8. 未知  |  21549次下载  |  免费
  9. 5电气工程师手册免费下载(新编第二版pdf电子书)
  10. 0.00 MB  |  15349次下载  |  免费
  11. 6数字电路基础pdf(下载)
  12. 未知  |  13750次下载  |  免费
  13. 7电子制作实例集锦 下载
  14. 未知  |  8113次下载  |  免费
  15. 8《LED驱动电路设计》 温德尔著
  16. 0.00 MB  |  6656次下载  |  免费

总榜

  1. 1matlab软件下载入口
  2. 未知  |  935054次下载  |  免费
  3. 2protel99se软件下载(可英文版转中文版)
  4. 78.1 MB  |  537798次下载  |  免费
  5. 3MATLAB 7.1 下载 (含软件介绍)
  6. 未知  |  420027次下载  |  免费
  7. 4OrCAD10.5下载OrCAD10.5中文版软件
  8. 0.00 MB  |  234315次下载  |  免费
  9. 5Altium DXP2002下载入口
  10. 未知  |  233046次下载  |  免费
  11. 6电路仿真软件multisim 10.0免费下载
  12. 340992  |  191187次下载  |  免费
  13. 7十天学会AVR单片机与C语言视频教程 下载
  14. 158M  |  183279次下载  |  免费
  15. 8proe5.0野火版下载(中文版免费下载)
  16. 未知  |  138040次下载  |  免费