ESP8266 Serial and Client print concussion.

Hi guys.

Im currently programming a device to send a command via serial to an Arduino when it receives the corresponding request form the web client.

I originally used GPIO pins as triggers for the arduino but it’s come to the point when i want to send ricther communication between the devices (alarm time, conformations ect).

I am using serial.print and client.print but every time a request is sent from the browser ("/BLIND=OPEN") it is sending “GET /BLIND=OPEN HTTP/1.1” to the serial monitor along with what i requested via serial.print.

I have tried changing the baud rate and the code but i can’t seem to stop it happening :angry:

my code is:

#include <ESP8266WiFi.h>

const char* ssid = “…”;
const char* password = “…”;

int ledStatus = 15;
int iPosSet = 0;
int iLoop = 0;
int Config = 1;
int request = 0;
WiFiServer server(80);

void setup() {
Serial.begin(115200);
pinMode(ledStatus, OUTPUT);
digitalWrite(ledStatus, LOW);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {
digitalWrite(ledStatus, HIGH);
delay(1000);
digitalWrite(ledStatus, LOW);
delay(1000);
}
server.begin();
}
void loop() {

WiFiClient client = server.available();
if (!client) {
return;
}
while(!client.available()){
delay(1);
}
String request = client.readStringUntil(’\r’);
Serial.println(request);
client.flush();

if (request.indexOf("/BLIND=OPEN") != -1&& iLoop == 1) {
Serial.println(‘2’);
}
if (request.indexOf("/BLIND=CLOSE") != -1&& iLoop == 1) {
Serial.println(‘3’);
}
client.println(“HTTP/1.1 200 OK”);
client.println(“Content-Type: text/html”);
client.println(""); // do not forget this one
client.println("");
client.println("");

client.print(“Blind Controls”);

client.println("

“);
client.println(”<a href="/BLIND=OPEN"">Open Blind “);
client.println(”<a href="/BLIND=CLOSE"">Close Blind
“);
client.println(”");

delay(1);

iLoop = 1;

}

That's the request. Changing the baud rate is not going to change that. If you want only part of the request then you need to parse it in your code and only print the desired portion of the request to Serial.

pert:
That's the request. Changing the baud rate is not going to change that. If you want only part of the request then you need to parse it in your code and only print the desired portion of the request to Serial.

Agreed^

I had similar requirements with another application and had to parse out the data i needed.

Your program is doing exactly what you told it to. Suggest you comment out the line that is printing the whole request (it was probably there for debugging)

while(!client.available()){
    delay(1);
  }
    String request = client.readStringUntil('\r');
      // Serial.println(request); <--------- comment out this line
      client.flush();
 
  if (request.indexOf("/BLIND=OPEN") != -1&& iLoop == 1)  {
    Serial.println('2');
  }
  if (request.indexOf("/BLIND=CLOSE") != -1&& iLoop == 1) {
   Serial.println('3');
  }