proyectos:talleres_esp:upayakuwasi
Diferencias
Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previa | ||
proyectos:talleres_esp:upayakuwasi [2018/03/22 03:16] – [Conexión de wifi para raspberrypi vía esp8266] brolin | proyectos:talleres_esp:upayakuwasi [2018/03/26 18:19] (actual) – kz | ||
---|---|---|---|
Línea 1: | Línea 1: | ||
====== Talleres en UPAYAKUWASI - Cayambe, Ecuadro ====== | ====== Talleres en UPAYAKUWASI - Cayambe, Ecuadro ====== | ||
+ | |||
+ | ===== Contenido ===== | ||
+ | - Introducción de los espacios (upayakuwasi-un/ | ||
+ | - Presentación de participantes y expectativas | ||
+ | - Uso y adaptación a recursos naturales (Caminata por UPAYAKUWASI) | ||
+ | - Introducción a electrónica, | ||
+ | - Control de Entradas y Salidas | ||
+ | - ESP8266 | ||
+ | - Arduino | ||
+ | - Sensor humedad | ||
+ | - Sensor temperatura y humedad | ||
+ | - Sensor luz | ||
+ | - Actuador relevo | ||
+ | - Práctica | ||
+ | |||
+ | ===== Taller Mujeres ===== | ||
+ | |||
+ | http:// | ||
+ | |||
+ | - Taller en 4 capas | ||
+ | - Riego, Automatización Válvulas, Sensores, Plataforma | ||
+ | - Primera capa: (Analógico) Ellas dibujan sus huertos, ¿de donde sacan el agua?, ¿cuáles válvulas prenden?, ¿A qué horas?, presentan al resto | ||
+ | - Segunda capa: (Automatización abrir cerrar válvulas) Se programan tiempos para abrir válvulas | ||
+ | - Tercer capa: (¿qué pasa si llueve?, necesito saber que ya no tengo que regar) Cuáles son los sensores, ¿cómo se programan? | ||
+ | - Cuarta capa: (Afinación y plataforma de control) | ||
+ | |||
+ | ¿Qué es lo que se llevan? -> Relevo con ESP8266 | ||
+ | |||
+ | Cada etapa tiene que tener su presupuesto. | ||
+ | |||
===== Conexión de wifi para raspberrypi vía esp8266 ===== | ===== Conexión de wifi para raspberrypi vía esp8266 ===== | ||
Línea 62: | Línea 92: | ||
</ | </ | ||
- | una vez instalado el paquete se instala el módulo con ''' | + | una vez instalado el paquete se instala el módulo con '' |
+ | Para configurar la red inalámbrica se usa '' | ||
+ | < | ||
+ | / | ||
+ | / | ||
+ | Description=' | ||
+ | Interface=wlan0 | ||
+ | Connection=wireless | ||
+ | Security=wpa | ||
+ | |||
+ | IP=dhcp | ||
+ | |||
+ | ESSID=' | ||
+ | # Prepend hexadecimal keys with \" | ||
+ | # If your key starts with ", write it as '""< | ||
+ | # See also: the section on special quoting rules in netctl.profile(5) | ||
+ | Key=' | ||
+ | # Uncomment this if your ssid is hidden | ||
+ | #Hidden=yes | ||
+ | </ | ||
+ | |||
+ | Luego arranque el servicio ''# | ||
+ | |||
+ | FIXME | ||
+ | Tenemos problemas con la asignación de dirección ip por dhcpd, relacionado con timeouts\\ | ||
+ | https:// | ||
+ | https:// | ||
+ | https:// | ||
+ | FIXME | ||
+ | |||
+ | ===== RTC digital por medio de la libreria Time para ESP8266 ===== | ||
+ | |||
+ | Básicamente la libreria funciona por alarmas y temporizadores. Una **Alarma** es una tarea que ocurre a determinada hora del día. Mientras que un **temporizador** es una tarea programada que ocurré **después** de que haya pasado algún intervalo de tiempo. | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | <WRAP center round info 60%> | ||
+ | Muy importante recordar que en vez de usar el delay(algunvalor) de Arduino, se debe usar el de la libreria alarm. De esta manera: Alarm.delay(algunvalor) | ||
+ | </ | ||
+ | |||
+ | <code languaje=" | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | int pin = D1; | ||
+ | int hora, minutos; | ||
+ | int alarma; | ||
+ | |||
+ | void setup() { | ||
+ | Serial.begin(9600); | ||
+ | hora = 8; | ||
+ | minutos = 1; | ||
+ | //fijamos el tiempo el Domingo 25 de marzo del 2018 a las 1:40 pm | ||
+ | setTime(hora, | ||
+ | //Creamos las alarmas | ||
+ | Alarm.alarmRepeat(hora, | ||
+ | Alarm.alarmRepeat(hora, | ||
+ | | ||
+ | // | ||
+ | // | ||
+ | |||
+ | //alarma = 15; | ||
+ | // | ||
+ | // | ||
+ | pinMode(pin, | ||
+ | digitalWrite(pin, | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | digitalClockDisplay(); | ||
+ | Alarm.delay(1000); | ||
+ | } | ||
+ | |||
+ | // funciones para llamar cuando se dispara una alarma | ||
+ | void prenderSensorRiegoManana(){ | ||
+ | Serial.println(" | ||
+ | digitalWrite(pin, | ||
+ | } | ||
+ | |||
+ | void apagarSensorRiegoManana(){ | ||
+ | Serial.println(" | ||
+ | digitalWrite(pin, | ||
+ | } | ||
+ | |||
+ | void EveningAlarm(){ | ||
+ | Serial.println(" | ||
+ | } | ||
+ | |||
+ | void WeeklyAlarm(){ | ||
+ | Serial.println(" | ||
+ | } | ||
+ | |||
+ | void ExplicitAlarm(){ | ||
+ | Serial.println(" | ||
+ | } | ||
+ | |||
+ | void Repeats(){ | ||
+ | Serial.println(" | ||
+ | digitalWrite(pin, | ||
+ | Alarm.delay(5000); | ||
+ | digitalWrite(pin, | ||
+ | Alarm.delay(1000); | ||
+ | } | ||
+ | |||
+ | void OnceOnly(){ | ||
+ | Serial.println(" | ||
+ | } | ||
+ | |||
+ | void digitalClockDisplay() | ||
+ | { | ||
+ | // digital clock display of the time | ||
+ | Serial.print(hour()); | ||
+ | printDigits(minute()); | ||
+ | printDigits(second()); | ||
+ | Serial.println(); | ||
+ | } | ||
+ | |||
+ | void printDigits(int digits) | ||
+ | { | ||
+ | Serial.print(":" | ||
+ | if(digits < 10) | ||
+ | Serial.print(' | ||
+ | Serial.print(digits); | ||
+ | } | ||
+ | |||
+ | void prendaSensor(){ | ||
+ | pinMode(pin, | ||
+ | } | ||
+ | |||
+ | void apagueSensor(){ | ||
+ | pinMode(pin, | ||
+ | } | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | ===== Código para activar algo desde una página web con ESP8266 ===== | ||
+ | |||
+ | Este código genera una página web para controlar el encendido o apagado de algún dispositivo. | ||
+ | |||
+ | < | ||
+ | |||
+ | #include < | ||
+ | |||
+ | const char* ssid = " | ||
+ | const char* password = " | ||
+ | |||
+ | int ledPin = D1; // GPIO13 | ||
+ | WiFiServer server(80); | ||
+ | |||
+ | void setup() { | ||
+ | Serial.begin(115200); | ||
+ | delay(10); | ||
+ | |||
+ | pinMode(ledPin, | ||
+ | digitalWrite(ledPin, | ||
+ | |||
+ | // Connect to WiFi network | ||
+ | Serial.println(); | ||
+ | Serial.println(); | ||
+ | Serial.print(" | ||
+ | Serial.println(ssid); | ||
+ | |||
+ | WiFi.begin(ssid, | ||
+ | |||
+ | while (WiFi.status() != WL_CONNECTED) { | ||
+ | delay(500); | ||
+ | Serial.print(" | ||
+ | } | ||
+ | Serial.println("" | ||
+ | Serial.println(" | ||
+ | |||
+ | // Start the server | ||
+ | server.begin(); | ||
+ | Serial.println(" | ||
+ | |||
+ | // Print the IP address | ||
+ | Serial.print(" | ||
+ | Serial.print(" | ||
+ | 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(" | ||
+ | while(!client.available()){ | ||
+ | delay(1); | ||
+ | } | ||
+ | |||
+ | // Read the first line of the request | ||
+ | String request = client.readStringUntil(' | ||
+ | Serial.println(request); | ||
+ | client.flush(); | ||
+ | |||
+ | // Match the request | ||
+ | |||
+ | int value = LOW; | ||
+ | if (request.indexOf("/ | ||
+ | digitalWrite(ledPin, | ||
+ | value = HIGH; | ||
+ | } | ||
+ | if (request.indexOf("/ | ||
+ | digitalWrite(ledPin, | ||
+ | value = LOW; | ||
+ | } | ||
+ | |||
+ | // Set ledPin according to the request | ||
+ | // | ||
+ | |||
+ | // Return the response | ||
+ | client.println(" | ||
+ | client.println(" | ||
+ | client.println("" | ||
+ | client.println("< | ||
+ | client.println("< | ||
+ | |||
+ | client.print("< | ||
+ | |||
+ | if(value == HIGH) { | ||
+ | client.print(" | ||
+ | } else { | ||
+ | client.print(" | ||
+ | } | ||
+ | client.println("< | ||
+ | client.println("< | ||
+ | client.println("< | ||
+ | client.println("</ | ||
+ | |||
+ | delay(1); | ||
+ | Serial.println(" | ||
+ | Serial.println("" | ||
+ | |||
+ | } | ||
+ | |||
+ | </ | ||
proyectos/talleres_esp/upayakuwasi.txt · Última modificación: 2018/03/26 18:19 por kz