So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By manny009
#63641 #include <ESP8266WiFi.h>

const char* ssid = "xxxxxxxxx";//type your ssid
const char* password = "xxxxxxx";//type your password

char val = 0; //variable to store the char read from the RFID button
/*Using RFID ID-12 to read unique character that is assigned to each RFID button or tag*/

WiFiServer server(80);

void setup() {
Serial.begin(9600); //connect to the serial port
delay(10);

// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");

// Start the server
server.begin();
Serial.println("Server started");

// Print the IP address
Serial.print("Use this URL to connect: ");
Serial.print("http://");
Serial.print(WiFi.localIP());
Serial.println("/");

}


void loop ()
{
//read the serial port
if(Serial.available()){
char val = Serial.read();//read from one char from the ID-12 and store it
Serial.print(val); //display the char in the serial monitor
}


// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}



// Return the response
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println(""); // do not forget this one
client.println("<!DOCTYPE HTML>");
client.println("<html>");

client.println("</br>");
client.print("RFID Tag No = ");
client.println(val);

delay(1);
Serial.println("Client disonnected");
Serial.println("");


}

Anyone tell me why I cannot post my serial data to the web server?
I am writing the serial data to char val then writing val to the web server but it will not display on the the browser.
User avatar
By manny009
#63672
martinayotte wrote:When you do "char val = Serial.read()" the "val" is a local variable and not using the global one.
Simply do "val = Serial.read()" instead ...



so I changes val to the global variable but still no printout on the web server.
Could it be that it is reading one bit at a time? thus not printing out the whole 13 characters of the RFID tag?



void loop ()
{
//read the serial port
if(Serial.available()){
val = Serial.read();//read from one char from the ID-12 and store it
Serial.print(val); //display the char in the serial monitor
}