spreedsheet
spreedsheet
com/spreadsheets/d/1zzDhmtr_TNMsatd-
MZtL9K7HYNH5il4AWW8KDsTLkZE/edit?gid=0#gid=0
https://docs.google.com/spreadsheets/d/1zzDhmtr_TNMsatd-
MZtL9K7HYNH5il4AWW8KDsTLkZE/edit?gid=1540099858#gid=1540099858
#include <deprecated.h>
#include <MFRC522.h>
#include <MFRC522Extended.h>
#include <require_cpp11.h>
//
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>> 01_Test_RFID-RC522_Serial
// This code only takes the UID in string form.
// If you want to see more detailed information about an RFID card or keychain,
please run the program code "DumpInfo".
// The "DumpInfo" program code is located at :
// Library folder "MFRC522" -> "examples" folder -> "DumpInfo" folder ->
DumpInfo.ino
// or
// From Arduino IDE : File -> Examples -> MFRC522 -> DumpInfo
// or
// From Arduino IDE : File -> Examples -> INCOMPATIBLE-> MFRC522 -> DumpInfo
// Create MFRC522 object as "mfrc522" and set SS/SDA PIN and Reset PIN.
MFRC522 mfrc522(SS_PIN, RST_PIN);
//
________________________________________________________________________________get
UID()
// Subroutine to obtain UID/ID when RFID card or RFID keychain is tapped to RFID-
RC522 module.
int getUID() {
if(!mfrc522.PICC_IsNewCardPresent()) {
return 0;
}
if(!mfrc522.PICC_ReadCardSerial()) {
return 0;
}
mfrc522.PICC_HaltA();
mfrc522.PCD_StopCrypto1();
return 1;
}
//________________________________________________________________________________
//
________________________________________________________________________________byt
eArray_to_string()
void byteArray_to_string(byte array[], unsigned int len, char buffer[]) {
for (unsigned int i = 0; i < len; i++) {
byte nib1 = (array[i] >> 4) & 0x0F;
byte nib2 = (array[i] >> 0) & 0x0F;
buffer[i*2+0] = nib1 < 0xA ? '0' + nib1 : 'A' + nib1 - 0xA;
buffer[i*2+1] = nib2 < 0xA ? '0' + nib2 : 'A' + nib2 - 0xA;
}
buffer[len*2] = '\0';
}
//________________________________________________________________________________
//
________________________________________________________________________________VOI
D SETUP()
void setup(){
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println();
delay(1000);
delay(1000);
Serial.println();
Serial.println("Please tap your card or key chain to the RFID-RC522 module.");
}
//________________________________________________________________________________
//
________________________________________________________________________________VOI
D LOOP()
void loop(){
// put your main code here, to run repeatedly:
readsuccess = getUID();
if(readsuccess){
Serial.println();
Serial.print("UID : ");
Serial.println(UID_Result);
delay(500);
}
delay(10);
}
//________________________________________________________________________________
//
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<<<<<<
endiiiiingggendiiiiingggendiiiiingggendiiiiingggendiiiiingggendiiiiingggendiiiiingg
g
#include <SPI.h>
#include <MFRC522.h>
#include <WiFi.h>
#include <HTTPClient.h>
// Wi-Fi credentials
const char* ssid = "THIRD FLOOR -4G";
const char* password = "abcd@123";
mfrc522.PICC_HaltA();
mfrc522.PCD_StopCrypto1();
return 1;
}
Serial.println();
Serial.println("-------------");
Serial.println("Sending request to Google Sheets...");
Serial.print("URL : ");
Serial.println(http_req_url);
HTTPClient http;
http.begin(http_req_url.c_str());
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
String payload;
if (httpCode > 0) {
payload = http.getString();
Serial.println("Payload : " + payload);
}
Serial.println("-------------");
http.end();
if (sts_Res == "OK") {
String atc_Info = getValue(payload, ',', 1);
if (atc_Info == "TI_Successful") {
String atc_Name = getValue(payload, ',', 2);
String atc_Date = getValue(payload, ',', 3);
String atc_Time_In = getValue(payload, ',', 4);
Serial.println("Time In Recorded:");
Serial.println("Name: " + atc_Name);
Serial.println("Date: " + atc_Date);
Serial.println("Time In: " + atc_Time_In);
}
if (atc_Info == "TO_Successful") {
String atc_Name = getValue(payload, ',', 2);
String atc_Date = getValue(payload, ',', 3);
String atc_Time_In = getValue(payload, ',', 4);
String atc_Time_Out = getValue(payload, ',', 5);
Serial.println("Time Out Recorded:");
Serial.println("Name: " + atc_Name);
Serial.println("Date: " + atc_Date);
Serial.println("Time In: " + atc_Time_In);
Serial.println("Time Out: " + atc_Time_Out);
}
}
}
}
void setup(){
Serial.begin(115200);
Serial.println();
delay(1000);
SPI.begin();
mfrc522.PCD_Init();
Serial.println();
Serial.println("-------------");
Serial.println("WIFI mode : STA");
WiFi.mode(WIFI_STA);
Serial.println("-------------");
Serial.println();
Serial.println("------------");
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
void loop(){
if (getUID()) {
Serial.println("UID: " + UID_Result);
http_Req(modes, UID_Result);
delay(2000); // Delay to prevent multiple reads
}
}