Attendance Control with Arduino and Factorial through Make

Attendance Control with Arduino and Factorial through Make

:robot: Lee este artículo en español :es: en LinkedIn:
Del Papel a la Automatización: Control de Asistencia con Arduino y Factorial a través de Make

Greetings, automation enthusiasts! This article will take you on a fascinating journey from paper records to full automation of attendance management.

Get ready to discover how the combination of Arduino, Factorial, and the powerful process automation platform Make can transform your approach to efficiency.

History

Imagine an environment where paper records and manual tasks dominate attendance management. Does it look familiar to you? In a world moving toward automation, these practices may become obsolete.

The need to optimize time and minimize errors leads us to explore new possibilities. This is where the idea of automating with Make comes into play.
Process automation is an option and a necessity to streamline daily operations. By embracing this trend, you will journey towards hassle-free and more efficient attendance management.

:dart: The Idea

The key to achieving optimized attendance management lies in merging the physical world with the online world, combining the engineering of Arduino with the effectiveness of the Factorial HR platform; all orchestrated through the Make automation platform.

Here are five essential steps to turn this idea into reality:

  • System Design: Visualize the ideal workflow and how the physical and virtual worlds should be integrated.
  • Hardware selection: Choose the physical device that fits your needs and make sure it’s compatible with the idea to be carried out. In this case, Internet access and reading RFID/NFC cards must be considered.
  • Settings in Factorial: Ensure you have all the necessary data on the platform for perfect synchronization. For this example, we require employees to have their NFC card code registered in the “Employee Company Identifier” field.
  • Arduino and Factorial Connection: We will use Make to establish fluid communication between both, and the means of communication will be a webhook. Upon reading the employee’s NFC card, the Arduino board will send the read data to Make via a call to the webhook.
  • Testing and tuning: Conduct extensive testing to ensure automation flows smoothly. Continuous optimization is vital.

Remember, process automation saves time, boosts accuracy, and reduces errors.

:artificial_satellite: Technological Stack: To Transform your Attendance Control :hammer_and_wrench:

Before we dive into the automated process, let’s learn about the key tools and services:

  • Make: Our favorite platform for process automation. https://www.make.com/en
  • Factorial: The excellent human resources management software for small and medium-sized businesses. https://factorialhr.es/
  • Arduino: The physical device that allows us to read RFID/NFC cards; the selected board is an Arduino nano 33 Iot and the MFRC522 accessory.
  • Google Gmail: To send system notifications.
  • Slack: To send system notifications.

:construction: Construction Process

Let’s get into the real action. Imagine the hum of the printer effortlessly generating attendance reports.

To achieve this, follow these practical steps:

  • Factorial Settings: Adjust settings to ensure a perfect connection. Create an API key you will need to Make and ensure each employee has the RFID card code registered in their profile.

  • Process in Make: Go to make.com, create an account, then a scenario that begins with a webhook and performs the different actions on the Factorial platform, for example, searching for the employee and recording their attendance.

  • Arduino’s assembly and coding: Assemble the circuit on a breadboard and implement the code for reading the RFID card and communication between the physical Arduino device and Factorial via a call to the Webhook previously created in Make.

Patience is key in this process. Every small adjustment brings us closer to hassle-free attendance management.

:mortar_board: Detailed Process: How to Build a System with Arduino, FactorialHR, and Make

Here, I detail each meticulous step of the process I designed to optimize efficiency in the Human Resources department:

  • The Arduino board scans the RFID/NFC card using the MFRC522 board.
  • The real value is sent to Make by calling a webhook using the Arduino’s Wi-Fi connection.
  • Upon receiving the call, Make runs the scenario, an automated process.
  • The first action is to read the complete list of employees from Factorial and search for the employee by filtering by the “Employee’s company identifier” field, which must match the value read from the RFID card received in the webhook.
  • Security is notified via Slack and email if the employee is not found, reporting an invalid login attempt.
  • If the employee exists but is fired, the security and Human Resources area is notified through Slack and email, indicating an invalid login attempt.
  • If you are confirmed to be a valid employee, your contract data is obtained to validate working days.
  • If registration occurs on a day not permitted according to the contract, the Human Resources area is notified via Slack and email, indicating an invalid time registration attempt.
  • If the employee and the day are valid, their entry or exit is recorded in Factorial.
  • In the case of an admission, if it is made 30 minutes after the allowed time, its lateness is recorded internally.
  • If three or more tardies accumulate in the month, the manager is identified in Factorial.
  • The user is searched for in the manager’s Slack and notified about the absence incurred by the employee.
  • In addition, the Human Resources area is notified of the misconduct committed by the employee.

:brain: Arduino source code

#include <SPI.h>
#include <WiFiNINA.h>
#include <ArduinoHttpClient.h>
#include "MFRC522.h"
#include <ArduinoJson.hpp>
#include <ArduinoJson.h>

#define Buzzer 2

// Leds
#define LED1 4  // Verde
#define LED2 3  // rojo
byte ledVerde = 0;
byte ledRojo = 0;
// END Leds

// RFID
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);
// END RFID

// MAKE
const char serverName[] = "hook.us1.make.com";
String pathWebhook = "/o8jfs38y61g2cp6wu1h51kxr6dtzxq11";
int port = 443;
DynamicJsonDocument dataRequest(1024);
// END MAKE

// WIFI
char ssid[] = "NOMBRE_DE_TU_RED";
char pass[] = "CONTRASEÑA_DE_TU_RED";
int keyIndex = 0;
int status = WL_IDLE_STATUS;
WiFiSSLClient wifi;
HttpClient client = HttpClient(wifi, serverName, port);
// END WIFI

void setup() {
  Serial.begin(9600);  // Inicializar la comunicación serie

  // Verificar módulo WiFi:
  if (WiFi.status() == WL_NO_MODULE) {
    Serial.println("¡Falló la comunicación con el módulo WiFi!");
    // no continuar
    while (true)
      ;
  }

  // Intentar conectarse a la red WiFi:
  while (status != WL_CONNECTED) {
    Serial.print("Intentando conectarse a la red");
    Serial.println(ssid);
    status = WiFi.begin(ssid, pass);
    // Esperar 10 segundos para la conexión:
    delay(10000);
  }

  printWifiStatus();

  // Inicializar el módulo RFID
  SPI.begin();
  mfrc522.PCD_Init();
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(Buzzer, OUTPUT);
  delay(4);
  Serial.println(F("Esperando por tarjetas de empleados"));
}

void loop() {
  if (!mfrc522.PICC_IsNewCardPresent()) {
    return;
  }
  if (!mfrc522.PICC_ReadCardSerial()) {
    return;
  }

  Serial.print("UID tag (código del empleado):");
  tone(Buzzer, 700);
  delay(200);
  noTone(Buzzer);
  String ID = "";
  for (byte i = 0; i < mfrc522.uid.size; i++) {
    ID.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
    ID.concat(String(mfrc522.uid.uidByte[i], HEX));
    delay(300);
  }
  Serial.println();
  ID.toUpperCase();

  callWebhook(ID);
  delay(1000);
}

void callWebhook(String user) {
  dataRequest["usuario"] = user;
  String json;
  serializeJson(dataRequest, json);

  Serial.println("making POST request");
  String contentType = "application/json";
  client.post(pathWebhook, contentType, json);
  String response = client.responseBody();
  Serial.print("Respuesta: ");
  Serial.println(response);

  StaticJsonDocument<300> doc;
  DeserializationError error = deserializeJson(doc, response);

  if (doc["estado"] == 1) {  // Led verde VALIDO
    digitalWrite(LED1, HIGH);
    digitalWrite(LED2, LOW);
    ledVerde = 1;
    ledRojo = 0;
  } else {  // Led rojo No VALIDO
    digitalWrite(LED1, LOW);
    digitalWrite(LED2, HIGH);
    ledVerde = 0;
    ledRojo = 1;
  }
}


void printWifiStatus() {
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // Imprimir la dirección IP del wifi:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);
} 

Conclusion

Congratulations! You’ve walked the path from paper records to full automation.
Now, every minute saved in attendance management becomes an investment in overall efficiency.

The combination of Arduino, Factorial and Make is an unstoppable trio that frees you from the chains of manual tasks.

In short, automating with Make is not just an option; It is the key to simplifying routines and boosting productivity.

Explore new ways to integrate automation with Make.com into your daily life and optimize your path to efficiency.
Until next time, efficiency followers!

3 Likes

Heya @Francisco_Fontes :blob_wave:

I’m reading through the community after the holidays and what do I find? Another one of your mind-blowing tutorials! :clap:

Thank you so much for continuously keeping us inspired with your undying resource of cool automation stories. I genuinely cannot thank you enough for sharing your brilliance with the community :raised_hands:

2 Likes