ElectroPeak
Published © GPL3+

Arduino Fingerprint Attendance System w/ Cloud Data Storage

Make a professional fingerprint attendance device with Arduino. Your data is saved to cloud so you can access it everywhere.

IntermediateFull instructions provided5 hours15,552

Things used in this project

Hardware components

Arduino Mega 2560 R3
×1
ElectroPeak R301T Fingerprint sensor
×1
ElectroPeak Micro SD TF Card Adapter Module
×1
ElectroPeak DS3231 I2C RTC Module
×1
ElectroPeak 3.5" TFT Color Display Screen Module
×1
ElectroPeak NodeMCU ESP8266 ESP-12E Board
×1
ElectroPeak male to Female Jumper Wire
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Laser cutter (generic)
Laser cutter (generic)
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Custom parts and enclosures

Fingerprint_Attendance_Code

Attendance_Device_Laser_Cut_Map

Code

Code 1

Arduino
Interfacing with Thingspeak and Uploading Data
/*
  WriteMultipleFields
  
  Description: Writes values to fields 1,2,3,4 and status in a single Thingspeak update every 20 seconds.
  
  Hardware: ESP8266 based boards
  
  !!! IMPORTANT - Modify the secrets.h file for this project with your network connection and Thingspeak channel details. !!!
  
  Note:
  - Requires ESP8266WiFi library and ESP8622 board add-on. See https://github.com/esp8266/Arduino for details.
  - Select the target hardware from the Tools->Board menu
  - This example is written for a network using WPA encryption. For WEP or WPA, change the WiFi.begin() call accordingly.
  
  Thingspeak ( https://www.Thingspeak.com ) is an analytic IoT platform service that allows you to aggregate, visualize, and 
  analyze live data streams in the cloud. Visit https://www.Thingspeak.com to sign up for a free account and create a channel.  
  
  Documentation for the Thingspeak Communication Library for Arduino is in the README.md folder where the library was installed.
  See https://www.mathworks.com/help/Thingspeak/index.html for the full Thingspeak documentation.
  
  For licensing information, see the accompanying license file.
  
  Copyright 2018, The MathWorks, Inc.
*/

#include "Thingspeak.h"
#include "secrets.h"
#include <ESP8266WiFi.h>

char ssid[] = SECRET_SSID;   // your network SSID (name) 
char pass[] = SECRET_PASS;   // your network password
int keyIndex = 0;            // your network key Index number (needed only for WEP)
WiFiClient  client;

unsigned long myChannelNumber = SECRET_CH_ID;
const char * myWriteAPIKey = SECRET_WRITE_APIKEY;

// Initialize our values
int number1 = 0;
int number2 = random(0,100);
int number3 = random(0,100);
int number4 = random(0,100);
String myStatus = "";

void setup() {
  Serial.begin(115200);  // Initialize serial

  WiFi.mode(WIFI_STA); 
  Thingspeak.begin(client);  // Initialize Thingspeak
}

void loop() {

  // Connect or reconnect to WiFi
  if(WiFi.status() != WL_CONNECTED){
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(SECRET_SSID);
    while(WiFi.status() != WL_CONNECTED){
      WiFi.begin(ssid, pass);  // Connect to WPA/WPA2 network. Change this line if using open or WEP network
      Serial.print(".");
      delay(5000);     
    } 
    Serial.println("\nConnected.");
  }

  // set the fields with the values
  Thingspeak.setField(1, number1);
  Thingspeak.setField(2, number2);
  Thingspeak.setField(3, number3);
  Thingspeak.setField(4, number4);

  // figure out the status message
  if(number1 > number2){
    myStatus = String("field1 is greater than field2"); 
  }
  else if(number1 < number2){
    myStatus = String("field1 is less than field2");
  }
  else{
    myStatus = String("field1 equals field2");
  }
  
  // set the status
  Thingspeak.setStatus(myStatus);
  
  // write to the Thingspeak channel
  int x = Thingspeak.writeFields(myChannelNumber, myWriteAPIKey);
  if(x == 200){
    Serial.println("Channel update successful.");
  }
  else{
    Serial.println("Problem updating channel. HTTP error code " + String(x));
  }
  
  // change the values
  number1++;
  if(number1 > 99){
    number1 = 0;
  }
  number2 = random(0,100);
  number3 = random(0,100);
  number4 = random(0,100);
  
  delay(20000); // Wait 20 seconds to update the channel again
}

Code 2

Arduino
#include "Thingspeak.h"
#include ESP8266WiFi.h>


char ssid[] = "YOUR SSID";
char pass[] = "SSID PASSWORD";
WiFiClient  client;

unsigned long myChannelNumber = YOUR CHANNEL ID;
const char * myWriteAPIKey = "YOUR CHANNEL WRITE API KEY";

String Final = "";

String Date = "";
String Enter = "";
String Exit = "";
String Name = "";
String WT = "";

void String_Analyze(String input) {
  int index1, index2, index3, index4;
  index1 =  input.indexOf('*', 0);
  index2 =  input.indexOf('*', index1 + 1);
  index3 =  input.indexOf('*', index2 + 1);
  index4 =  input.lastIndexOf('*');

  Name = input;
  Date = input;
  Enter = input;
  Exit = input;
  WT = input;

  Name.remove(index1);

  Date.remove(index2);
  Date.remove(0, index1 + 1);

  Enter.remove(index3);
  Enter.remove(0, index2 + 1);

  Exit.remove(index4);
  Exit.remove(0, index3 + 1);

  WT.remove(0, index4 + 1);
}

void Get_String()
{
  while (Serial.available()) {

    Final = Serial.readString(); // read the incoming data as string
    //Serial.println(Final);
  }
}
void setup() {

  Serial.begin(9600);
  WiFi.mode(WIFI_STA);
  Thingspeak.begin(client);
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);
}



void loop() {

  if (WiFi.status() != WL_CONNECTED) {
    //Serial.print("Attempting to connect to SSID: ");
    // Serial.println(ssid);
    while (WiFi.status() != WL_CONNECTED) {
      WiFi.begin(ssid, pass);  // Connect to WPA/WPA2 network. Change this line if using open or WEP network
      Serial.print("0");
      delay(5000);
    }
  }
  digitalWrite(LED_BUILTIN, LOW);
  //Serial.println("\nConnected.");

  Get_String();
  String_Analyze(Final);
  if (!Final.equals(""))
  {
    Thingspeak.setField(1, Date);
    Thingspeak.setField(2, Name);
    Thingspeak.setField(3, Enter);
    Thingspeak.setField(4, Exit);
    Thingspeak.setField(5, WT);

    int x = Thingspeak.writeFields(myChannelNumber, myWriteAPIKey);
    if (x == 200) {
      delay(100);
      Serial.print("1");
    }
    else {
      delay(100);
      Serial.print("0");
    }

    delay(17000);
    Final = "";
  }

Credits

ElectroPeak

ElectroPeak

55 projects • 444 followers
At ElectroPeak we want to teach you to enjoy electronics more. We offer Top-notch guides and worry-free shopping experience.

Comments