AT+CIPSEND wrong character in reply (129)

PeVoo
Posts: 6
Joined: Sun Dec 13, 2015 11:39 pm

AT+CIPSEND wrong character in reply (129)

Postby PeVoo » Mon Dec 14, 2015 12:13 am

Hello,

I'm creating a library for ESP8266 and I have discovered that the reply character to the AT+CIPSEND command is not always the ">". It depends on the length of the transmitted data in my case. When I'm sending only a few (less than 10) characters, everything is OK, I get the ">" and all works well. But when I try to send more (10+) characters then instead of ">" I'm getting a 129 character in response (or -128 if signed). If I ignore that, then the sending still works, but I would like to be sure that the chip is waiting for data before I send it to it.

More info:
I've got ATmega328P chip on a breadboard, correctly connected (with 16MHz oscillator and the power is filtered using 22pF capacitors right next to the microcontroller). I'm using SortwareSerial library to communicate wit ESP-01 (black) on analog A1,A2 pins (I use standard Serial pins for debugging) and I use ISP pins to upload new sketches. I'm running everything on 3,3V. AT+GMR says: 00200.9.5(b1) compiled @ Dec 25 2014 21:40:28 AI-THINKER Dec 25 2014. I've got some other stuff on the breadboard too, but I think it's not important because it all works fine. I have tried to change the serial pins to digital (2 and 4) and the result was the same.

Thank you for your help.

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: AT+CIPSEND wrong character in reply (129)

Postby ESP_Faye » Mon Dec 14, 2015 2:31 pm

Hi,

Sorry that we could not duplicate your problem.

Please have a try with our latest AT firmware http://bbs.espressif.com/viewtopic.php?f=46&t=1451
AT documentation: http://bbs.espressif.com/viewtopic.php?f=51&t=1022

If your problem is still unsolved, please provide the AT logs for debugging. For example:

Code: Select all

AT+CWMODE=3

OK
AT+CWJAP="netgear","12348765"
WIFI CONNECTED
WIFI GOT IP

OK
AT+CIPSTART="TCP","192.168.1.3",1001
CONNECT

OK
AT+CIPSEND=2000

OK
>
Recv 2000 bytes

SEND OK

PeVoo
Posts: 6
Joined: Sun Dec 13, 2015 11:39 pm

Re: AT+CIPSEND wrong character in reply (129)

Postby PeVoo » Tue Dec 15, 2015 7:11 am

Hi,

I'm attaching here my log. I'm using USB-to-Serial to send commands to ATmega328P using its hardware serial pins and then it forwards them to the ESP8266 using SoftwareSerial on pins A1, A2 and then it's forwarding its reply back to me. Both serials are set to 9600 baud rate. I think I'm getting some kind of distorsions on the ESP TX -> ATmega RX line while it is sending data through WiFi - see the log near the bottom, when it's echoing a bigger piece of data to send. Also some of the chars are missing. Maybe it will help you get what's wrong.

ESP8266 LOG.zip
The LOG.
PS: Why can't I attach a TXT file?
(473 Bytes) Downloaded 570 times


Maybe I will try to flash it with the newest firmware later (not today), but I am afraid of that because when I got this chip I've had big problems when I was trying to flash it and I was really happy that it finally succeeded (so I haven't touched it's firmware since then). The flashing process was hanging up after every time on the same number of bytes sent. Then I started to upload some other firmware versions and the number of bytes (until hang) has changed. After about 10 tries I discovered that the number of bytes was bigger now for the same (my desired) firmware version. Then I tried more times and it was hanging later each time and then it finally succeeded to the end. Like the chip was warming up and being able to "learn" more every time. Maybe this chip is broken from the beginning, but so far it is working correctly (except the flashing process and the issues with replies described here).

Please try to help me with this. If you want me to do some more tests, please ask. I'll do what I can. You can even send me some sketches to test if you need it (and I will send you their output).

Thank you.

PeVoo
Posts: 6
Joined: Sun Dec 13, 2015 11:39 pm

Re: AT+CIPSEND wrong character in reply (129)

Postby PeVoo » Tue Dec 15, 2015 7:26 am

PS: The attached log contains few errors because I was manually cleaning it from my additional debug lines, so it would contain the sent AT commands and their replies. Also don't worry about the CIPMODE error. This setting is not reseting every time so this time it was 0 already (I think even cutting the power off does not reset it every time).

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: AT+CIPSEND wrong character in reply (129)

Postby ESP_Faye » Fri Dec 18, 2015 2:55 pm

Hi,

It seems that the wrong character problem is only a display problem, the command is actually right (because you can always get the "OK" response, but it shows the wrong character).

Maybe you can try it with another UART tool, or try to re-connect your hardware UART serial line.

PeVoo
Posts: 6
Joined: Sun Dec 13, 2015 11:39 pm

Re: AT+CIPSEND wrong character in reply (129)

Postby PeVoo » Fri Dec 18, 2015 4:42 pm

Hi,

It's definitely not a display problem. Please notice that on short data the chip replies correctly with ">" character - only for longer data it replies with a 129 character. I didn't 'guess' the 129 number, I have converted the character to unsigned int (in the sketch) and got the number from there - so it's not an encoding problem. Second thing. please notice the line where I'm sending 70 identical bytes of data. When I get an echo of them, they are distorted, but you can see that few first and last characters are read correctly. The middle part gets distorted (that's why the echoes of short data are NOT getting distorted). I'm 90% sure that it is related to baud rate distortions. It's either happening on the ESP chip or ATmega328P-PU (or both in the opposite directions). I don't have an oscilloscope, but I'm sure you do. Please check whether the speed of transmission is anyhow affected in both chips in the moment of getting an echo for 70 bytes that are being send. Also please note that some of the replies are missing some characters at the beginning. I don't know what is the cause of that but maybe it's somehow related. If you want me to perform any tests (before I flash the chip and potentially lost it), please write. I'm last day at work today so I will have more time to help you now.

Thanks and regards.

PeVoo
Posts: 6
Joined: Sun Dec 13, 2015 11:39 pm

Re: AT+CIPSEND wrong character in reply (129)

Postby PeVoo » Sun Dec 20, 2015 7:11 am

Hi again,

I think my theory of temporary baud rate distortions is correct. I thought that maybe during sending over WiFi the chip is unable to keep the correct serial baud rate so I started to experiment with it. While keeping the ESP at 9600 I was changing the SoftwareSerial's baud rate in my sketch. When I've set it to a magic number of 9200 I was getting the correct characters in echoed data to send! But this didn't solve my problem, because the ">" character is still distorted (now I was getting a "@" char) so my program still can't know if it is OK to send the data or not. :( Also I have replaced the ESP chip with another one (blue, with the same firmware) and it's the same, so it's either a common ESP problem or ATmega problem.

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: AT+CIPSEND wrong character in reply (129)

Postby ESP_Faye » Mon Dec 21, 2015 11:09 am

Hi,

Code: Select all

AT+GMR
00200.9.5(b1)
piled @ Dec 25 2014
THINKER Dec 25 2014
OK


It seems that you are not using our official AT firmware.
Could you have a try with our AT firmware ? http://bbs.espressif.com/viewtopic.php?f=46&t=1451

PeVoo
Posts: 6
Joined: Sun Dec 13, 2015 11:39 pm

Re: AT+CIPSEND wrong character in reply (129)

Postby PeVoo » Wed Dec 23, 2015 5:01 am

Hi,

I thought it was official, just a little old (and it was recommended to me as the least problematic version).

I will have to learn to use your flashing tool first before I try the newest version. Last time it was a single BIN file and a simple tool that just transfered this single file through a COM port. I see you have the the firmware file split (and some different versions of those parts) and your tool somehow merges the files before flashing, but I don't understand any of the rules yet. So many strange options... Why can't this be just a simple single file upload? Have you got any quick tutorial on this somewhere?

In the meantime I have discovered another thing. When I "talk" to the chip directly from PC terminal, I don't get the echo distortions. Even on 115200 baud rate. So it must be either the ATmega328P-PU problem or some code problems (pins? library conflicts? Hardware and software serials conflict? I don't know). But it seems that the ESP chip is OK (despite the incorrect firmware version). If you have any advice for me where or how to look for the cause of the problem or what it might be then please write, because I'm stuck with it and I would really appreciate any constructive help.

Thanks.

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: AT+CIPSEND wrong character in reply (129)

Postby ESP_Faye » Thu Dec 24, 2015 2:35 pm

Hi,

Download AT documentation.

Download ESP Flash Tool and documentation.

Sorry that you are not using our official AT firmware. Our AT firmware has two bin files, but you can merge them to be a single bin file through ESP Flash Tool.
Could you have a try with our AT firmware ? http://bbs.espressif.com/viewtopic.php?f=46&t=1451
Command "ATE1" to enable echo, "ATE0" to disable echo.

Thanks for your interest in ESP8266 !

Who is online

Users browsing this forum: No registered users and 2 guests