Trouble in C#, Receiving data from esp8266
Posted: Thu Aug 31, 2017 4:06 am
Hello guys!!!
what is the best way to send and receive information from esp8266 in C# and showing it???
i used some codes but they didn't work:(
on the ESP:
Wifi Connection is valid and the ip address is known.this code waits for a request and shows the request on SerialTerminal and send the "Data" to client.
and the PC side using System.Net.WebClient:
the problem is that when you request on a web explorer(Like mozila or anything) on a PC is in the same LAN it works great. it shows the Data and Serial shows the request that you entered on web explorer.
but the C# codes give me an error:
however the request that i entered in the C# codes ("This_is_a_test") is shown in the SerialTerminal.
is there anyway to communicate between esp and a C# application without these errors???
what is the best way to send and receive information from esp8266 in C# and showing it???
i used some codes but they didn't work:(
on the ESP:
Code: Select all
void loop() {
WiFiClient client = server.available();
if (!client) {
return;
}
while (!client.available()) {
delay(1);
}
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
client.println(Data);
}
Wifi Connection is valid and the ip address is known.this code waits for a request and shows the request on SerialTerminal and send the "Data" to client.
and the PC side using System.Net.WebClient:
Code: Select all
WebClient wc = new WebClient();
byte[] Data = wc.DownloadData("http://192.168.1.100/This_is_a_test");
File.WriteAllBytes(@"D:\A.txt", Data);
the problem is that when you request on a web explorer(Like mozila or anything) on a PC is in the same LAN it works great. it shows the Data and Serial shows the request that you entered on web explorer.
but the C# codes give me an error:
The server committed a protocol violation. Section=ResponseStatusLine
however the request that i entered in the C# codes ("This_is_a_test") is shown in the SerialTerminal.
is there anyway to communicate between esp and a C# application without these errors???