Hi Anyone,
Looking for guidance on my project; all thoughts and/or ideas gratefully received.
I have an RFID project that I plan to mould into a time-clock system for use as a simulation tool for motor vehicle college students; RFID cards to log students in/out each day and log in/out of tasks. I plan to use log in data to use in math classes to discuss/explore productivity and bonus systems and all the math it entails.
Anyhoo, I am an Ardweebo and this is a complicated project (for me). I am using an Arduino Mega, 40x2 LCD, RTC breakout, SD card Breakout and an Adafruit NFC shield and two beautiful 10mm frosted LEDs for further visual communication.
I have these working together for basic security checks; student swipes card, the arduino checks card id against known UIDs and either lets them enter or not.
I am struggling to get to grips with two elements; the storing of RFID card UIDs and returning student names.
I currently store the known UIDs in the source code: (I hope I have inserted this correctly)
#include <Wire.h>
#include <RTClib.h>
#include <stdio.h>
#include <constants.h>
#include <vfd.h>
#include <vfd.c>
#include <SPI.h>
#include <SD.h>
#include <Adafruit_PN532.h>
File myFile;
RTC_DS1307 rtc;
int wgnd = 18; // RTC Breakout board doesn't require much juice. Repurposing pin 18 & 19 as GND & +5V output.
int w5v = 19;
int refresh_rate = 5000; // Default Refresh rate of 5 seconds
const int ledPin = 16; // The Green LED
const int ledPin1 = 17; // The RED LED
const int chipSelect = 53;
const int numCodes = 5; // the number of RFID tags allocated to sketch
const char *codes[] // RFID UID codes
{
"4D398796", // Tag 1
"8B2A6474", // Tag 2
"9BF36174", // Tag 3
"0B426B74", // Tag 4
"3BF46B74" // Tag 5
};
char code[16]; // hex string of code
Adafruit_PN532 nfc(2, 3); // IRQ, RESET pins : Reset pin not connected by default on the NFC Shield
/*******************************************************************************/
Since I won't be the only teacher using this Time-Clock when completed, it means that storing the authorised UIDs in the source code is not feasible. I need to store it on the SD card (EEPROM not big enough to accomodate number of students) in a file (txt? csv? other format?). I have been trying to manipulate this bit of code I added (from Arduino SD card tutorial) to no avail:
/********************** Next, set up how Tag data is checked on SD card... **********************/
myFile = SD.open("myFile.txt"); //Read the Tag information (myFile.txt) to check tag data on SD card
if (myFile)
{
Serial.println("myFile.txt");
while(myFile.available())
{
Serial.write(myFile.read());
}
Serial.print("Student Number: ");
Serial.print(code);
myFile.close(); // Close the file when finished.
}
else
{
Serial.println(F("Error opening myFile.txt."));
return;
}
Anyone got ideas how I can get this to work? I am quite sure it is missing some things like functions etc?
Secondly, when reading the RFID card, I would like the system to return the student's name as opposed to the card's UID as it is less impersonal (though I am sure I could use this in my English classes as a discussion point!).
In my very limited knowledge, I am thinking that this links to my first problem in that I get arduino to check for UID in SD file and return the associated student name? Unfortunately, I have no code to share as I have not found anything on the internet that I understand would help me fix this.
Thought I would include a picture of my project so far.
Again, all thoughts and/or ideas gratefully received (in Ardweebo and Laymens' language!).
Full code for this project as attachment in case I am looking in the wrong place. Please note; the code is a cobble of many sources and is, in all likelihood, horribly mashed together but gotta learn somehow so please laugh discreetly...
Thanks
JmB1971
Doc1.pdf (512 KB)
RFID System.pdf (166 KB)
Screen dump of Serial Monitor.pdf (123 KB)