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

#62728 SerialPort ESP 8266 ESP8266 Wifi

Posted by JohanV on 18 May 2015 - 12:47 PM

Hello I'm trying to interface the ESP8266 WiFi with AT commands.



Also any one intresting in WiFi for the Netduino,

( better just buy the new Netduino 3 with out of the box Wifi !!! :D )



At the moment i'm using the module, with this firmware (0018000902-AI03).

At 9600 bit ps.



most functions are working now.


my problem is the ESP 8266 only have 256 byte buffer. so to read the 256 byte buffer ( 2048 bit. ).

after about 200 ms you start to loose data.


At the moment i spend quite some time to get me familiar to the .net micro framework serial port.


The serial port is read with an interupt.

This interupt is started in a new thread. so this is triggered after some data is recieved.

somtimes 2 bytes somtimes 10 or more.


serialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceived_Interrupt);

serialPort.ErrorReceived += new SerialErrorReceivedEventHandler(ErrorReceived_Interrupt);


Also at first i did not have an Error Revieved interrupt, and was unable to find the problems i had with this module.

turns out it's an buffer input overflow. ( 256 bytes max ).


I changed the handling of the recieved data, and turns out, my approach is to slowy ( or the neduino ? ). For this module.

I'm using some string functions that i suspect are to slowly ?


static System.String sRecieveData = "";

static SerialPort serialPort;


//* Data reception interrupt handler */

internal void DataReceived_Interrupt(object com, SerialDataReceivedEventArgs arg)


  byte[] bytes = new byte[serialPort.BytesToRead];

  // read the bytes

  serialPort.Read(bytes, 0, bytes.Length);

  // convert the bytes into a string

  String strLine = new String(System.Text.Encoding.UTF8.GetChars(bytes, 0, bytes.Length));

  sRecieveData += strLine;




/* Data reception interrupt handler */

internal void DataReceived_Interrupt(object com, SerialDataReceivedEventArgs arg)


  byte[] buf = new byte[1];

  System.String sRecievePart = "";

  while (serialPort.BytesToRead > 0)


    serialPort.Read(buf, 0, 1);

    sRecievePart += (char)buf[0];


  sRecieveData += sRecievePart;



So my question is what is the best way to handle the recieved serial data ? so i not get the buffer overflow error. 




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.