Giter VIP home page Giter VIP logo

Comments (30)

JAndrassy avatar JAndrassy commented on August 10, 2024

I answered you yesterday. Did you delete and repost it again without any change?
your request is wrong. lookup HTTP protocol. what is a header line, what is a request body, how they are separated by an empty line.

from wifiesp.

gimenezfrg avatar gimenezfrg commented on August 10, 2024

Hi, sorry, I didn't delete the previous one, keep it up, I just opened a new one because I thought it would be better.
I have no problem consuming the API, it works, the data arrives, the problem is that it takes almost 1s the whole operation, I changed the code and it continues the same thing, see:

String content = "{\"UserName\": \"" + wsUserName + "\", \"BancoDados\": " + wsBancoDados + ", \"Botao\": \"" + buttonCode + "\", \"Ligado\": " + buttonStatus + "}";
    client.println("POST " + wsMetodo + " HTTP/1.1");
    client.println("Host: " + wsServidorIp + ":" + wsServidorPort);
    client.println("Content-Length: " + String(content.length() + 2));
    client.println("Content-Type: application/json"); 
    client.println("Connection: close");   
    client.println(); 
    client.println(content); 
12:51:08.894 > B04 APERTADO
12:51:08.929 > Evento B04...
12:51:08.929 > [WiFiEsp] Connecting to 10.1.1.122
12:51:08.961 > Conectado ao servidor.
12:51:08.988 > Send B04...
12:51:09.755 > Envio finalizado.

from wifiesp.

JAndrassy avatar JAndrassy commented on August 10, 2024

what bad rate do you use to communicate with the AT firmware?
what code prints that output?

from wifiesp.

gimenezfrg avatar gimenezfrg commented on August 10, 2024
void setup()
{  
  Serial.begin(9600);
   //-- Inicializa a serial para conexão com ESP.
  Serial3.begin(115200);
  //-- Inicializa modulo ESP.
  WiFi.init(&Serial3);
...

while (status != WL_CONNECTED) 
  {   
    Serial.print("Tentando conectar ao WPA SSID: ");
    Serial.println(ssid);
    
    status = WiFi.begin(ssid, pass);
  }

...

void ButtonWsSend(String buttonCode, String buttonStatus)
{
  if (client.connect(wsServidorIp.c_str(), wsServidorPort)) 
  {
    Serial.println("Conectado ao servidor.");
    Serial.println("Send "+ buttonCode +"...");

    //--.    

    String content = "{\"UserName\": \"" + wsUserName + "\", \"BancoDados\": " + wsBancoDados + ", \"Botao\": \"" + buttonCode + "\", \"Ligado\": " + buttonStatus + "}";
    client.println("POST" + wsMetodo + " HTTP/1.1");
    client.println("Host: " + wsServidorIp + ":" + wsServidorPort);
    client.println("Content-Length: " + String(content.length() + 2));
    client.println("Content-Type: application/json"); 
    client.println("Connection: keep-alive");   
    client.println(); 
    client.println(content); 
    
    //--.

    client.flush();
    client.stop();

    Serial.println("Envio finalizado.");
  }
}

from wifiesp.

JAndrassy avatar JAndrassy commented on August 10, 2024

you could try my WiFiEspAT library. maybe it is faster. sure is, it can run at higher baud rate on hardware Serial

https://github.com/jandrassy/WiFiEspAT#Why-a-new-wifiesp-library

from wifiesp.

gimenezfrg avatar gimenezfrg commented on August 10, 2024

Good afternoon, do you think it might be related to the Firmware I'm using?

I'm using an Arduino Mega RoboDyn board (AT MEGA 2560 + ESP 8266).
This was the AT Firmware I used on ESP:

image

from wifiesp.

JAndrassy avatar JAndrassy commented on August 10, 2024

SDK 1.5 is ancient.
but the speed is a problem of WiFiEsp library. my WiFiEspAT library is faster

from wifiesp.

gimenezfrg avatar gimenezfrg commented on August 10, 2024

I'm trying for your library but I can't communicate with ESP, see:
image

image

Before I updated the Firmware to version 2.2.1:
image

What will be the problem?

from wifiesp.

JAndrassy avatar JAndrassy commented on August 10, 2024

my library requires at least AT 1.7 (from SDK 3)
https://www.espressif.com/en/support/download/at?keys=&field_type_tid%5B%5D=14

from wifiesp.

gimenezfrg avatar gimenezfrg commented on August 10, 2024

Same thing :(

image

image

image

from wifiesp.

JAndrassy avatar JAndrassy commented on August 10, 2024

the board's setup should be right if it worked with previous library.
turn on debug logging https://github.com/jandrassy/WiFiEspAT#logging

EDIT: does the AT firmware respond to commands from Serial Monitor when you connect the esp8266 directly over USB?

from wifiesp.

gimenezfrg avatar gimenezfrg commented on August 10, 2024

It is not responding to AT commands.

With ESP connected directly to USB and with DIP7 on it just shows this:
image

With the DIP7 turned off, this information is passed on and on:
image

*** The information is only readable at 74880 speed

from wifiesp.

gimenezfrg avatar gimenezfrg commented on August 10, 2024

I put this firmware:

image

With this configuration:
image

from wifiesp.

gimenezfrg avatar gimenezfrg commented on August 10, 2024

The closest I got to running the AT commands was by following this tutorial "https://www.instructables.com/Program-Any-ESP8266-Boardmodule-With-AT-Commands-F" and leaving the configuration almost the same:
image

Connecting to ESP 74880 I receive these messages:
image

After changing to 115200 I get a Ready, sending the AT command I get ERROR
image

*** The problem seems to be with the version of this ESP, something is not hitting, this board is an ESP8266EX

from wifiesp.

JAndrassy avatar JAndrassy commented on August 10, 2024

see https://github.com/jandrassy/WiFiEspAT#at-17-1

and to send AT commands from Serial Monitor set the line ending setting to Both

from wifiesp.

gimenezfrg avatar gimenezfrg commented on August 10, 2024

With firmware version 2.2.1:
image

The AT command worked:
image

I will try to use your library now ...

from wifiesp.

gimenezfrg avatar gimenezfrg commented on August 10, 2024

Did not work :(

image

from wifiesp.

JAndrassy avatar JAndrassy commented on August 10, 2024

again. AT 1.7 is with SDK 3.
test with CheckFirmware example

AT 2.1 is with RTOS SDK IDF framework

from wifiesp.

gimenezfrg avatar gimenezfrg commented on August 10, 2024

Is it for me to test with Firmware 1.7? I already tested with 1.7 and 1.7.4, it does not work the AT command, the only one that seems to work is this one, 2.2.1

I didn't understand what I have to test now, could you give more details?

from wifiesp.

gimenezfrg avatar gimenezfrg commented on August 10, 2024

I think I understand, is it for me to follow the recommendations below?
How do I do this "--flash_size 1MB 0x0" in "ESP8266 DOWNLOAD TOOL"?

image

from wifiesp.

gimenezfrg avatar gimenezfrg commented on August 10, 2024

It worked, I put Firmware 1.7.4 following its settings and it worked, the weather improved well, something around 200ms for POST and 100ms for GET.

The only problem is that after consuming the API 4 times, on Thursday, as a disconnected server, can you tell me why?

image

from wifiesp.

gimenezfrg avatar gimenezfrg commented on August 10, 2024

I commented client.stop() and stopped disconnecting after 5 times, I don't know if it's right, but it worked.

from wifiesp.

JAndrassy avatar JAndrassy commented on August 10, 2024

you flashed the 1 MB version? the esp8266 on Mega+WiFi has a 4 MB flash memory, but the firmware only needs two so Espressif builds the published version for 2 MB flash and a stripped down version for 1 MB flash

from wifiesp.

gimenezfrg avatar gimenezfrg commented on August 10, 2024

I used firmware 1.7.4 and followed the parameters indicated in mark 2 of the image, should I use the parameters of mark 1?

image

from wifiesp.

JAndrassy avatar JAndrassy commented on August 10, 2024

yes 1, the second is for 1 MB esp-01 modules.
but it is not important if you don't need the removed features

from wifiesp.

gimenezfrg avatar gimenezfrg commented on August 10, 2024

How can I be sure that mine is not ESP-01? It has these markings:
ESP8266EX
412019
UB00PPAW77

from wifiesp.

JAndrassy avatar JAndrassy commented on August 10, 2024

4 MB clues: 1) Robotdyn Mega+WiFi board spec 2) Flash Download Tool detection

from wifiesp.

gimenezfrg avatar gimenezfrg commented on August 10, 2024

Okay, last question, is there a significant difference whether or not to use client.stop()?

Without it working well, can I keep it that way?
I also left Connection: keep-alive, it got faster.

Thank you very much for all the support.

from wifiesp.

JAndrassy avatar JAndrassy commented on August 10, 2024

Okay, last question, is there a significant difference whether or not to use client.stop()?

Without it working well, can I keep it that way?
I also left Connection: keep-alive, it got faster.

Thank you very much for all the support.

the AT firmware is limited to 5 concurrent 'links' (TCP clients and UDP listeners). it is harder to manage if some connections are left open.

and is it faster?

from wifiesp.

gimenezfrg avatar gimenezfrg commented on August 10, 2024

Just for you to understand, my solution has 16 connected buttons and are pressed by users at random. When a button is pressed, I consume a web service to record the moment that was pressed, the registration is done in a database.

As it can happen that more than one user presses the same time, the sending must be as fast as possible.

Anyway, without using client.stop() and with "Connection: keep-alive" it fine, somewhere around 80ms, and it doesn't stop after 5 uploads.

from wifiesp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.