What does he mean about the reset button?
I'm sorry, I'm new to this kind of stuff
What does he mean about the reset button?
I'm sorry, I'm new to this kind of stuff
Welcome to the forum
You started a topic in the Uncategorised category of the forum
Your topic has been moved to a relevant category. Please be careful in future when deciding where to start new topics
Who is "he" in your question and what is "he" referring to ?
May we assume that the csv file is on a SD card?
If yes, simplest solution:
Sorry, I forgot to mention. No, I am only storing my data on the Arduino UNO R3 board itself. How do I extract its data?
I can show you the code if necessary. It's about 600 lines
Okay, I'll take note on that
It is necessary
This is the easiest way to tidy up the code and add the code tags
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.
Okay, here is the code for it
#include "Adafruit_Fingerprint.h" //fingerprint library header file
#include <EEPROM.h> //command for storing data
#include <LiquidCrystal.h> //lcd header file
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
#include <SoftwareSerial.h>
SoftwareSerial fingerPrint(2, 3); //for tx/rx communication between arduino & r305 fingerprint sensor
#include <Wire.h>
#include "RTClib.h" //library file for DS3231 RTC Module
RTC_DS3231 rtc;
uint8_t id;
Adafruit_Fingerprint finger = Adafruit_Fingerprint(&fingerPrint);
#define register_back 14 //
#define delete_ok 15
#define forward 16
#define reverse 17
#define match 5
#define indFinger 7
#define buzzer 5
#define records 10 // 10 for 10 user
int user1, user2, user3, user4, user5, user6, user7, user8, user9, user10;
DateTime now;
void setup() {
delay(1000);
lcd.begin(16, 2);
Serial.begin(9600);
pinMode(register_back, INPUT_PULLUP);
pinMode(forward, INPUT_PULLUP);
pinMode(reverse, INPUT_PULLUP);
pinMode(delete_ok, INPUT_PULLUP);
pinMode(match, INPUT_PULLUP);
pinMode(buzzer, OUTPUT);
pinMode(indFinger, OUTPUT);
digitalWrite(buzzer, LOW);
if (digitalRead(register_back) == 0) {
digitalWrite(buzzer, HIGH);
delay(500);
digitalWrite(buzzer, LOW);
lcd.clear();
lcd.print("Please wait !");
lcd.setCursor(0, 1);
lcd.print("Downloding Data");
Serial.println("Please wait");
Serial.println("Downloding Data..");
Serial.println();
Serial.print("S.No. ");
for (int i = 0; i < records; i++) {
digitalWrite(buzzer, HIGH);
delay(500);
digitalWrite(buzzer, LOW);
Serial.print(" User ID");
Serial.print(i + 1);
Serial.print(" ");
}
Serial.println();
int eepIndex = 0;
for (int i = 0; i < 30; i++) {
if (i + 1 < 10)
Serial.print('0');
Serial.print(i + 1);
Serial.print(" ");
eepIndex = (i * 7);
download(eepIndex);
eepIndex = (i * 7) + 210;
download(eepIndex);
eepIndex = (i * 7) + 420;
download(eepIndex);
eepIndex = (i * 7) + 630;
download(eepIndex);
eepIndex = (i * 7) + 840;
download(eepIndex);
eepIndex = (i * 7) + 1050;
download(eepIndex);
eepIndex = (i * 7) + 1260;
download(eepIndex);
eepIndex = (i * 7) + 1470;
download(eepIndex);
eepIndex = (i * 7) + 1680;
download(eepIndex);
Serial.println();
}
}
if (digitalRead(delete_ok) == 0) {
lcd.clear();
lcd.print("Please Wait");
lcd.setCursor(0, 1);
lcd.print("Reseting.....");
for (int i = 1000; i < 1005; i++)
EEPROM.write(i, 0);
for (int i = 0; i < 841; i++)
EEPROM.write(i, 0xff);
lcd.clear();
lcd.print("System Reset");
delay(1000);
}
lcd.clear();
lcd.print(" Fingerprint ");
lcd.setCursor(0, 1);
lcd.print("Attendance System");
delay(2000);
lcd.clear();
digitalWrite(buzzer, HIGH);
delay(500);
digitalWrite(buzzer, LOW);
for (int i = 1000; i < 1000 + records; i++) {
if (EEPROM.read(i) == 0xff)
EEPROM.write(i, 0);
}
finger.begin(57600);
Serial.begin(9600);
lcd.clear();
lcd.print("Finding Module..");
lcd.setCursor(0, 1);
delay(2000);
if (finger.verifyPassword()) {
Serial.println("Found fingerprint sensor!");
lcd.clear();
lcd.print(" Module Found");
delay(2000);
} else {
Serial.println("Did not find fingerprint sensor :(");
lcd.clear();
lcd.print("Module Not Found");
lcd.setCursor(0, 1);
lcd.print("Check Connections");
while (1)
;
}
if (!rtc.begin())
Serial.println("Couldn't find RTC");
// rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
if (rtc.lostPower()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(2018, 6, 7, 11, 0, 0));
// This line sets the RTC with an explicit date & time, for example to set
// June 7, 2018 at 11am you would call:
// rtc.adjust(DateTime(2018, 6, 7, 11, 0, 0));
}
lcd.setCursor(0, 0);
lcd.print(" Press Match to ");
lcd.setCursor(0, 1);
lcd.print(" Start System");
delay(3000);
user1 = EEPROM.read(1000);
user2 = EEPROM.read(1001);
user3 = EEPROM.read(1002);
user4 = EEPROM.read(1003);
user5 = EEPROM.read(1004);
lcd.clear();
digitalWrite(indFinger, HIGH);
}
void loop() {
now = rtc.now();
lcd.setCursor(0, 0);
lcd.print("Time: ");
lcd.print(now.hour(), DEC);
lcd.print(':');
lcd.print(now.minute(), DEC);
lcd.print(':');
lcd.print(now.second(), DEC);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print("Date: ");
lcd.print(now.day(), DEC);
lcd.print('/');
lcd.print(now.month(), DEC);
lcd.print('/');
lcd.print(now.year(), DEC);
lcd.print(" ");
delay(500);
int result = getFingerprintIDez();
if (result > 0) {
digitalWrite(indFinger, LOW);
delay(100);
lcd.clear();
lcd.print("ID:");
lcd.print(result);
lcd.setCursor(0, 1);
lcd.print("Please Wait....");
delay(1000);
attendance(result);
lcd.clear();
lcd.print("Attendance ");
lcd.setCursor(0, 1);
lcd.print("Registered");
delay(1000);
digitalWrite(indFinger, HIGH);
return;
}
checkKeys();
delay(300);
}
// dmyyhms - 7 bytes
void attendance(int id) {
int user = 0, eepLoc = 0;
if (id == 1) {
eepLoc = 0;
user = user1++;
} else if (id == 2) {
eepLoc = 210;
user = user2++;
} else if (id == 3) {
eepLoc = 420;
user = user3++;
} else if (id == 4) {
eepLoc = 630;
user = user4++;
} else if (id == 5) {
eepLoc = 0;
user = user5++;
} else if (id == 6) {
eepLoc = 840;
user = user5++;
} else if (id == 7) {
eepLoc = 1050;
user = user7++;
} else if (id == 8) {
eepLoc = 1260;
user = user8++;
} else if (id == 9) {
eepLoc = 1470;
user = user9++;
} else if (id == 10) {
eepLoc = 1680;
user = user8++;
}
/*else if(id == 5) // fifth user
{
eepLoc=840;
user=user5++;
}*/
else
return;
int eepIndex = (user * 7) + eepLoc;
EEPROM.write(eepIndex++, now.hour());
EEPROM.write(eepIndex++, now.minute());
EEPROM.write(eepIndex++, now.second());
EEPROM.write(eepIndex++, now.day());
EEPROM.write(eepIndex++, now.month());
EEPROM.write(eepIndex++, now.year() >> 8);
EEPROM.write(eepIndex++, now.year());
EEPROM.write(1000, user1);
EEPROM.write(1001, user2);
EEPROM.write(1002, user3);
EEPROM.write(1003, user4);
// EEPROM.write(1004,user5);
// EEPROM.write(1005,user6);
// EEPROM.write(4,user5); // figth user
}
void checkKeys() {
if (digitalRead(register_back) == 0) {
lcd.clear();
lcd.print("Please Wait");
delay(1000);
while (digitalRead(register_back) == 0)
;
Enroll();
}
else if (digitalRead(delete_ok) == 0) {
lcd.clear();
lcd.print("Please Wait");
delay(1000);
delet();
}
}
void Enroll() {
int count = 1;
lcd.clear();
lcd.print("Enter Finger ID:");
while (1) {
lcd.setCursor(0, 1);
lcd.print(count);
if (digitalRead(forward) == 0) {
count++;
if (count > records)
count = 1;
delay(500);
}
else if (digitalRead(reverse) == 0) {
count--;
if (count < 1)
count = records;
delay(500);
} else if (digitalRead(delete_ok) == 0) {
id = count;
getFingerprintEnroll();
for (int i = 0; i < records; i++) {
if (EEPROM.read(i) != 0xff) {
EEPROM.write(i, id);
break;
}
}
return;
}
else if (digitalRead(register_back) == 0) {
return;
}
}
}
void delet() {
int count = 1;
lcd.clear();
lcd.print("Enter Finger ID");
while (1) {
lcd.setCursor(0, 1);
lcd.print(count);
if (digitalRead(forward) == 0) {
count++;
if (count > records)
count = 1;
delay(500);
}
else if (digitalRead(reverse) == 0) {
count--;
if (count < 1)
count = records;
delay(500);
} else if (digitalRead(delete_ok) == 0) {
id = count;
deleteFingerprint(id);
for (int i = 0; i < records; i++) {
if (EEPROM.read(i) == id) {
EEPROM.write(i, 0xff);
break;
}
}
return;
}
else if (digitalRead(register_back) == 0) {
return;
}
}
}
uint8_t getFingerprintEnroll() {
int p = -1;
lcd.clear();
lcd.print("finger ID:");
lcd.print(id);
lcd.setCursor(0, 1);
lcd.print("Place Finger");
delay(2000);
while (p != FINGERPRINT_OK) {
p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
Serial.println("Image taken");
lcd.clear();
lcd.print("Image taken");
break;
case FINGERPRINT_NOFINGER:
Serial.println("No Finger");
lcd.clear();
lcd.print("No Finger Found");
break;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
lcd.clear();
lcd.print("Comm Error");
break;
case FINGERPRINT_IMAGEFAIL:
Serial.println("Imaging error");
lcd.clear();
lcd.print("Imaging Error");
break;
default:
Serial.println("Unknown error");
lcd.clear();
lcd.print("Unknown Error");
break;
}
}
// OK success!
p = finger.image2Tz(1);
switch (p) {
case FINGERPRINT_OK:
Serial.println("Image converted");
lcd.clear();
lcd.print("Image converted");
break;
case FINGERPRINT_IMAGEMESS:
Serial.println("Image too messy");
lcd.clear();
lcd.print("Image too messy");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
lcd.clear();
lcd.print("Comm Error");
return p;
case FINGERPRINT_FEATUREFAIL:
Serial.println("Could not find fingerprint features");
lcd.clear();
lcd.print("Feature Not Found");
return p;
case FINGERPRINT_INVALIDIMAGE:
Serial.println("Could not find fingerprint features");
lcd.clear();
lcd.print("Feature Not Found");
return p;
default:
Serial.println("Unknown error");
lcd.clear();
lcd.print("Unknown Error");
return p;
}
Serial.println("Remove finger");
lcd.clear();
lcd.print("Remove Finger");
delay(2000);
p = 0;
while (p != FINGERPRINT_NOFINGER) {
p = finger.getImage();
}
Serial.print("ID ");
Serial.println(id);
p = -1;
Serial.println("Place same finger again");
lcd.clear();
lcd.print("Place Finger");
lcd.setCursor(0, 1);
lcd.print(" Again");
while (p != FINGERPRINT_OK) {
p = finger.getImage();
switch (p) {
case FINGERPRINT_OK:
Serial.println("Image taken");
break;
case FINGERPRINT_NOFINGER:
Serial.print(".");
break;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
break;
case FINGERPRINT_IMAGEFAIL:
Serial.println("Imaging error");
break;
default:
Serial.println("Unknown error");
return;
}
}
// OK success!
p = finger.image2Tz(2);
switch (p) {
case FINGERPRINT_OK:
Serial.println("Image converted");
break;
case FINGERPRINT_IMAGEMESS:
Serial.println("Image too messy");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
Serial.println("Communication error");
return p;
case FINGERPRINT_FEATUREFAIL:
Serial.println("Could not find fingerprint features");
return p;
case FINGERPRINT_INVALIDIMAGE:
Serial.println("Could not find fingerprint features");
return p;
default:
Serial.println("Unknown error");
return p;
}
// OK converted!
Serial.print("Creating model for #");
Serial.println(id);
p = finger.createModel();
if (p == FINGERPRINT_OK) {
Serial.println("Prints matched!");
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
Serial.println("Communication error");
return p;
} else if (p == FINGERPRINT_ENROLLMISMATCH) {
Serial.println("Fingerprints did not match");
return p;
} else {
Serial.println("Unknown error");
return p;
}
Serial.print("ID ");
Serial.println(id);
p = finger.storeModel(id);
if (p == FINGERPRINT_OK) {
Serial.println("Stored!");
lcd.clear();
lcd.print(" Finger Stored!");
delay(2000);
} else if (p == FINGERPRINT_PACKETRECIEVEERR) {
Serial.println("Communication error");
return p;
} else if (p == FINGERPRINT_BADLOCATION) {
Serial.println("Could not store in that location");
return p;
} else if (p == FINGERPRINT_FLASHERR) {
Serial.println("Error writing to flash");
return p;
} else {
Serial.println("Unknown error");
return p;
}
}
int getFingerprintIDez() {
uint8_t p = finger.getImage();
if (p != FINGERPRINT_OK)
return -1;
p = finger.image2Tz();
if (p != FINGERPRINT_OK)
return -1;
p = finger.fingerFastSearch();
if (p != FINGERPRINT_OK) {
lcd.clear();
lcd.print("Finger Not Found");
lcd.setCursor(0, 1);
lcd.print("Try Later");
delay(2000);
return -1;
}
// found a match!
Serial.print("Found ID #");
Serial.print(finger.fingerID);
return finger.fingerID;
}
uint8_t deleteFingerprint(uint8_t id) {
uint8_t p = -1;
lcd.clear();
lcd.print("Please wait");
p = finger.deleteModel(id);
if (p == FINGERPRINT_OK) {
Serial.println("Deleted!");
lcd.clear();
lcd.print("Finger Deleted");
lcd.setCursor(0, 1);
lcd.print("Successfully");
delay(1000);
}
else {
Serial.print("Something Wrong");
lcd.clear();
lcd.print("Something Wrong");
lcd.setCursor(0, 1);
lcd.print("Try Again Later");
delay(2000);
return p;
}
}
void download(int eepIndex) {
if (EEPROM.read(eepIndex) != 0xff) {
Serial.print("T->");
if (EEPROM.read(eepIndex) < 10)
Serial.print('0');
Serial.print(EEPROM.read(eepIndex++));
Serial.print(':');
if (EEPROM.read(eepIndex) < 10)
Serial.print('0');
Serial.print(EEPROM.read(eepIndex++));
Serial.print(':');
if (EEPROM.read(eepIndex) < 10)
Serial.print('0');
Serial.print(EEPROM.read(eepIndex++));
Serial.print(" D->");
if (EEPROM.read(eepIndex) < 10)
Serial.print('0');
Serial.print(EEPROM.read(eepIndex++));
Serial.print('/');
if (EEPROM.read(eepIndex) < 10)
Serial.print('0');
Serial.print(EEPROM.read(eepIndex++));
Serial.print('/');
Serial.print(EEPROM.read(eepIndex++) << 8 | EEPROM.read(eepIndex++));
} else {
Serial.print("---------------------------");
}
Serial.print(" ");
}
Is the download()
function the function to get the data to the PC? If so, use a proper terminal program (instead of serial monitor) that allows you to save to file.
I'm not quite sure on that first question. Can you recommend a good proper terminal program that allows me to save to file?
And do you think I can still retrieve that data after a week, month or so?
Edit: I got that code from someone on YouTube and I am also trying to understand some parts of it
Well, perhaps it might help some of us to help you, if you provided that youTube link, then? We can't read your mind.
If the data has not been overwritten, then the datasheet for the 328P (the micro on your UNO) says:
High Endurance Non-volatile Memory Segments
̶ 4/8/16/32KBytes of In-System Self-Programmable Flash program memory
̶ 256/512/512/1KBytes EEPROM
̶ 512/1K/1K/2KBytes Internal SRAM
̶ Write/Erase Cycles: 10,000 Flash/100,000 EEPROM
̶ Data retention: 20 years at 85°C/100 years at 25°C(1)
You will be good for a while longer than a month
Oh great, thanks for that information
Do i need an sd card? Is the storage from the arduino uno r3 enough?
The lack of comments in that code makes it difficult to figure out what is going on. But I think it keeps a count of how many times a user with a registered fingerprint is recognised by the system (the user1..n variables). It also seems to record the time and date when a particular user last had their fingerprint recognised - overwriting the previous entry.
The amount of data stored doesn't appear to grow as time passes and more fingerprint recognitions happen.
If that is the case, then the internal EEPROM would be able to hold the information. However, you do need to be aware of the limitations of writing to EEPROM. The datasheet says that the EEPROM is good for 100,000 write/erase cycles. For a small group of people, this might not be an issue.
Do you know what the code is supposed to do? Does it meet your needs or do you intend to expand it?
I was also having difficulties with understanding the code because of that
What do you mean by overwriting it? Erasing the previous user and replacing it with the other one?
Thanks for informing me more about the code, I also do know what the code does in a basic way of understanding. My concern for now is how to retrieve or download the data from the Arduino UNO R3.
My plan is to take all 45 student's attendance, only in the morning with their fingerprints and hopefully I can get the data once I will bring my Arduino UNO R3 back and connect it to my PC.
I have searched all over the internet within my knowledge and experience about retrieving data from the EEPROM, but I can't seem to find one that matches my problem. Let alone when I asked the guy from the video tutorial about how to retrieve the data to which I never really understood what he meant.
Do you think that 45 students fingerprint data won't be too much?
@1von You won't be pleased to hear this but the whole sketch is a mess and could be written in a much neater, cleaner way
If you want to keep the current sketch then start by telling us what happens when you call the download function. What do you see on the Serial monitor ?
Ok, so lets take things one at a time:
The code seems to hold a count of how many times a users fingerprint has been recognised. This seems to be the number held in user1, user2 etc and is incremented by 1 in the attendance() function.
The attendance() function also writes the date and time that the fingerprint was recognised into the EEPROM. I'm not sure now if the code overwrites the previous date and time that was written for that particular user or whether it adds the date and time to a list in EEPROM.
The code defines pin 14 as register_back. This pin is configured as an input and read during setup(). I'm guessing that if the code sees that pin grounded, then it goes into the data download mode. This simply appears to be printing out the values that have been stored in the EEPROM. It will appear in whatever PC serial terminal program you use. Depending on the PC program, you can sometimes turn logging on and the PC program will save the received information into a file. Or you can simply highlight it in the IDE serial monitor and copy and paste it into Notepad or similar program.
From what I can tell, you can only download by grounding that pin and pressing the RESET button or cycling the power to the UNO.
Ok, so you need to work out how much storage each user requires in the EEPROM and then multiply that by 45. If the number you get is less than 2048, then you are OK. If it is more than 2048, then you need to change something. Either reduce the amount of logging or use an external EEPROM chip which will easily cater for your needs.
I am probably stressing you guys out but I have no clue how to call the download function, like what I said, this is not my code and I am just trying my hardest to understand what the guy from the tutorial did