I am a ID card manufacturer in kolkata . we provide id card for student . One day when we consulting with my head master suddenly show that there is so many(lot of ) attendance book stag on a rack and hard some shocking story about some missing student . And attempted to create a new gen attendance m/c .
** This module can :
~ Read TAG ID with a simple swap upon reader
~ store record with internal sd card
~ send sms from Server after every attendance.
/*
* This sketch sends data via HTTP GET requests to data.sparkfun.com service.
*
* You need to get streamId and privateKey at data.sparkfun.com and paste them
* below. Or just customize this script to talk to other HTTP servers.
*
*/
#include
#include
#include "MFRC522.h"
#define RST_PIN 5 // RST-PIN für RC522 - RFID - SPI - Modul GPIO5
#define SS_PIN 2 // SDA-PIN für RC522 - RFID - SPI - Modul GPIO2
const char* ssid = "ARDIND_B";
const char* password = "***************";
const char* host = "progoti.in";
//const char* streamId = "....................";
//const char* privateKey = "....................";
int devstts=0;
MFRC522 mfrc522(SS_PIN, RST_PIN);
void setup() {
pinMode(16, OUTPUT);
pinMode(15, OUTPUT);
pinMode(4, OUTPUT);
Serial.begin(115200);
delay(100);
// We start by connecting to a WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522
WiFi.begin(ssid, password);
int retries = 0;
while ((WiFi.status() != WL_CONNECTED) && (retries < 10)) {
retries++;
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println(" WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.println(F("Ready!"));
Serial.println(F("======================================================"));
Serial.println(F("Scan for Card and print UID:"));
Serial.print("connecting to ");
Serial.println(host);
// Use WiFiClient class to create TCP connections
WiFiClient client;
const int httpPort = 80;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
digitalWrite(16, HIGH); // turn the LED on (HIGH is the voltage level)
delay(10000); // wait for a second
digitalWrite(16, LOW);
return;
}
// We now create a URI for the request
String url = "/proj/getdevstts.php?name=amr1257";
Serial.print("Requesting URL: ");
Serial.println(url);
// This will send the request to the server
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
delay(10);
// Read all the lines of the reply from server and print them to Serial
while(client.available()){
String line = client.readStringUntil('\r');
Serial.print(line);
line.trim();
if (line.equals("in-mode"))
{
Serial.println("IN-MODE");
digitalWrite(4, HIGH); // turn the out LED on
devstts=1; //set the device as out mode
}
if (line.equals("out-mode"))
{
Serial.println("OUT-MODE");
digitalWrite(15, HIGH); // turn the out LED on
devstts=2; //set the device as out mode
}
}
Serial.println();
Serial.println("closing connection");
}
int value = 0;
String readIDold;
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();
String readID = "s";
for (byte i = 0; i < mfrc522.uid.size; i++) {
readID += mfrc522.uid.uidByte[i];
}
if(readID!=readIDold)
{
readIDold=readID;
Serial.print("connecting to ");
Serial.println(host);
// Use WiFiClient class to create TCP connections
WiFiClient client;
const int httpPort = 80;
if (!client.connect(host, httpPort)) {
//client.println("GET /search?q=arduino HTTP/1.0");
Serial.println("connection failed");
digitalWrite(16, HIGH); // turn the LED on (HIGH is the voltage level)
delay(10000); // wait for a second
digitalWrite(16, LOW);
return;
}
// We now create a URI for the request
String url = "/proj/getnmid.php?name=amr1257&id=";
url += readID;
Serial.print("Requesting URL: ");
Serial.println(url);
// This will send the request to the server
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
delay(10);
// Read all the lines of the reply from server and print them to Serial
while(client.available()){
String line = client.readStringUntil('\r');
Serial.print(line);
line.trim();
if (line.equals("Change-mode"))
{
if (devstts==1)
{
Serial.println("OUT-MODE");
digitalWrite(4, LOW);
digitalWrite(15, HIGH);// turn the in LED off
devstts=2; //set the device as out mode
}
else
{
Serial.println("IN-MODE");
digitalWrite(15, LOW);
digitalWrite(4, HIGH); // turn the in LED on
devstts=1;
}
}
if (line.equals("In-mode"))
{
Serial.println("IN-MODE");
digitalWrite(4, HIGH);// turn the in LED on
devstts=1;
}
}
Serial.println();
Serial.println("closing connection");
digitalWrite(16, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(16, LOW); // turn the LED off by making the voltage LOW
}
else
{
Serial.print("Weating For New Card");
}
}
// 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);
}
}
After a long time experiment realize that this module can send a unic number with every individual card and upload time attachment . One station module is there to collect RFID card or Your ID card (we are using 1k rfid ).
At the first time when I realize that this module is working...Over internet I get response from url http://progoti.in/proj1/vunmid.php
amr1257 ID - s11218413446 Date - 2016-01-15 Time- 09:53:13
amr1257 ID - s17614213446 Date - 2016-01-15 Time- 09:56:36
amr1257 ID - s17616113346 Date - 2016-01-15 Time- 09:56:49
First part of this doc is ID and then Punching TIME
Update ...
Comments