Components and supplies
Jumper wires (generic)
DHT11 Temperature & Humidity Sensor (4 pins)
RFID-RC522
Resistor 10k ohm
Arduino SIM Kit
Solderless Breadboard Full Size
Apps and platforms
Arduino IoT Cloud
Arduino IDE
Project description
Code
ThingsProperties
arduino
1// Code generated by Arduino IoT Cloud, DO NOT EDIT. 2 3#include <ArduinoIoTCloud.h> 4#include <Arduino_ConnectionHandler.h> 5 6 7const char THING_ID[] = "5f584b39-23dd-4bae-9947-a6ae872db8ff"; 8 9const char GPRS_APN[] = SECRET_APN; 10const char PINNUMBER[] = SECRET_PIN; 11const char GPRS_LOGIN[] = SECRET_USERNAME; 12const char GPRS_PASSWORD[] = SECRET_PASSWORD; 13 14void onMsgAttendanceChange(); 15void onMsgTempHumChange(); 16void onLedChange(); 17 18String msg_Attendance; 19String msgTempHum; 20float humidity; 21float temperature; 22bool led; 23 24void initProperties(){ 25 26 ArduinoCloud.setThingId(THING_ID); 27 ArduinoCloud.addProperty(msg_Attendance, READWRITE, ON_CHANGE, onMsgAttendanceChange); 28 ArduinoCloud.addProperty(msgTempHum, READWRITE, ON_CHANGE, onMsgTempHumChange, 5); 29 ArduinoCloud.addProperty(humidity, READ, ON_CHANGE, NULL); 30 ArduinoCloud.addProperty(temperature, READ, ON_CHANGE, NULL); 31 ArduinoCloud.addProperty(led, READWRITE, ON_CHANGE, onLedChange); 32 33} 34 35GSMConnectionHandler ArduinoIoTPreferredConnection(PINNUMBER, GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD);
Sketch
arduino
1#include <SPI.h> 2#include <MFRC522.h> 3#include "thingProperties.h" 4#include "DHT.h" 5#define DHTpin 2 6#define DHTTYPE DHT11 7#define SS_PIN 11 8#define RST_PIN 12 9MFRC522 mfrc522(SS_PIN, RST_PIN); 10 11String student[6][2] = { 12 {"90 17 34 37", "Ana" }, 13 {"D3 AA D0 45", "Paula" }, 14 {"52 98 81 39", "Renato" }, 15 {"71 E4 AE 20", "Luis" }, 16 {"E3 72 52 1A", "Angela" }, 17 {"91 39 45 20", "Maria" } 18}; 19DHT dht(DHTpin, DHTTYPE); 20 21void setup() { 22 // Initialize serial and wait for port to open: 23 Serial.begin(9600); 24 delay(1500); 25 26 // Defined in thingProperties.h 27 initProperties(); 28 // Connect to Arduino IoT Cloud 29 ArduinoCloud.begin(ArduinoIoTPreferredConnection); 30 setDebugMessageLevel(2); 31 ArduinoCloud.printDebugInfo(); 32 delay(4); 33 dht.begin(); 34} 35 36void loop() { 37 SPI.begin(); 38 mfrc522.PCD_Init(); 39 if ( mfrc522.PICC_IsNewCardPresent()) { 40 if (mfrc522.PICC_ReadCardSerial()) { 41 String content = ""; 42 byte letter; 43 for (byte i = 0; i < mfrc522.uid.size; i++) 44 { 45 content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ")); 46 content.concat(String(mfrc522.uid.uidByte[i], HEX)); 47 } 48 //Serial.println(content.substring(1)); 49 content.toUpperCase(); 50 for (int i = 0; i < 6; i++) { 51 if (content.substring(1) == student[i][0]) 52 { 53 msg_Attendance = "Attendance Recorded for Student: " + student[i][1] ; 54 } 55 } 56 Serial.println(msg_Attendance); 57 } 58 } 59 dht_sensor_getdata(); 60 delay(500); 61 ArduinoCloud.update(); 62} 63void onLedChange() { 64 // Add your code here to act upon Led change 65 Serial.print("led: " + led); 66 digitalWrite(LED_BUILTIN, led); 67} 68 69void dht_sensor_getdata() 70{ 71 float hm = dht.readHumidity(); 72 Serial.print(F("Humidity ")); 73 Serial.println(hm); 74 float temp = dht.readTemperature(); 75 Serial.print(F("Temperature ")); 76 Serial.println(temp); 77 humidity = hm; 78 temperature = temp; 79 if (temp > 27) { 80 msgTempHum = "Temperature = " + String (temperature) + " Humidity = " + String(humidity) + " -> High "; 81 } 82 else if (temp < 20) { 83 msgTempHum = "Temperature = " + String (temperature) + " Humidity = " + String(humidity) + " -> Low "; 84 } 85 else { 86 msgTempHum = "Temperature = " + String (temperature) + " Humidity = " + String(humidity) + " -> All ok "; 87 } 88} 89 90void onMsgChange() { 91} 92void onMsgTempHumChange() { 93} 94void onMsgAttendanceChange() { 95}
Readme
text
1:Author: anaferraz 2:Date: 28/12/2021 3:Revision: version#1 4:License: Public Domain 5 6= Project: {IoT Project for EEM602 } 7 8Describe your project 9Automatic Attendance and Classroom Monitoring (temperature and humidity) 10 11== Step 1: Installation 12Please describe the steps to install this project. 13Using a MKR 1400 GSM, DHT11 and RFID-RC522 14 15== Step 2: Assemble the circuit 16 17Assemble the circuit following the diagram: 18Port Number - Connected 192 - DHT11 208 - MOSI (RFID) 219 - SCK (RFID) 2210 - MISO (RFID) 2311 - SDA (RFID) 2412 - RESET (RFID) 25 26== Step 3: Load the code 27 28Upload the code contained in this sketch on to your board 29 30=== Folder structure 31 32.... 33 SIM_dec18a => Arduino sketch folder 34 ├── SIM_dec18a.ino => main Arduino file 35 ├── thingProperties.h => Arduino IoT Cloud properties 36 ├── Secret => Arduino IoT Cloud properties 37 └── ReadMe.adoc => this file 38.... 39 40=== License 41This project is released under no license. 42 43=== BOM 44Add the bill of the materials you need for this project. 45 46|=== 47| ID | Part name 48| R1 | 10k Resistor 49| S1 | DHT11 50| A1 | Arduino MKR 1400 GSM 51|=== 52 53 54=== Help 55This document is written in the _AsciiDoc_ format, a markup language to describe documents. 56 57== Secret 58 59APN prepay.pelion 60PIN 0000 61USERNAME arduino 62PASSWORD arduino
ThingsProperties
arduino
1// Code generated by Arduino IoT Cloud, DO NOT EDIT. 2 3#include <ArduinoIoTCloud.h> 4#include 5 <Arduino_ConnectionHandler.h> 6 7 8const char THING_ID[] = "5f584b39-23dd-4bae-9947-a6ae872db8ff"; 9 10const 11 char GPRS_APN[] = SECRET_APN; 12const char PINNUMBER[] = SECRET_PIN; 13const 14 char GPRS_LOGIN[] = SECRET_USERNAME; 15const char GPRS_PASSWORD[] = SECRET_PASSWORD; 16 17void 18 onMsgAttendanceChange(); 19void onMsgTempHumChange(); 20void onLedChange(); 21 22String 23 msg_Attendance; 24String msgTempHum; 25float humidity; 26float temperature; 27bool 28 led; 29 30void initProperties(){ 31 32 ArduinoCloud.setThingId(THING_ID); 33 34 ArduinoCloud.addProperty(msg_Attendance, READWRITE, ON_CHANGE, onMsgAttendanceChange); 35 36 ArduinoCloud.addProperty(msgTempHum, READWRITE, ON_CHANGE, onMsgTempHumChange, 37 5); 38 ArduinoCloud.addProperty(humidity, READ, ON_CHANGE, NULL); 39 ArduinoCloud.addProperty(temperature, 40 READ, ON_CHANGE, NULL); 41 ArduinoCloud.addProperty(led, READWRITE, ON_CHANGE, 42 onLedChange); 43 44} 45 46GSMConnectionHandler ArduinoIoTPreferredConnection(PINNUMBER, 47 GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD);
Sketch
arduino
1#include <SPI.h> 2#include <MFRC522.h> 3#include "thingProperties.h" 4#include 5 "DHT.h" 6#define DHTpin 2 7#define DHTTYPE DHT11 8#define SS_PIN 11 9#define 10 RST_PIN 12 11MFRC522 mfrc522(SS_PIN, RST_PIN); 12 13String student[6][2] = { 14 15 {"90 17 34 37", "Ana" }, 16 {"D3 AA D0 45", "Paula" }, 17 {"52 98 18 81 39", "Renato" }, 19 {"71 E4 AE 20", "Luis" }, 20 {"E3 72 52 1A", 21 "Angela" }, 22 {"91 39 45 20", "Maria" } 23}; 24DHT dht(DHTpin, DHTTYPE); 25 26void 27 setup() { 28 // Initialize serial and wait for port to open: 29 Serial.begin(9600); 30 31 delay(1500); 32 33 // Defined in thingProperties.h 34 initProperties(); 35 36 // Connect to Arduino IoT Cloud 37 ArduinoCloud.begin(ArduinoIoTPreferredConnection); 38 39 setDebugMessageLevel(2); 40 ArduinoCloud.printDebugInfo(); 41 delay(4); 42 43 dht.begin(); 44} 45 46void loop() { 47 SPI.begin(); 48 mfrc522.PCD_Init(); 49 50 if ( mfrc522.PICC_IsNewCardPresent()) { 51 if (mfrc522.PICC_ReadCardSerial()) 52 { 53 String content = ""; 54 byte letter; 55 for (byte i = 0; 56 i < mfrc522.uid.size; i++) 57 { 58 content.concat(String(mfrc522.uid.uidByte[i] 59 < 0x10 ? " 0" : " ")); 60 content.concat(String(mfrc522.uid.uidByte[i], 61 HEX)); 62 } 63 //Serial.println(content.substring(1)); 64 content.toUpperCase(); 65 66 for (int i = 0; i < 6; i++) { 67 if (content.substring(1) == student[i][0]) 68 69 { 70 msg_Attendance = "Attendance Recorded for Student: " + 71 student[i][1] ; 72 } 73 } 74 Serial.println(msg_Attendance); 75 76 } 77 } 78 dht_sensor_getdata(); 79 delay(500); 80 ArduinoCloud.update(); 81} 82void 83 onLedChange() { 84 // Add your code here to act upon Led change 85 Serial.print("led: 86 " + led); 87 digitalWrite(LED_BUILTIN, led); 88} 89 90void dht_sensor_getdata() 91{ 92 93 float hm = dht.readHumidity(); 94 Serial.print(F("Humidity ")); 95 Serial.println(hm); 96 97 float temp = dht.readTemperature(); 98 Serial.print(F("Temperature ")); 99 100 Serial.println(temp); 101 humidity = hm; 102 temperature = temp; 103 if (temp 104 > 27) { 105 msgTempHum = "Temperature = " + String (temperature) + " Humidity 106 = " + String(humidity) + " -> High "; 107 } 108 else if (temp < 20) { 109 msgTempHum 110 = "Temperature = " + String (temperature) + " Humidity = " + String(humidity) 111 + " -> Low "; 112 } 113 else { 114 msgTempHum = "Temperature = " + String 115 (temperature) + " Humidity = " + String(humidity) + " -> All ok "; 116 } 117} 118 119void 120 onMsgChange() { 121} 122void onMsgTempHumChange() { 123} 124void onMsgAttendanceChange() 125 { 126}
Readme
text
1:Author: anaferraz 2:Date: 28/12/2021 3:Revision: version#1 4:License: 5 Public Domain 6 7= Project: {IoT Project for EEM602 } 8 9Describe your project 10Automatic 11 Attendance and Classroom Monitoring (temperature and humidity) 12 13== Step 1: 14 Installation 15Please describe the steps to install this project. 16Using a MKR 17 1400 GSM, DHT11 and RFID-RC522 18 19== Step 2: Assemble the circuit 20 21Assemble 22 the circuit following the diagram: 23Port Number - Connected 242 - DHT11 258 26 - MOSI (RFID) 279 - SCK (RFID) 2810 - MISO (RFID) 2911 - SDA (RFID) 3012 31 - RESET (RFID) 32 33== Step 3: Load the code 34 35Upload the code contained 36 in this sketch on to your board 37 38=== Folder structure 39 40.... 41 SIM_dec18a 42 => Arduino sketch folder 43 ├── SIM_dec18a.ino => main 44 Arduino file 45 ├── thingProperties.h => Arduino IoT Cloud properties 46 47 ├── Secret => Arduino IoT Cloud properties 48 └── ReadMe.adoc 49 => this file 50.... 51 52=== License 53This project is released under 54 no license. 55 56=== BOM 57Add the bill of the materials you need for this project. 58 59|=== 60| 61 ID | Part name 62| R1 | 10k Resistor 63| S1 | DHT11 64 65| A1 | Arduino MKR 1400 GSM 66|=== 67 68 69=== 70 Help 71This document is written in the _AsciiDoc_ format, a markup language to 72 describe documents. 73 74== Secret 75 76APN prepay.pelion 77PIN 0000 78USERNAME 79 arduino 80PASSWORD arduino
Downloadable files
Left Side Arduino
D2 – digital pin 2 – for DHT11 data
Left Side Arduino
Connections
Connections
Left Side Arduino
D2 – digital pin 2 – for DHT11 data
Left Side Arduino
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)
Right Side Arduino
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)
Right Side Arduino
Connections
Connections
Comments
Only logged in users can leave comments
Automatic Attendance and Classroom Environmental Monitoring | Arduino Project Hub