-
Notifications
You must be signed in to change notification settings - Fork 0
/
RFIDScanner.ino
74 lines (66 loc) · 1.87 KB
/
RFIDScanner.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
const char* ssid = "GEEK COMBAT";
const char* password = "gcdefault";
int count = 0; // count = 0
char input[12]; // character array of size 12
boolean flag = 0; // flag =0
bool read = false;
ESP8266WebServer server(80);
void setup()
{
Serial.begin(9600); // begin serial port with baud rate 9600bps
read = false;
WiFi.begin(ssid, password);
Serial.print("CONNETING TO WIFI");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("CONNECTED to WIFI");
Serial.println(WiFi.localIP());
server.on("/", handleRoot);
server.onNotFound(handleNotFound);
server.begin();
}
void loop()
{
if(Serial.available())
{
count = 0;
while(Serial.available() && count < 12) // Read 12 characters and store them in input array
{
input[count] = Serial.read();
count++;
Serial.print(input);
delay(20);
// Serial.println(count);
}
read = true;
Serial.println(input); // Print RFID tag number
}
else {
read = true;
}
server.handleClient();
}
void handleRoot() {
if(read)
server.send(200, "text/plain", input);
else
server.send(200,"text/plain", "NOTHING");
}
void handleNotFound(){
String message = "File Not Found\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET)?"GET":"POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i=0; i<server.args(); i++){
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
}