test esp web server-wifi client-(lib ESP8266WiFi), 'contenido dinamico'

This commit is contained in:
jp.av.dev 2021-07-12 21:58:57 -04:00
parent e882f48c5b
commit e8067ec92c
2 changed files with 13 additions and 2 deletions

View File

@ -0,0 +1,6 @@
Archivo de configuracion ***confidencial.h***
```c
const char* ssid = "SSID";
const char* password = "password";
```

View File

@ -1,7 +1,10 @@
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <WiFiClient.h> #include <WiFiClient.h>
#include <ESP8266WebServer.h> #include <ESP8266WebServer.h>
#include "ESP8266mDNS.h" #include <ESP8266mDNS.h>
#include "confidencial.h"
int loopcont;
ESP8266WebServer server(80); ESP8266WebServer server(80);
@ -9,7 +12,7 @@ const int led = 13;
void handleRoot() { void handleRoot() {
digitalWrite(led, 1); digitalWrite(led, 1);
server.send(200, "text/plain", "Hola desde el esp01 (2)!"); server.send(200, "text/plain", "Hola desde el esp01! "+(String)loopcont);
digitalWrite(led, 0); digitalWrite(led, 0);
} }
@ -36,6 +39,7 @@ void setup(void) {
Serial.begin(115200); Serial.begin(115200);
WiFi.mode(WIFI_STA); WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password); WiFi.begin(ssid, password);
loopcont = 0;
Serial.println(""); Serial.println("");
// Wait for connection // Wait for connection
@ -67,5 +71,6 @@ void setup(void) {
void loop(void) { void loop(void) {
server.handleClient(); server.handleClient();
loopcont+=1;
} }