Skip to content
Snippets Groups Projects
Commit 86bd9084 authored by Roman Antoschin's avatar Roman Antoschin
Browse files

Replace RFID_IoT_BS_final.ino

- HTTP 400 problem fixed
- Comments added
- Serial output revised
parent e07b7d19
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@
MFRC522 mfrc522(SS_PIN, RST_PIN); // initiate instance of MFRC522 for MF522-AN
const char server[] = "bs19-team34.bas.uni-koblenz.de"; // configure network credentials (server URL)
const char* ssid = "IoT2019"; // configure network credentials (SSID)
const char* ssid = "BS2019"; // configure network credentials (SSID)
const char* password = "IoTinBS2019"; // configure network credentials (PW)
WiFiClient client;
......@@ -20,14 +20,13 @@ void setup() { // initial general configuration
Serial.print("[CONNECTING TO WiFi with Network SSID: "); // inform about connection try
Serial.print(ssid); // print configured SSID
Serial.println("]");
Serial.print("] ");
WiFi.begin(ssid, password); // start connection process
while (WiFi.status() != WL_CONNECTED) { // try and indicate connecting
delay(1000);
Serial.print(".");
}
Serial.println("");
Serial.println("");
Serial.println("[CONNECTION SUCCESSFUL]"); // inform about successful connection
Serial.println("");
}
......@@ -47,36 +46,32 @@ void loop() { // start the continuous readiness of the system
mfrc522.PICC_HaltA(); // as soon as tag information has been completely read out and tag is still within range,
// put tag to sleep and wait for transmission
Serial.println("");
Serial.println("[CONNECTING TO SERVER...]"); // inform about connection try
Serial.println("");
if (client.connect(server, 80)) { // connect to configured server and execute code if successful
delay(1000);
Serial.println("[CONNECTION SUCCESSFUL]"); // inform about successful connection
Serial.println("");
Serial.println("[TRANSMITTING RFID DATA...]"); // inform about transmission try
Serial.println("");
String data = "action=append&tagId=" + tagID; // prepare RFID tag data to be transmitted
client.println("POST /api/rfid.php HTTP/1.1"); // transfer html content
client.print("Host: bs19-team34.bas.uni-koblenz.de\n");
client.print("Host: bs19-team34.bas.uni-koblenz.de\r\n");
client.println("User-Agent: ESP8266/1.0");
client.println("Connection: close");
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.print(data.length());
client.print("\n\n");
client.println();
client.println();
client.print(data); // tranfser prepared RFID tag data
delay(500);
Serial.println("[TRANSMISSION SUCCESSFUL]"); // inform about successful transmission
Serial.println("");
client.stop(); // close connection to server
// delay(500);
Serial.println("[CONNECTION TO SERVER CLOSED]"); // inform about successful connection closure
Serial.println("");
} else {
} else {
Serial.println("[ERROR: CONNECTION NOT SUCCESSFUL ! ! !]"); // inform about connection problem
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment