Chat freely about anything...

User avatar
By Klyf
#24078 I'm using ESP8266 with arduino, and I'm getting Unlink error when server sends data to ESP.
This case works:

setup () {
ESP -> Server - connect to server
}

loop() {
ESP -> Server - Send data to server
ESP <=> await an answer
ESP <- Server - Server send an answer back
Arduino read the answer of ESPserial
}
Everything works fine! But the outlined case below is NOT working.

setup () {
ESP -> Server - connect to server
}

timeToSend() {
ESP -> Server - Send data to server
ESP <=> await an answer
ESP <- Server - Server send an answer back
}

loop() {

if (canSend) {
timeToSend();
}
check (ESPserial->available()) {// if there is data in this connection from time to time (1 sec)
readESPData();
}
}
When the server send data to ESP (without ESP send data to server first), ESPserial->available() detect that data has arrived, but when I'm gonna to read it, ESP returns UNLINK, and everything gets bad.
Why can't ESP receive any data in any time? It works only when ESP send data first and want to read an answer...

Marcio
User avatar
By Klyf
#24095 Only more one information, after I get this UNLINK error, I try to connect again and the same error happens forever. Logs:
// when the server tries to send data any time, I get the first unlink error

Unlink
readCmd:0
nByRead:0

// when is detected that is not connected
AT+CIPSEND=41

link is not
AT+CIFSR

192.168.1.5

OK
// try to connect again
AT+CIPSTART="TCP","192.168.1.4",1883

OK
Linked
AT+CIPSEND=41

> 0'weathertemperature:19*C,humidity:61%,
SEND OK
avail:2
avail:2
avail:2
avail:2

// for no reasons, after I connect and send the data again, I got the same error when I try to read the server responses
ERROR
Unlink
readCmd:0
nByRead:0
User avatar
By Klyf
#24467 Anyone had this problem? I thought this forum was more active!
My tip for the ESP manufactures is improve the error codes returned by this device. I loop up at documentation and there is only one hit for "unlink" that is not related to my problem.