Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
3
3CB105-SimonNutsey-IoT
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
simon.nutsey
3CB105-SimonNutsey-IoT
Commits
1f909f1e
Commit
1f909f1e
authored
Jan 03, 2021
by
simon.nutsey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parent
0c89118b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
0 deletions
+91
-0
RFIDScannerAminu
RFIDScannerAminu
+91
-0
No files found.
RFIDScannerAminu
0 → 100644
View file @
1f909f1e
#include <ESP8266WiFi.h>
#include <SPI.h>
#include <MFRC522.h>
#include "ThingSpeak.h";
constexpr uint8_t RST_PIN = D3; //reset pin set
constexpr uint8_t SS_PIN = D4; //slave pin set
MFRC522 rfid(SS_PIN, RST_PIN);
MFRC522::MIFARE_Key key;
const char* ssid = "VM8257564"; //wifi ssid
const char* pass = "Qx6nqdyv4hhy"; //wifi pass
int connectledPin = D8; //Blue led when connected to internet
int unconnectledPin = D1; //Red let when not connected to internet
WiFiClient client;
const unsigned long channel_id = 1223547; //Thing Speak channel id
const char write_api_key[] = "7JWC5PW2TW4YQ10L"; //Thing Speak write api key
String tag; //define "Tag" as a string
void setup()
{
pinMode(connectledPin,OUTPUT); //Set both LEDs to output
pinMode(unconnectledPin, OUTPUT);
digitalWrite(connectledPin,LOW);
digitalWrite(unconnectledPin, HIGH); //When starting Blue LED off Red LED on
Serial.begin(9600);
delay(10);
Serial.println("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
Serial.println();
Serial.println("Connecting");
SPI.begin(); // Init SPI bus // Attempt to connect to the wifi
rfid.PCD_Init(); // Init MFRC522
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
digitalWrite(connectledPin, HIGH);
digitalWrite(unconnectledPin, LOW);
Serial.println("");
Serial.println("You are now connected to ");
Serial.println(ssid);
ThingSpeak.begin(client);
}
void loop() {
if ( ! rfid.PICC_IsNewCardPresent())
return;
if (rfid.PICC_ReadCardSerial()) { //when a card is detected print its ID value
for (byte i = 0; i < 4; i++) {
tag += rfid.uid.uidByte[i];
}
Serial.println(tag);
if (tag =="160248110163") {
Serial.println("Access Granted"); //If statment. If ID scanned = 160248110163 then write to thing speak. More ids can be added should the need arise
ThingSpeak.setField(3, String(tag));
ThingSpeak.writeFields(channel_id, write_api_key);
}
tag = "";
rfid.PICC_HaltA();
rfid.PCD_StopCrypto1();
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment