-2

hello i am trying to send data to lcd screen ,but they arrive as GET/ DATO /HTTP 1.1

I ONLY NEED TO ARRIVE DATA AND DELETE (GET/ /HTTP 1.1)

I am used to the esp8266 by wifi in access point mode the program works well

request is the data that arrives at the arduino terminal

  }
 if (request.indexOf("") != -1)  { //////SHIPPING PART
  // enviar
  lcd.init();
   lcd.backlight();
   lcd.setCursor(0,0);
   lcd.print(request);

    delay(1000);
 
   }

Send Text

I just want to send text so this is what I hope to ahieve

SEND DATO

DELETE GET/ /HTTP 1.1

#include <ESP8266WiFi.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>



   
const char *ssid_AP = "LCDAP";
const char *Password_AP = "12345678";

WiFiServer server(80);

LiquidCrystal_I2C lcd(0x27,2,16); 

void setup(){
  lcd.init();                      // initialize the lcd 
  lcd.backlight();
  lcd.setCursor(2,0);
  lcd.print("LCD Ready");
  Serial.begin(115200);
  delay(10);


  delay(1000);
  WiFi.mode(WIFI_AP);
  WiFi.softAP(ssid_AP,Password_AP);

  Serial.println("WiFi conected");
  Serial.println();
  WiFi.printDiag(Serial);
  Serial.print("AP direccion IP: ");
  Serial.println(WiFi.softAPIP());

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

void loop() {
  // Check if a client has connected
  WiFiClient client = server.available();
  if (!client) {
    return;
  }
 
  // Wait until the client sends some data
  Serial.println("new client");
  while(!client.available()){
    delay(1);
  }
 
  // Read the first line of the\r %d\n
  String request = client.readStringUntil('\n');
  Serial.println(request);
  client.flush();

 

if (request.indexOf("/LCDBORRAR") != -1)  {
   lcd.clear();
    delay(1000);
 
  }
 if (request.indexOf("") != -1)  { ////// send text
  // enviar
  lcd.init();
   lcd.backlight();
   lcd.setCursor(0,0);
   lcd.print(request);

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

   }
  • If you're going to use HTTP then you need to actually use the HTTP protocol. `WiFiServer` is a raw TCP server. You need to either implement the HTTP protocol yourself in that case, or better yet, use an HTTP server library. There are lots of tutorials online showing how to do this. – romkey Apr 02 '22 at 23:23
  • 64 / 5.000 Resultados de traducción thank you but I already took this path, I'm close to the problem.... – VLAD D ELECTRONICS Apr 03 '22 at 00:01
  • How exactly is your HTTP request that you received looks like(what your `Serial.println(request);` looks like)? You need to have better understanding of [HTTP messages](https://developer.mozilla.org/en-US/docs/Web/HTTP/Messages). Your code doesn't do what you think is doing. – hcheung Apr 03 '22 at 23:59
  • It's simple, I don't need a web page for what I need there are examples like this and I see that it is possible https://www.youtube.com/watch?v=U48Jc6FMwPU but I need it Access Point (AP) but I didn't find any example. that is not so complex my cell application sends the data but it arrives as (GET/ /HTTP 1.1) example (GET/hello /HTTP 1.1) (GET/cat /HTTP 1.1) etc. – VLAD D ELECTRONICS Apr 04 '22 at 05:43
  • works fine when you define the word if (request.indexOf("") != -1) { ////// send text (GET/hello /HTTP 1.1) lcd.init(); lcd.backlight(); lcd.setCursor(0,0); lcd.print("Hello"); ////// prints only hello delay(1000); } Thanks for your interest!!! – VLAD D ELECTRONICS Apr 04 '22 at 05:44

1 Answers1

0

req.replace(" HTTP/1.1", ""); // Para quitar HTTP/1.1 req.replace("GET /", ""); // Para quitar GET /

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 07 '22 at 06:49