[WifiEsp] can transmit data but won't receive

Hello Forum

My name is Ignacio, I'm working in a project including an ESP-07 wifi module
I designed my own shield, having all the provisions for the module to work flawlessly
(I/O level translators, own power regulator with suitable capacitance, config pins set for operation, etc)
It works like a charm, it boots up okey, it connects to my home router, after some attempts.
Sometimes instantly, sometimes after a couple of attempts.

So I decided to test the connectivity using the Wifiesp provided examples.
I tested the module with an UDP and tcp test software, the Socket test V3.0

In UDP I used the example UdpSendReceive.ino and the module worked ok without problem

Now, when I ran the example "WebClient.ino" I had the issue that the program would connect OK and transmit the expected data to the receiver, but it won't receive any data.

So, I set the program as provided (for connecting to the "arduino.cc" server asking for the asciilogo.txt)
but it didn't worked either.

In both cases the module received correctly the disconnecting signal.
But no data at all.

The module is an ESP-07, it runs at 115200 baud AT command, The firmware version is 1.5.4 (as showed by the debug message) The arduino board is an MEGA2560 with only the said examples loaded (no extra software)

Do you know what may be the problem I'm experiencing?
best regards

Ignacio

try to use 9600 baud. it slows down the incoming data so the library catches up.
or try my WiFiEspAT library. it works at 500000 baud, but requires AT 1.7 (SDK 3) and doesn't support SSL

Juraj:
try to use 9600 baud. it slows down the incoming data so the library catches up.
or try my WiFiEspAT library. it works at 500000 baud, but requires AT 1.7 (SDK 3) and doesn't support SSL

Hi Juraj

I forgot to mention that I'm using a hardware serial port. (Serial3 ) On the other hand, the module is soldered to the board and no provisions for firmware upload were taken.

Do you know what issue may have the library with the tcp protocol?

regards
Ignacio

I did't say something about SoftwareSerial. use 9600 over hardware Serial too. with higher baud rate the AT firmware floods the receive buffer with data faster then the library can read them

Juraj:
I did’t say something about SoftwareSerial. use 9600 over hardware Serial too. with higher baud rate the AT firmware floods the receive buffer with data faster then the library can read them

Okey, but why the library works in UDP send and receive but in TCP it works only sending?
Additionally, if I set the initialization in 9600 baud the board isn’t detected (tag not found) Supposedly, the wifi board detects the baudrate at startup?

thanks in advance
Ignacio

nachus001:
Okey, but why the library works in UDP send and receive but in TCP it works only sending?
Additionally, if I set the initialization in 9600 baud the board isn't detected (tag not found) Supposedly, the wifi board detects the baudrate at startup?

thanks in advance
Ignacio

why TCP receive doesn't work? I wrote "the AT firmware floods the receive buffer with data faster then the library can read them".
read GitHub - jandrassy/WiFiEspAT: Arduino networking library. Standard Arduino WiFi networking API over ESP8266 or ESP32 AT commands.

you must set the baud rate in firmware too to 9600 baud for WiFiEsp library.

hello

I forgot to say that I can't receive even a single byte

nachus001:
hello

I forgot to say that I can't receive even a single byte

how do you know? the library gets +IDP with the count of bytes it should read and attempts to read so many bytes. if the buffer overflows, some bytes are lost and never arrive so the count is not fulfilled. The library waits until timeout and then returns an error and no data.

I use a program to test tcp and udp connections. I can send bytes one by one or in chunks. The program is SocketTest.

If I send a single byte I receive a single byte. At least in UDP it works like that.

start to debug the library. make it to show all the communication with AT firmware. maybe then you will see what is happening.

or update the AT firmware and use my library.

Juraj:
make it to show all the communication with AT firmware. maybe the you will see what is happening.

I revised the library files,and i managed to set the debug level to 4. And it seems to be that the module is sending some garbage that confuses the library

Once connected to the wifi router, it connects to my tcp test software that is listening, and the resulting listing is like this (remembert that the sketch keeps looping asking for conncetion status)

IP Address: 192.168.0.164
> getCurrentRSSI
----------------------------------------------
>> AT+CWJAP?
+CWJAP:"Fibertel WiFi031 2.4GHz","00:cb:51:f1:45:93",6,-48

OK
---------------------------------------------- > 482

Signal strength (RSSI):-482 dBm

Starting connection to server...
[WiFiEsp] Connecting to 192.168.0.180
> startClient 192.168.0.180 4500
----------------------------------------------
>> AT+CIPSTART=3,"TCP","192.168.0.180",4500
3,CONNECT

OK
---------------------------------------------- > 0

Connected to server
> sendData: 3 27

OK
> 
Recv 27 bytes

SEND OK
> sendData: 3 2

OK
> 
Recv 2 bytes

SEND OK
> sendData: 3 16

OK
> 
Recv 16 bytes

SEND OK
> sendData: 3 2

OK
> 
Recv 2 bytes

SEND OK
> sendData: 3 17

OK
> 
Recv 17 bytes

SEND OK
> sendData: 3 2

OK
> 
Recv 2 bytes

SEND OK
> sendData: 3 2

OK
> 
Recv 2 bytes

SEND OK
> getClientState 3
----------------------------------------------
>> AT+CIPSTATUS
STATUS:3
+CIPSTATUS:3,"TCP","192.168.0.180",4500,22766,0

OK
---------------------------------------------- > "TCP"⸮⸮!⸮⸮⸮N

Connected
> getClientState 3
----------------------------------------------
>> AT+CIPSTATUS
STATUS:3
+CIPSTATUS:3,"TCP","192.168.0.180",4500,22766,0

OK
---------------------------------------------- > "TCP"⸮⸮!⸮⸮⸮N

Connected
> getClientState 3
----------------------------------------------
>> AT+CIPSTATUS
STATUS:3
+CIPSTATUS:3,"TCP","192.168.0.180",4500,22766,0

OK
---------------------------------------------- > "TCP"⸮⸮!⸮⸮⸮N

Connected
> getClientState 3
----------------------------------------------
>> AT+CIPSTATUS
STATUS:3
+CIPSTATUS:3,"TCP","192.168.0.180",4500,22766,0

OK
---------------------------------------------- > "TCP"⸮⸮!⸮⸮⸮N

Connected
> getClientState 3

when I first send a message from my test software to the connected module, the library does this

.
.
.
.
.
.
.
Connected
> getClientState 3
----------------------------------------------
>> AT+CIPSTATUS
STATUS:3
+CIPSTATUS:3,"TCP","192.168.0.180",4500,22766,0

OK
---------------------------------------------- > "TCP"⸮⸮!⸮⸮⸮N

Connected
> getClientState 3

+IPD,3,23,192.168.0.180,4500:dadawdawdawawdawdawwd

Dirty characters in the serial buffer! > 54
----------------------------------------------
>> AT+CIPSTATUS
STATUS:3
+CIPSTATUS:3,"TCP","192.168.0.180",4500,22766,0

OK
---------------------------------------------- > "TCP"⸮⸮!⸮⸮⸮N

Connected
> getClientState 3
----------------------------------------------
>> AT+CIPSTATUS
STATUS:3
+CIPSTATUS:3,"TCP","192.168.0.180",4500,22766,0

OK
---------------------------------------------- > "TCP"⸮⸮!⸮⸮⸮N
.
.
.
.
.

but, when I sent the second message (next before disconecting 'cos the loop floods the monitor with text) I get this

.
.
.
.
.
Connected
> getClientState 3
----------------------------------------------
>> AT+CIPSTATUS

+IPD,3,20,192.168.0.180,4500:dwawdawdawdawawdaw
STATUS:3
+CIPSTATUS:3,"TCP","192.168.0.180",4500,22766,0

OK
---------------------------------------------- > "TCP"⸮⸮!⸮⸮⸮N

Connected
> getClientState 3
----------------------------------------------
>> AT+CIPSTATUS
STATUS:3
+CIPSTATUS:3,"TCP","192.168.0.180",4500,22766,0
.
.
.
.
.

when I disconnect from the test software, the module receives the disconnection okey.

However, today I've tested the example "Webclientrepeating.ino" and it worked okey, from the arduino site (repeatedly downloading the text logo)as well as from my test software.

Why do you think is this happening?

Hey

I made some progress with the wifiesp thing. particularly the "WebClient.ino" example
By commenting out the connection checking section, the character reception works okey
But I lose the ability to know if the connection is dead.
The only way to do that would be to use client.stop() unilaterally, just after quitting doing bussiness with the server, but that would limit too much the kind of application flows that are available.

void loop()
{
  
 
  

  // if there are incoming bytes available
  // from the server, read them and print them
  
  while (client.available()) {
    char c = client.read();
    Serial.write(c);
                              }


  // if the server's disconnected, stop the client
  if (!client.connected()) {      // commenting out this "if" section  will allow the character reception
    Serial.println();
    Serial.println("Disconnecting from server...");
    client.stop();

    // do nothing forevermore
    while (true);
  }

  
}

now, going by the route of the connected() function path, I found that it calls the getClientState() function

uint8_t EspDrv::getClientState(uint8_t sock)
{
 LOGDEBUG1(F("> getClientState"), sock);

 char findBuf[20];
 sprintf_P(findBuf, PSTR("+CIPSTATUS:%d,"), sock);

 char buf[10];
 if (sendCmdGet(F("AT+CIPSTATUS"), findBuf, ",", buf, sizeof(buf)))
 {
 LOGDEBUG(F("Connected"));
 return true;
 }

 LOGDEBUG(F("Not connected"));
 return false;
}

which calls sendCmdGet() which indeed calls many functions that are called also by available() and read() as far as I could see.

So, the problem seems to be in some part of the connected() that corrupts some flags in the library structure, or some function in arduino core libraries that changed since the time the library was released.

I'm stuck now, if you have any clue, please let me know

thanks in advance
Ignacio