Hola a todos quiero pedir su amable ayuda para poder seguir con mi proyecto en el cual estoy usando el ESP8266 y la siguiente libreria de Github SSD1306 and SH1106 based 128x64 pixel OLED la cual me funciona para poder mostrar los ejemplos que vienen en la pantalla, pero el problema es que soy novato y he leido bastante pero lo que quiero lograr es que se vea en la pantalla oled la direccion Ip Local y el Gateway y la mascara de red y al cambiar las salidas en el servidor web si apago una luz o algo que tambien se vea. adjunto el codigo que copie de una pagina de internet lo que quiero es poder sacar en pantalla todo lo que puedo ver en el monitor serial, ese es mi problema no he podido cuando intento hacer codigo simple o cargarle ejemplos si puedo ver lo que quiero en la pantalla pero al tratar de mostrar lo que quiero de este codigo no me funciona, si me pueden decir por donde empezar, o si hay algo que pueda consultar agradecería la ayuda.
// Initialize the OLED display using Wire library
//SSD1306Wire display(0x3c, D3, D5);
const char* ssid = "xxxx";
const char* password = "xxxxx";
WiFiServer server(80);
IPAddress ip(192, 168, 0, 9);
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 255, 0);
String Relevo1Estado = "off";
const int relay1 = 5;
void setup() {
Serial.begin(115200);
// funcion de pantalla lcd
// display.init();
// display.flipScreenVertically();
//display.setFont(ArialMT_Plain_10);
//display.setTextAlignment(TEXT_ALIGN_LEFT);
// Initialize the output variables as outputs
pinMode(relay1, OUTPUT);
digitalWrite(relay1, HIGH);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
WiFi.config(ip, gateway, subnet);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
// Print local IP address and start web server
Serial.println("");
Serial.println("WiFi connected.");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
server.begin();
}
void loop() {
WiFiClient client = server.available();
if (client) {
Serial.println("New Client.");
String currentLine = "";
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
header += c;
if (c == '\n') {
if (currentLine.length() == 0) {
client.println("HTTP/1.1 200 OK");
client.println("Content-type:text/html");
client.println("Connection: close");
client.println();
if (header.indexOf("GET /5/on") >= 0)
{
Serial.println("LUZ SALA on");
Relevo1Estado = "on";
digitalWrite(relay1, LOW);
}
else if (header.indexOf("GET /5/off") >= 0)
{
Serial.println("LUZ SALA off");
Relevo1Estado = "off";
digitalWrite(relay1, HIGH);
client.println("<!DOCTYPE html><html>");
client.println("<head><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">");
client.println("<link rel=\"icon\" href=\"data:,\">");
//client.println("<style>html { color: white; background-color: #000000;font-family: Helvetica; display: inline-block; margin: 0px auto; text-align: center;}");
client.println("<style>html { color: r; background-color: #000000;font-family: r; text-align: center;}");
client.println(".button { background-color: rrr; border: none; color:
; padding: 2px px;");
client.println("text-decoration: none; font-size: 23px; margin: 9px; cursor: pointer;}");
client.println(".button2 {background-color: rrr;}</style></head>");
// Web Page Heading
client.println("<body><h1> Web Server Control Luces</h1>");
// Display current state, and ON/OFF buttons for GPIO 5
client.println("<p>LUZ SALA- Estado " + Relevo1Estado + "</p>");
// If the relay1State is off, it displays the ON button
if (Relevo1Estado == "off") {
client.println("<p><a href=\"/5/on\"><button class=\"button\">ON</button></a></p>");
} else {
client.println("<p><a href=\"/5/off\"><button class=\"button button2\">OFF</button></a></p>");
</p>");
}
client.println("</body></html>");
// The HTTP response ends with another blank line
client.println();
// Break out of the while loop
break;
} else { // if you got a newline, then clear currentLine
currentLine = "";
}
} else if (c != '\r') { // if you got anything else but a carriage return character,
currentLine += c; // add it to the end of the currentLine
}
}
}
// Clear the header variable
header = "";
// Close the connection
client.stop();
Serial.println("Client disconnected.");
Serial.println("");
}
}