Am a doing a college project Rfid tracker using Nodemcu v3. i am using 2 rfid readers and 2 nodemcu. I want the datas of the 2 rfid to be a posted on a single web server. each nodemcu creates an ip address where my data transfered on the server. each data is on a new ip address. i want the data of the 2 nodemcu to be posted on one server. is that possible . here is my code
1st rfid with nodemcu code
#include <MFRC522.h> //RFID Library
#include <SPI.h> // Serial Protocol Interface
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h> // Sets up a server
#define SS_PIN 15 // Slave Select pin (D8)
#define RST_PIN 5 // Reset Pin (D1)
MFRC522 mfrc522(SS_PIN, RST_PIN);
ESP8266WebServer server;
char* ssid = "Oppo a57"; // Mobile Hotspot name
char* password = "12345678@"; // Connect to the Wifi network
void setup()
{
Serial.begin(9600); // Initiate a serial communication
SPI.begin(); // Initiate SPI bus
mfrc522.PCD_Init(); // Initiate MFRC522
Serial.println("Approximate your card to the reader..."); // Prints on new line
Serial.println();
WiFi.begin(ssid,password);
while(WiFi.status()!=WL_CONNECTED) // Wait for connection
{
Serial.print(".");
delay(100);
}
Serial.println("");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP()); //Print the local IP Address
server.begin(); // Start the server
}
void loop()
{ server.handleClient(); //Handle incoming https requests
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
Serial.print("UID tag :");
String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++) // mfrc522.uid.size --> PRINTS UID SIZE
{
Serial.print(mfrc522.uid.uidByte < 0x10 ? " 0" : " "); // mfrc522.uid.uidByte --> PRINTS BYTES OF UID
_ Serial.print(mfrc522.uid.uidByte*, HEX);
content.concat(String(mfrc522.uid.uidByte < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte, HEX));
}
Serial.println();
//Serial.print("Message : ");*_
* content.toUpperCase();*
if (content.substring(1) == "E0 5D 12 A4" ) // Compares the string
{
* Serial.println("Dr.Ayesha entered in Room 1");*
* server.on("/",{server.send(200,"text/plain","Dr.Ayesha entered in Room 1");}); // Posted on the web server*
}
/*else if ( content.substring(1) == "3E 0E AB 59" )
* {*
* Serial.println("Dr.Santosh entered in Room 1" );*
* server.on("/",{server.send(200,"text/plain","Dr.Zenul entered in Room 1");});*
_ }/
else if ( content.substring(1) == "50 DD 20 A4" )
{
Serial.println("Dr.Zenul entered in Room 1" );
server.on("/",{server.send(200,"text/plain"," Dr.Zenul entered in Room 1");});
}*_
else
* {*
* Serial.println("Invalid");*
* }*
delay(3000);
}
2nd rfid with nodemcu code
#include <MFRC522.h> //RFID Library
#include <SPI.h> // Serial Protocol Interface
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h> // Sets up a server
#define SS_PIN 15 // Slave Select pin (D8)
#define RST_PIN 5 // Reset Pin (D1)
MFRC522 mfrc522(SS_PIN, RST_PIN);
ESP8266WebServer server;
char* ssid = "Oppo a57"; // Mobile Hotspot name
char* password = "12345678@"; // Connect to the Wifi network
void setup()
{
* Serial.begin(9600); // Initiate a serial communication*
* SPI.begin(); // Initiate SPI bus*
* mfrc522.PCD_Init(); // Initiate MFRC522*
* Serial.println("Approximate your card to the reader..."); // Prints on new line*
* Serial.println();*
* WiFi.begin(ssid,password);*
* while(WiFi.status()!=WL_CONNECTED) // Wait for connection*
* {*
* Serial.print(".");*
* delay(100);*
* }*
* Serial.println("");*
* Serial.print("IP Address: ");*
* Serial.println(WiFi.localIP()); //Print the local IP Address*
server.begin(); // Start the server
}
void loop()
{ server.handleClient(); //Handle incoming https requests
* if ( ! mfrc522.PICC_IsNewCardPresent())
_ {
return;
}
// Select one of the cards*
* if ( ! mfrc522.PICC_ReadCardSerial())*
* {
return;
}
Serial.print("UID tag :");
String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++) // mfrc522.uid.size --> PRINTS UID SIZE*
* {
Serial.print(mfrc522.uid.uidByte < 0x10 ? " 0" : " "); // mfrc522.uid.uidByte --> PRINTS BYTES OF UID
Serial.print(mfrc522.uid.uidByte, HEX);
content.concat(String(mfrc522.uid.uidByte < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte, HEX));
}
Serial.println();
//Serial.print("Message : ");*_
* content.toUpperCase();*
if (content.substring(1) == "E0 5D 12 A4" ) // Compares the string
{
* Serial.println("Dr.Ayesha entered in Room 2");*
* server.on("/",{server.send(200,"text/plain"," Dr.Ayesha entered in Room 2");}); // Posted on the web server*
}
/*else if ( content.substring(1) == "3E 0E AB 59" )
* {*
* Serial.println("Operation Theatre" );*
* server.on("/",{server.send(200,"text/plain","Operation Theatre");});*
_ }/
else if ( content.substring(1) == "50 DD 20 A4" )
{
Serial.println("Dr.Zenul entered in Room 1" );
server.on("/",{server.send(200,"text/plain","Dr.Zenul entered in Room 1");});
}*_
else
* {*
* Serial.println("Invalid ");*
* }*
delay(3000);
}
Please help me out by getting both the datas on a server