Why cant I pint to my webserver?
Posted: Mon Mar 13, 2017 9:21 am
#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.
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.