ESP8266 Serial and Client print concussion.
hi guys.
im programming device send command via serial arduino when receives corresponding request form web client.
i used gpio pins triggers arduino it's come point when want send ricther communication between devices (alarm time, conformations ect).
i using serial.print , client.print every time request sent browser ("/blind=open") sending "get /blind=open http/1.1" serial monitor along requested via serial.print.
i have tried changing baud rate , code can't seem stop happening
my code is:
#include <esp8266wifi.h>
const char* ssid = "....";
const char* password = "....";
int ledstatus = 15;
int iposset = 0;
int iloop = 0;
int config = 1;
int request = 0;
wifiserver server(80);
void setup() {
serial.begin(115200);
pinmode(ledstatus, output);
digitalwrite(ledstatus, low);
wifi.begin(ssid, password);
while (wifi.status() != wl_connected) {
digitalwrite(ledstatus, high);
delay(1000);
digitalwrite(ledstatus, low);
delay(1000);
}
server.begin();
}
void loop() {
wificlient client = server.available();
if (!client) {
return;
}
while(!client.available()){
delay(1);
}
string request = client.readstringuntil('\r');
serial.println(request);
client.flush();
if (request.indexof("/blind=open") != -1&& iloop == 1) {
serial.println('2');
}
if (request.indexof("/blind=close") != -1&& iloop == 1) {
serial.println('3');
}
client.println("http/1.1 200 ok");
client.println("content-type: text/html");
client.println(""); // not forget one
client.println("<!doctype html>");
client.println("<html>");
client.print("blind controls");
client.println("<br><br>");
client.println("<a href=\"/blind=open\"\"><button>open blind </button></a>");
client.println("<a href=\"/blind=close\"\"><button>close blind </button></a><br />");
client.println("</html>");
delay(1);
iloop = 1;
}
im programming device send command via serial arduino when receives corresponding request form web client.
i used gpio pins triggers arduino it's come point when want send ricther communication between devices (alarm time, conformations ect).
i using serial.print , client.print every time request sent browser ("/blind=open") sending "get /blind=open http/1.1" serial monitor along requested via serial.print.
i have tried changing baud rate , code can't seem stop happening
my code is:
#include <esp8266wifi.h>
const char* ssid = "....";
const char* password = "....";
int ledstatus = 15;
int iposset = 0;
int iloop = 0;
int config = 1;
int request = 0;
wifiserver server(80);
void setup() {
serial.begin(115200);
pinmode(ledstatus, output);
digitalwrite(ledstatus, low);
wifi.begin(ssid, password);
while (wifi.status() != wl_connected) {
digitalwrite(ledstatus, high);
delay(1000);
digitalwrite(ledstatus, low);
delay(1000);
}
server.begin();
}
void loop() {
wificlient client = server.available();
if (!client) {
return;
}
while(!client.available()){
delay(1);
}
string request = client.readstringuntil('\r');
serial.println(request);
client.flush();
if (request.indexof("/blind=open") != -1&& iloop == 1) {
serial.println('2');
}
if (request.indexof("/blind=close") != -1&& iloop == 1) {
serial.println('3');
}
client.println("http/1.1 200 ok");
client.println("content-type: text/html");
client.println(""); // not forget one
client.println("<!doctype html>");
client.println("<html>");
client.print("blind controls");
client.println("<br><br>");
client.println("<a href=\"/blind=open\"\"><button>open blind </button></a>");
client.println("<a href=\"/blind=close\"\"><button>close blind </button></a><br />");
client.println("</html>");
delay(1);
iloop = 1;
}
that's request. changing baud rate not going change that. if want part of request need parse in code , print desired portion of request serial.
Arduino Forum > Topics > Home Automation and Networked Objects > ESP8266 Serial and Client print concussion.
arduino
Comments
Post a Comment