Hackster is hosting Hackster Holidays, Finale: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Tuesday!Stream Hackster Holidays, Finale on Tuesday!
anaferraz
Published © GPL3+

Automatic Attendance and Classroom Environmental Monitoring

This project simulates a Smart Classroom automatic attendance using RFID module and classroom environmental monitoring using DHT11.

BeginnerShowcase (no instructions)4,639
Automatic Attendance and Classroom Environmental Monitoring

Things used in this project

Hardware components

Arduino SIM Kit
Arduino SIM Kit
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
Sunfounder RFID-RC522
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Arduino IoT Cloud
Arduino IoT Cloud
Arduino IDE
Arduino IDE

Story

Read more

Schematics

Connections

Right Side Arduino

VCC (3.3V) – to power up RFID module and DHT11 sensor
GND – ground for RFID and DHT11 sensor
D8 – digital pin 8 – MOSI
D9 – digital pin 9 – SCK
D10 – digital pin 10 - MISO
D11 – digital pin 11 – SDA (SS)
D11 – digital pin 12 – SCL (RST)

Left Side Arduino

D2 – digital pin 2 – for DHT11 data

Code

Sketch

Arduino
#include <SPI.h>
#include <MFRC522.h>
#include "thingProperties.h"
#include "DHT.h"
#define DHTpin 2
#define DHTTYPE DHT11
#define SS_PIN 11
#define RST_PIN 12
MFRC522 mfrc522(SS_PIN, RST_PIN);

String student[6][2] = {
  {"90 17 34 37", "Ana" },
  {"D3 AA D0 45", "Paula" },
  {"52 98 81 39", "Renato" },
  {"71 E4 AE 20", "Luis" },
  {"E3 72 52 1A", "Angela" },
  {"91 39 45 20", "Maria" }
};
DHT dht(DHTpin, DHTTYPE);

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  delay(1500);
  
  // Defined in thingProperties.h
  initProperties();
  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
  delay(4);
  dht.begin();
}

void loop() {
  SPI.begin();
  mfrc522.PCD_Init();
  if ( mfrc522.PICC_IsNewCardPresent()) {
    if (mfrc522.PICC_ReadCardSerial()) {
      String content = "";
      byte letter;
      for (byte i = 0; i < mfrc522.uid.size; i++)
      {
        content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
        content.concat(String(mfrc522.uid.uidByte[i], HEX));
      }
      //Serial.println(content.substring(1));
      content.toUpperCase();
      for (int i = 0; i < 6; i++) {
        if (content.substring(1) == student[i][0])
        {
          msg_Attendance = "Attendance Recorded for Student: " + student[i][1] ;
        }
      }
      Serial.println(msg_Attendance);
    }
  }
  dht_sensor_getdata();
  delay(500);
  ArduinoCloud.update();
}
void onLedChange()  {
  // Add your code here to act upon Led change
  Serial.print("led: " + led);
  digitalWrite(LED_BUILTIN, led);
}

void dht_sensor_getdata()
{
  float hm = dht.readHumidity();
  Serial.print(F("Humidity "));
  Serial.println(hm);
  float temp = dht.readTemperature();
  Serial.print(F("Temperature "));
  Serial.println(temp);
  humidity = hm;
  temperature = temp;
  if (temp > 27) {
    msgTempHum = "Temperature = " + String (temperature) + "  Humidity = " + String(humidity) + " -> High ";
  }
  else if (temp < 20) {
    msgTempHum = "Temperature = " + String (temperature) + "  Humidity = " + String(humidity) + " -> Low ";
  }
  else {
    msgTempHum = "Temperature = " + String (temperature) + "  Humidity = " + String(humidity) + " -> All ok ";
  }
}

void onMsgChange()  {
}
void onMsgTempHumChange()  {
}
void onMsgAttendanceChange()  {
}

Readme

Plain text
:Author: anaferraz
:Date: 28/12/2021
:Revision: version#1
:License: Public Domain

= Project: {IoT Project for EEM602 }

Describe your project
Automatic Attendance and Classroom Monitoring (temperature and humidity)

== Step 1: Installation
Please describe the steps to install this project.
Using a MKR 1400 GSM, DHT11 and RFID-RC522

== Step 2: Assemble the circuit

Assemble the circuit following the diagram:
Port Number - Connected
2   - DHT11
8   - MOSI (RFID)
9   - SCK   (RFID)
10  - MISO  (RFID)
11  - SDA   (RFID)
12  - RESET (RFID)

== Step 3: Load the code

Upload the code contained in this sketch on to your board

=== Folder structure

....
 SIM_dec18a                 => Arduino sketch folder
  ├── SIM_dec18a.ino        => main Arduino file
  ├── thingProperties.h     => Arduino IoT Cloud properties
  ├── Secret                => Arduino IoT Cloud properties
  └── ReadMe.adoc           => this file
....

=== License
This project is released under no license.

=== BOM
Add the bill of the materials you need for this project.

|===
| ID | Part name            
| R1 | 10k Resistor               
| S1 | DHT11                       
| A1 | Arduino MKR 1400 GSM         
|===


=== Help
This document is written in the _AsciiDoc_ format, a markup language to describe documents.

== Secret

APN prepay.pelion
PIN 0000
USERNAME arduino
PASSWORD arduino

ThingsProperties

Arduino
// Code generated by Arduino IoT Cloud, DO NOT EDIT.

#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>


const char THING_ID[]      = "5f584b39-23dd-4bae-9947-a6ae872db8ff";

const char GPRS_APN[]      = SECRET_APN;
const char PINNUMBER[]     = SECRET_PIN;
const char GPRS_LOGIN[]    = SECRET_USERNAME;
const char GPRS_PASSWORD[] = SECRET_PASSWORD;

void onMsgAttendanceChange();
void onMsgTempHumChange();
void onLedChange();

String msg_Attendance;
String msgTempHum;
float humidity;
float temperature;
bool led;

void initProperties(){

  ArduinoCloud.setThingId(THING_ID);
  ArduinoCloud.addProperty(msg_Attendance, READWRITE, ON_CHANGE, onMsgAttendanceChange);
  ArduinoCloud.addProperty(msgTempHum, READWRITE, ON_CHANGE, onMsgTempHumChange, 5);
  ArduinoCloud.addProperty(humidity, READ, ON_CHANGE, NULL);
  ArduinoCloud.addProperty(temperature, READ, ON_CHANGE, NULL);
  ArduinoCloud.addProperty(led, READWRITE, ON_CHANGE, onLedChange);

}

GSMConnectionHandler ArduinoIoTPreferredConnection(PINNUMBER, GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD);

Credits

anaferraz
15 projects • 8 followers

Comments