Herramientas de usuario

Herramientas del sitio


personas:johnny:proyectos:esp8266

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

Ambos lados, revisión anteriorRevisión previa
Próxima revisión
Revisión previa
Próxima revisiónAmbos lados, revisión siguiente
personas:johnny:proyectos:esp8266 [2019/06/01 08:09] – [conectar ESp8266 a telegram] kzpersonas:johnny:proyectos:esp8266 [2019/06/04 17:02] – [Conexión LM35] kz
Línea 1: Línea 1:
-====== Configuración inicial, blink con ESP8266 en Mac usando Atom Platformio ======+====== Configuración inicial platformio en atom esp8266 ======
  
 ===== Materiales ===== ===== Materiales =====
Línea 122: Línea 122:
  
  
-{{ :personas:johnny:captura_de_pantalla_2016-11-12_a_las_19.38.43.png?600 |}}+{{ :personas:johnny:captura_de_pantalla_2016-11-12_a_las_19.38.43.png?200 |}}
  
  
Línea 234: Línea 234:
  
 http://androidcontrol.blogspot.com.co/2016/05/esp8266-wifi-control-relay.html http://androidcontrol.blogspot.com.co/2016/05/esp8266-wifi-control-relay.html
 +
 +====== Simple led on off página incrustada en código ======
 +
 +<code c++>
 +
 +#include <ESP8266WiFi.h>
 +
 +const char* ssid = "Your SSID";
 +const char* password = "Your password";
 +
 +int ledPin = 13;
 +WiFiServer server(80);
 +
 +void setup() {
 +  
 +  pinMode(ledPin,OUTPUT);
 +  digitalWrite(ledPin,LOW);
 +
 +  Serial.begin(115200);
 +  Serial.println();
 +  Serial.print("Wifi connecting to ");
 +  Serial.println( ssid );
 +
 +  WiFi.begin(ssid,password);
 +
 +  Serial.println();
 +  Serial.print("Connecting");
 +
 +  while( WiFi.status() != WL_CONNECTED ){
 +      delay(500);
 +      Serial.print(".");        
 +  }
 +
 +  
 +  Serial.println();
 +
 +  Serial.println("Wifi Connected Success!");
 +  Serial.print("NodeMCU IP Address : ");
 +  Serial.println(WiFi.localIP() );
 +
 +  server.begin();
 +  Serial.println("NodeMCU Server started");
 +
 +  // Print the IP address
 +  Serial.print("Use this URL to connect: ");
 +  Serial.print("http://");
 +  Serial.print(WiFi.localIP());
 +  Serial.println("/");
 +  
 +}
 +
 +void loop() {
 +
 +    // Check if a client has connected
 +  WiFiClient client = server.available();
 +  if (!client) {
 +    return;
 +  }
 +
 +  // Wait until the client sends some data
 +  Serial.println("Hello New client");
 +  while(!client.available()){
 +    delay(1);
 +  }
 +
 +   // Read the first line of the request
 +  String request = client.readStringUntil('\r');
 +  Serial.println(request);
 +  client.flush();
 +
 +   // Match the request
 + 
 +  int value = LOW;
 +  if (request.indexOf("/LED=ON") != -1)  {
 +    digitalWrite(ledPin, HIGH);
 +    value = HIGH;
 +  }
 +  if (request.indexOf("/LED=OFF") != -1)  {
 +    digitalWrite(ledPin, LOW);
 +    value = LOW;
 +  }
 + 
 +// Set ledPin according to the request
 +//digitalWrite(ledPin, value);
 + 
 +  // Return the response
 +  client.println("HTTP/1.1 200 OK");
 +  client.println("Content-Type: text/html");
 +  client.println(""); //  do not forget this one
 +  client.println("<!DOCTYPE HTML>");
 +  client.println("<html>");
 + 
 +  client.print("Led pin is now: ");
 + 
 +  if(value == HIGH) {
 +    client.print("On");
 +  } else {
 +    client.print("Off");
 +  }
 +  client.println("<br><br>");
 +  client.println("<a href=\"/LED=ON\"\"><button>Turn On </button></a>");
 +  client.println("<a href=\"/LED=OFF\"\"><button>Turn Off </button></a><br />");  
 +  client.println("</html>");
 + 
 +  delay(1);
 +  Serial.println("Client disonnected");
 +  Serial.println("");
 +  
 +}
 +
 +</code>
  
 ====== Cómo programar sensor AQA en rama AQAkit ====== ====== Cómo programar sensor AQA en rama AQAkit ======
Línea 287: Línea 398:
 #include <ESP8266mDNS.h> #include <ESP8266mDNS.h>
  
-static const char ssid[] = "manunderworld"; +static const char ssid[] = "-------"; 
-static const char password[] = "alex1988alex";+static const char password[] = "-------";
 MDNSResponder mdns; MDNSResponder mdns;
  
Línea 509: Línea 620:
 #define USE_SERIAL Serial #define USE_SERIAL Serial
  
-static const char ssid[] = "manunderworld"; +static const char ssid[] = "-------"; 
-static const char password[] = "alex1988alex";+static const char password[] = "---------";
 MDNSResponder mdns; MDNSResponder mdns;
  
Línea 888: Línea 999:
 {{:personas:johnny:proyectos:telegram_createbot2.jpg?400|}} {{:personas:johnny:proyectos:telegram_createbot2.jpg?400|}}
  
-===== código telegram bot esp8266c =====+===== código telegram bot esp8266 =====
  
 Se usa esta librería para el [[https://github.com/Gianbacchio/ESP8266-TelegramBot/blob/master/src/ESP8266TelegramBOT.cpp|telegram bot]] Se usa esta librería para el [[https://github.com/Gianbacchio/ESP8266-TelegramBot/blob/master/src/ESP8266TelegramBOT.cpp|telegram bot]]
Línea 1005: Línea 1116:
  
 </code> </code>
 +
 +====== conexionado de algunos sensores ======
 +
 +===== Conexión relevador =====
 +
 +Se puede reemplazar el transistor de la imagen por un ** 2N2222 **. para ensayar el Relay, se puede usar el código __blink__ de arduino
 +
 +{{:personas:johnny:proyectos:relevador.jpg?600|}}
 +
 +===== Conexión DTH11 =====
 +
 +Este sensor es un sensor de temperatura y humedad en el aire.Toda la información para conectar el sensor en este [[http://www.circuitbasics.com/how-to-set-up-the-dht11-humidity-sensor-on-an-arduino/|link]]
 +
 +{{:personas:johnny:proyectos:screen_shot_2019-06-04_at_10.08.24_am.png?150|}}
 +
 +Así conectamos el sensor al arduino o al esp. La resistencia tiene de que ser 10K
 +
 +{{:personas:johnny:proyectos:screen_shot_2019-06-04_at_10.09.37_am.png?400|}}
 +
 +El código que necesitamos para leer los valores del sensor es este:
 +
 +<code c++>
 +#include <dht.h>
 +
 +dht DHT;
 +
 +#define DHT11_PIN 7
 +
 +void setup(){
 +  Serial.begin(9600);
 +}
 +
 +void loop()
 +{
 +  int chk = DHT.read11(DHT11_PIN);
 +  Serial.print("Temperature = ");
 +  Serial.println(DHT.temperature);
 +  Serial.print("Humidity = ");
 +  Serial.println(DHT.humidity);
 +  delay(1000);
 +}
 +</code>
 +
 +===== Conexión LM35 =====
 +
 +[[https://programarfacil.com/tutoriales/fragmentos/leer-el-sensor-de-temperatura-lm35-en-arduino/|Aquí]]
 + a toda la información. En este caso hemos optado por un sensor bastante normal que detecta temperaturas desde -55ºC a 150ºC, 1ºC equivale a 10mV y soporta voltajes de entre 4V y 30V. Todo esta información se ha obtenido de la ficha técnica del LM35.
 +
 +{{:personas:johnny:proyectos:screen_shot_2019-06-04_at_10.14.49_am.png?600|}}
 +
 +<code c++>
 +/*
 +  Creado: Luis del Valle (ldelvalleh@programarfacil.com)
 +  https://programarfacil.com
 +*/
 + 
 +// Declaracion de variables globales
 +float tempC; // Variable para almacenar el valor obtenido del sensor (0 a 1023)
 +int pinLM35 = 0; // Variable del pin de entrada del sensor (A0)
 + 
 +void setup() {
 +  // Cambiamos referencia de las entradas analógicas
 +  analogReference(INTERNAL);
 +  
 +  // Configuramos el puerto serial a 9600 bps
 +  Serial.begin(9600);
 +}
 + 
 +void loop() {
 +  // Con analogRead leemos el sensor, recuerda que es un valor de 0 a 1023
 +  tempC = analogRead(pinLM35); 
 +   
 +  // Calculamos la temperatura con la fórmula
 +  tempC = (1.1 * tempC * 100.0)/1024.0; 
 + 
 +  // Envia el dato al puerto serial
 +  Serial.print(tempC);
 +  // Salto de línea
 +  Serial.print("\n");
 +  
 +  // Esperamos un tiempo para repetir el loop
 +  delay(1000);
 +}
 +
 +</code>
 +
 +
  
  
personas/johnny/proyectos/esp8266.txt · Última modificación: 2019/06/04 19:14 por kz