-->
Page 1 of 2

Serial.readString() is returning gibberish

PostPosted: Tue Dec 30, 2014 5:36 pm
by maptor
Got what is probably a stupid question for most people- though one I can't find the answer to on the web- but how do I properly capture the data returned from the ESP on an Arduino?

My setup is:
    -SoftwareSerial on pins 10 and 11 for the ESP (both the module and the interface running at 9600)
    -Serial connection is left free for USB debugging messages.

What happens:
I'm able to communicate just fine with the ESP, both input and output, up until the point that it returns the data requested from a GET. For some reason I can't get anything when attempting to readBytes() or even just read(). readString() returns gibberish... sort of. While I don't have my stuff with me at the moment to give an exact output, something like "This is a test" becomes "ths s a es".

What's going on here? Only the contents of the doc I'm receiving gets garbled. The rest of the message (header info, etc.) is completely legible. I once tried sending a string of numbers and parseInt() iterating through the entire message wound up with a string of a bunch of nonsense integers (of course) but concluded by the correct number string sequence. My guess is that I'm misusing readString() and am just being too lazy, but I'd love to be told that from someone who knows better before I make things a bit more complicated.

(Note: When I have the ESP connected directly via serial to my computer, the message is correctly received. Is this a SoftwareSerial limitation?)

Re: Serial.readString() is returning gibberish

PostPosted: Tue Dec 30, 2014 5:39 pm
by alonewolfx2
Software serial very slow and buggy for esp. You need hardware serial. It's not working correctly with software serial

Re: Serial.readString() is returning gibberish

PostPosted: Tue Dec 30, 2014 9:04 pm
by FeK9
maptor wrote:Got what is probably a stupid question for most people- though one I can't find the answer to on the web- but how do I properly capture the data returned from the ESP on an Arduino?

My setup is:
    -SoftwareSerial on pins 10 and 11 for the ESP (both the module and the interface running at 9600)
    -Serial connection is left free for USB debugging messages.

What happens:
I'm able to communicate just fine with the ESP, both input and output, up until the point that it returns the data requested from a GET. For some reason I can't get anything when attempting to readBytes() or even just read(). readString() returns gibberish... sort of. While I don't have my stuff with me at the moment to give an exact output, something like "This is a test" becomes "ths s a es".

What's going on here? Only the contents of the doc I'm receiving gets garbled. The rest of the message (header info, etc.) is completely legible. I once tried sending a string of numbers and parseInt() iterating through the entire message wound up with a string of a bunch of nonsense integers (of course) but concluded by the correct number string sequence. My guess is that I'm misusing readString() and am just being too lazy, but I'd love to be told that from someone who knows better before I make things a bit more complicated.

(Note: When I have the ESP connected directly via serial to my computer, the message is correctly received. Is this a SoftwareSerial limitation?)


GDay maptor

Read a post on this forum a month or two ago...
viewtopic.php?f=8&t=244&start=10

"...RX buffer on the ESP is 256... SoftwareSerial RX buffer is 64..."

I also came across an article on HobbyTronics Ltd UK, on howto modify/add a 256 buffer to the Arduino IDE...
http://www.hobbytronics.co.uk/arduino-s ... uffer-size

I've not tried it myself, as I'm still experimenting directly with my little esp8266...

Re: Serial.readString() is returning gibberish

PostPosted: Tue Dec 30, 2014 11:08 pm
by maptor
Thanks for the replies! I'll try poking around to try and fix things and report back with what works.