CONTROL DE DISPOSITIVOS DEL HOGAR. ESP8266 THUNKABLE IP

  Рет қаралды 143

PABLO LEMA

PABLO LEMA

Күн бұрын

Пікірлер: 2
@Electroos22
@Electroos22 Жыл бұрын
Que tal. Me acabas de dar una excelente idea para un proyecto de Iot. Muchas gracias 👍. Saludos desde Panamá 🇵🇦
@pablolema7017
@pablolema7017 4 жыл бұрын
#include const char* ssid = "NOMBRE_DE_TU_RED_WIFI";//type your ssid const char* password = "CLAVE_DE_TU_RED";//type your password int PASILLO = 16; // GPIO2 of ESP8266 //int SALA = 5; //int COCINA = 4; //int HABITACION = 0; IPAddress ip(192,168,1,23); IPAddress gateway(192,168,1,9); IPAddress subnet(255,255,255,0); WiFiServer ESPserver(80);//Service Port void setup() { Serial.begin(115200); pinMode(PASILLO, OUTPUT); digitalWrite(PASILLO, HIGH); //pinMode(SALA, OUTPUT); //digitalWrite(SALA, HIGH); //pinMode(COCINA, OUTPUT); //digitalWrite(COCINA, HIGH); //pinMode(HABITACION, OUTPUT); //digitalWrite(HABITACION, HIGH); Serial.println(); Serial.println(); Serial.print("Connecting to: "); Serial.println(ssid); WiFi.config(ip, gateway, subnet); WiFi.begin(ssid, password); delay(1000); /* The following four line of the code will assign a Static IP Address to the ESP Module. If you do not want this, comment out the following four lines. */ while (WiFi.status() != WL_CONNECTED) { delay(100); Serial.print("*"); } Serial.println(""); Serial.println("WiFi connected"); // Start the server ESPserver.begin(); Serial.println("Server started"); // Print the IP address Serial.print("The URL to control ESP8266: "); Serial.print(""); Serial.print(WiFi.localIP()); } void loop() { // Check if a client has connected WiFiClient client = ESPserver.available(); if (!client) { return; } // Wait until the client sends some data Serial.println("New Client"); while(!client.available()) { delay(1); } // Read the first line of the request String request = client.readStringUntil(' '); Serial.println(request); client.flush(); // Match the request////////////////////////////////////CONTROL RELES////////////////////////////////////////// int pasillo1 = LOW; if (request.indexOf("/VENTILADOROFF") != -1) { Serial.println("LAMP is ON"); digitalWrite(PASILLO, LOW); pasillo1 = LOW; } if (request.indexOf("/VENTILADORON") != -1) { Serial.println("LAMP is OFF"); digitalWrite(PASILLO, HIGH); pasillo1 = HIGH; } //int sala1 = LOW; //if (request.indexOf("/SALAOFF") != -1) //{ //Serial.println("LAMP is ON"); //digitalWrite(SALA, LOW); //sala1 = LOW; //} //if (request.indexOf("/SALAON") != -1) //{ //Serial.println("LAMP is OFF"); //digitalWrite(SALA, HIGH); //sala1 = HIGH; //} // //int cocina1 = LOW; //if (request.indexOf("/COCINAOFF") != -1) //{ //Serial.println("LAMP is ON"); //digitalWrite(COCINA, LOW); //cocina1 = LOW; //} //if (request.indexOf("/COCINAON") != -1) //{ //Serial.println("LAMP is OFF"); //digitalWrite(COCINA, HIGH); //cocina1 = HIGH; //} // //int habitacion1 = LOW; //if (request.indexOf("/HABITACIONOFF") != -1) //{ //Serial.println("LAMP is ON"); //digitalWrite(HABITACION, LOW); //habitacion1 = LOW; //} //if (request.indexOf("/HABITACIONON") != -1) //{ //Serial.println("LAMP is OFF"); //digitalWrite(HABITACION, HIGH); //habitacion1 = HIGH; //} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Return the response client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println(""); // IMPORTANT client.println(""); client.println(""); client.print("Status of the Lamp: "); if(pasillo1 == LOW) { client.print("ON"); } else { client.print("OFF"); } delay(1); //client.stop(); Serial.println("Client disconnected"); Serial.println(""); }
Everything You Need To Know About DeepSeek
8:07
The Coding Sloth
Рет қаралды 19 М.
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
Quando A Diferença De Altura É Muito Grande 😲😂
00:12
Mari Maria
Рет қаралды 45 МЛН
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
AI Is Making You An Illiterate Programmer
27:22
ThePrimeTime
Рет қаралды 215 М.
Get Started with GitHub Copilot in VS Code (2025)
21:27
Visual Studio Code
Рет қаралды 4 М.
superposición y mallas CIRCUITOS
23:23
PABLO LEMA
Рет қаралды 32
DeepSeek’s AI LIE? The $5.6M Hoax That Shook the Market!
12:54
How to install JupyterLab and Notebook for Data Science
20:45
Chai aur Code
Рет қаралды 5 М.
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН