I am using this code to display the LF RFID's tag into the serial monitor and the same has to be sent to my database. While reading the Tags its displaying something like this on the serial monitor
Attempting to connect to SSID: Reliance Wi-Pod-2E7
Connected to XAMPP:
0006110954
Ÿÿ 0006140110
ÿÿ
Can someone help me to get only the tag ID's?
#include <SPI.h>
#include <WiFi.h>
#include <Client.h>
#include<SoftwareSerial.h>
SoftwareSerial RFID(9,10);
int i;
int rfid;
char ssid[] = "Reliance Wi-Pod-2E7";
char pass[] = "A3D2D2E7";
int status = WL_IDLE_STATUS;
char newtag[14];// = {2,49,51,48,48,57,69,66,48,51,57,48,52,3};
String fielddata ="newtag=";
String updateserver="";
IPAddress server(101,63,153,136);
//IPAddress server(184, 106, 153, 149);
//char server[] = "localhost/te";
//IPAddress ip(192,168,1,4);
WiFiClient client;
// server address:
//unsigned long lastConnectionTime = 0; // last time you connected to the server, in milliseconds
//boolean lastConnected = false; // state of the connection last time through the main loop
//const unsigned long postingInterval = 5*1000; // delay between updates, in milliseconds
//String writeAPIKey = "6ZBMK0KXQTVS7FJW"; //ur thingspeak api????
void setup()
{
Serial.begin(9600);
RFID.begin(9600);
while ( status != WL_CONNECTED)
{
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid,pass);
// wait 10 seconds for connection:
delay(10000);
}
// you're connected now, so print out the status:
}
void loop()
{
//while(1)
{
if (client.connect(server, 80))
{
Serial.print("Connected to XAMPP:");
Serial.println();
while(1)
{
if (RFID.available() > 0)
{
//Serial.println("reading rfid tags");
delay(100);
for (i=0; i < 14; i++)
{
rfid = RFID.read();
newtag[i]=rfid;
}
// RFID.flush();
//Serial.print("rfid tag no:");
Serial.print(newtag);
//Serial.println("Sending to Server...");
updateserver = fielddata +String(newtag) ;
client.println("POST /lf/add.php HTTP/1.1");
client.println("Host: 101.63.153.136"); // SERVER ADDRESS HERE TOO
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.print(updateserver.length());
client.print("\n\n");
client.print(updateserver);
}
}
}
else
{
Serial.println("Cannot connect to Server");
}
}
}