Hi Readers,

Today I have done some tests with ESP8266 prototype board.

As I had lot of issues with missing parts or annoying problems with some technologies I decided to use this prototype board as main board which will work as coordinator and for first part I will use raspberry pi zero as end-device.

Prototype board is from china is cheap and easy to install.

Installation:

What you need to do you need to download and install drivers CH340 and that’s all. I have used drivers from this site http://www.arduined.eu/ch340-windows-8-driver-download/  I think this driver is directly provided by Chinese manufactures.

Board testing:

I have created SerialPortMonitor application (source code on the bottom) which will allow you to send all commands to ESP8266 prototype board you would like. As for example to test your board I would suggest to send “AT” and after that if board will response with “AT” it will mean it is working.

Serial port is hardcoded but if you like you can use Console.Read() to provide com port manually. Bear in mind that for me seria port speed set to 9600 didn’t work for me. I have used 115200 and after that was fine.

I have decided to create this basic application even there are many tools which will allow you to send AT commands to ESP8266 prototype board but I think this application is good basic base to start working on your own ESP8266 application.

SerialPortMonitor source code:

private static string indata = string.Empty;

static void Main(string[] args)
{
var indata = string.Empty;
SerialPort serialPort = new SerialPort(“COM5”);
serialPort.BaudRate = 115200;
serialPort.Parity = Parity.None;
serialPort.StopBits = StopBits.One;
serialPort.DataBits = 8;
serialPort.Handshake = Handshake.None;
serialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);

try {
serialPort.Open();
}
catch (Exception e) {
Console.WriteLine(e.Message);
Console.WriteLine(“Application had an exception and must be closed. Press any key to continue…”);
Console.ReadLine();
return;
}

Console.WriteLine(“Write ‘end’ when you will wish to close this application.”);
Console.WriteLine(“To send command press enter (remember that \\r\\n characters will be added automatically to end of the command).\n\n”);
while (true) {
indata = Console.ReadLine();
if (!indata.StartsWith(“end”)) serialPort.WriteLine(indata + “\r\n”);
else break;
}

serialPort.Close();
}

private static string ProcessIncommingData(string data)
{
data = data.Replace(“\r”, @”\r”);
data = data.Replace(“\n”, @”\n”);
return data;
}

private static void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
{
SerialPort sp = (SerialPort)sender;
indata += ProcessIncommingData(sp.ReadExisting());

if (indata.Contains(“OK\\r\\n”) || indata.Contains(“ERROR\\r\\n”))
{
Console.WriteLine($”<< {indata}\n”);
// DO SOMETHING WITH DATA
indata = string.Empty;
}
}

 

Github repository: https://goo.gl/ii9xsz

Be positive and stay calm!

Cheers,

Radek

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s