Netduino home hardware projects downloads community

Jump to content

The Netduino forums have been replaced by new forums at This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.


Member Since 07 Jun 2012
Offline Last Active May 22 2015 02:57 PM

Posts I've Made

In Topic: SerialPort ESP 8266 ESP8266 Wifi

22 May 2015 - 02:57 PM

After some testing i reccomend for serial data processing, 

some short code that quickly handles the datarecieved interrupt.


and about a 100 or 150 msec handling the data, but this is al depending on your project off-course.


       private int recBufferLength = 0;
       private byte[] recBuffer = new byte[2048];
            /* Data reception interrupt handler */
       internal void DataReceived_Interrupt(object com, SerialDataReceivedEventArgs arg)
             // byte[] buffer = new byte[serialPort.BytesToRead];
             Int32 curRead = serialPort.Read(recBuffer, recBufferLength , serialPort.BytesToRead);
             recBufferLength += curRead;


// i use some sort of data process moment, each 100 or 150 msec.

// at this moment i turn the data into a string.


 sRecieveData += new String(System.Text.Encoding.UTF8.GetChars(recBuffer, 0, recBufferLength));
 recBuffer = new byte[2048];
Also if there is an incomplete http response from the ESP8266, remember how the request was made.
Http1.0 or HTTP1.1.
testing against a linux apache server the HTTP1.1 could use Chunked responses.
( there will be some strange identifier ?? 8d4 in this case.) http://en.wikipedia....ansfer_encoding
HTTP/1.1 200 OK
Date: Fri, 22 May 2015 14:54:29 GMT
Server: Apache/2.2.29 (Unix)
X-Powered-By: PHP/5.4.40
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1
for a different request i get a response of 39342 bytes.
But still my response with the ESP8266 is choped at around 1450 bytes.
Connection: close
Accept: text/html
User-Agent: ESP8266
+IPD,1412:HTTP/1.1 200 OK
Content-Length: 39342
Content-Type: text/html
Last-Modified: Sun, 10 May 2015 19:52:13 GMT
Accept-Ranges: bytes
ETag: "2d348ccf5a8bd01:0"
Server: Microsoft-IIS/8.0
X-Powered-By: ASP.NET
Set-Cookie: ARRAffinity=0fc3cc817ad58a64bbaff8bc51eb48d3224777aeb37b322d17e1369cad947f99;Path=/;
Date: Fri, 22 May 2015 14:51:24 GMT
Connection: close
?<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<meta content="en-us" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-e

In Topic: SerialPort ESP 8266 ESP8266 Wifi

22 May 2015 - 07:26 AM

Also after getting some serial port data back, and do some string searching.

I did not check how long this takes. an array search will probably be a lot faster ?


                this.SendTimeOut = System.DateTime.Now;

                // search string
                for (int i1 = 0; i1 < 10000; ++i1)
                    test.IndexOf(":" + i1.ToString());
                Debug.Print(this.SendTimeOut +"::"+ System.DateTime.Now);

In Topic: SerialPort ESP 8266 ESP8266 Wifi

22 May 2015 - 07:13 AM

Hi Chris,


Thanks for the support, 

I did some string tests.


                this.SendTimeOut = System.DateTime.Now;
                System.String test = "";
                for (int i1 = 0; i1 < 10000; ++i1)
                    test += ":" + i1.ToString();
                Debug.Print(this.SendTimeOut +"::"+ System.DateTime.Now);
this itteration takes about 68 seconds for 10000 repeats.
And turns out it does only 147 times per second the ( += string function ).
so this is only 1200 bytes per second, not fast enough for the 9600 baud rate.
I will look into some array functions to do similar functionality.
I know the STM32F427 is quite fast with array functions.
Any one have some nice example that will run fast ?

In Topic: SerialPort ESP 8266 ESP8266 Wifi

21 May 2015 - 08:41 AM

Hi Chris,


Actualy, i changed the speed to 115200, and get about 1450 bytes at each http response.

so quite an improvement. Different than i expected....

But some data is still choped, at the end, this is not a real problem, for only sending some simple sensor data to a webserver or database.


I get the "RXOver" type in ErrorReceived_Interrupt(object sender, SerialErrorReceivedEventArgs e)

This is an input buffer overflow ?


So to fix this i need to speed up reading and processing data from the input buffer ?


I'm still wondering what the slow part is of this code (DataReceived_Interrupt) ?

there is an example of the esp8266 driver ( )

this code handles the return data of the module in arrays, i think to avoid slow string processing ?

In Topic: SerialPort ESP 8266 ESP8266 Wifi

19 May 2015 - 11:26 PM

This module has only 256 bytes cache. as far as i can test, and read on the internet.


also i did not think about that the data rate could be to slow, 

during testing i saw with the interrupt routine many times only get 2 to 4 characters.

but i will change it and see what happens.


i know the baud rate can be changed of this module. it started with 115200, and i thought it would be to fast for netmf.


so it's not the string manipulation that is slow but rather the interupt trigger fired many times ?


if i get serial data back bigger than about 256 bytes the stream is choped at irregular places





i will try it tomorrow.

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.