documentacion-proceso:tecnologicos:taller-esp8266
Diferencias
Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previa | ||
documentacion-proceso:tecnologicos:taller-esp8266 [2016/03/12 06:19] – [Relevo wifi] brolin | documentacion-proceso:tecnologicos:taller-esp8266 [Fecha desconocida] (actual) – borrado - editor externo (Fecha desconocida) 127.0.0.1 | ||
---|---|---|---|
Línea 1: | Línea 1: | ||
- | ====== Taller ESP8266 ====== | ||
- | |||
- | ===== El contenido es: ===== | ||
- | |||
- | - ¿Qué es el ESP8266? | ||
- | - ¿Cómo se programa? (Explicación de las diferentes formas para programarlo y configuración del IDE de Arduino para hacerlo) | ||
- | - Montaje de un programador para el ESP-12 | ||
- | - Ejemplo LED-Blink (Y de ahí lo que se les ocurra) | ||
- | |||
- | ===== Materiales ===== | ||
- | |||
- | * cable usb-mini (AGREGAR IMAGEN) | ||
- | * ftdi (AGREGAR IMAGEN) | ||
- | * protoboard (AGREGAR IMAGEN) | ||
- | * soldador (AGREGAR IMAGEN) | ||
- | * un computador con arduino instalado > 1.6.4 (AGREGAR IMAGEN) | ||
- | * ESP12 (AGREGAR IMAGEN) | ||
- | * pcb para ESP12 (AGREGAR IMAGEN) | ||
- | * Suiche on/off de 6 patas (AGREGAR IMAGEN) | ||
- | * Pulsador (AGREGAR IMAGEN) | ||
- | |||
- | ===== 1. ¿Qué es el ESP8266? ===== | ||
- | |||
- | http:// | ||
- | |||
- | **High Integrated** | ||
- | |||
- | ESP8266EX is among the most integrated WiFi chips in the industry with the size of 5mm x 5mm ; it integrates the antenna switches, RF balun, power amplifier, low noise receive amplifier, filters, power management modules while requires minimal external circuitry. The entire solution, including front-end module, is designed to occupy minimal PCB area. | ||
- | |||
- | |||
- | **32-bit MCU** | ||
- | |||
- | ESP8266EX integrates Tensilica L106 32-bit micro controller (MCU) which features extra low power consumption and 16-bit RSIC. The CPU clock speed is 80 MHz. It can also reach a maximum value of 160 MHz. Real Time Operation System (RTOS) is enabled. Currently, only 20% of MIPS has been occupied by the Wi-Fi stack, the rest can all be used for user application programming and development. | ||
- | |||
- | **Low Power** | ||
- | |||
- | ESP8266EX has been designed for mobile, wearable electronics and Internet of Things applications with the aim of achieving the lowest power consumption with a combination of several proprietary technologies. The power saving architecture operates in 3 modes: active mode, sleep mode and deep sleep mode. | ||
- | |||
- | **Robustness** | ||
- | |||
- | By integrating more components on-chip, we have made the solution to be the most robust and manufacturable. Our solutions also feature the widest operating temperature range, from -40°C to +125°C. | ||
- | |||
- | |||
- | https:// | ||
- | |||
- | **What is this ESP8266** | ||
- | |||
- | * It's a wireless SoC | ||
- | * It has GPIO, I2C, ADC, SPI, PWM and some more | ||
- | * It's running at 80MHz | ||
- | * 64KBytes of instruction RAM | ||
- | * 96KBytes of data RAM | ||
- | * 64KBytes boot ROM | ||
- | * It has a Winbond W25Q40BVNIG SPI flash | ||
- | * It's a RISC architecture | ||
- | * The core is a 106micro Diamond Standard core (LX3) made by Tensilica | ||
- | * The ESP8266 chip is made by Espressif | ||
- | * Modules bearing this chip are made by various manufacturers | ||
- | |||
- | **Features** | ||
- | |||
- | * 802.11 b/g/n protocol | ||
- | * Wi-Fi 2.4 GHz, support WPA/WPA2 | ||
- | * Super small module size (11.5mm x 11.5mm) | ||
- | * Integrated 10-bit ADC | ||
- | * Integrated TCP/IP protocol stack (ipv4 only at the moment) | ||
- | * Integrated TR switch, balun, LNA, power amplifier and matching network Integrated PLL, regulators, and power management units | ||
- | * +20dBm output power in 802.11b mode | ||
- | * Supports antenna diversity | ||
- | * Deep sleep power <10uA, Power down leakage current < 5uA | ||
- | * Integrated low power 32-bit MCU | ||
- | * SDIO 2.0, SPI, UART, I2C | ||
- | * STBC, 1x1 MIMO, 2x1 MIMO | ||
- | * A-MPDU & A-MSDU aggregation & 0.4μs guard interval | ||
- | * Wake up and transmit packets in < 2ms | ||
- | * Standby power consumption of < 1.0mW (DTIM3) | ||
- | * Operating temperature range -40C ~ 125C | ||
- | | ||
- | ===== 2. ¿Cómo se programa? ===== | ||
- | |||
- | ==== Arduino ==== | ||
- | Installing with Boards Manager | ||
- | |||
- | Starting with 1.6.4, Arduino allows installation of third-party platform packages using Boards Manager. We have packages available for Windows, Mac OS, and Linux (32 and 64 bit). | ||
- | |||
- | - Install Arduino 1.6.5 from the Arduino website. | ||
- | - Start Arduino and open Preferences window. | ||
- | - Enter http:// | ||
- | - Open Boards Manager from Tools > Board menu and install esp8266 platform (and don't forget to select your ESP8266 board from Tools > Board menu after installation). | ||
- | |||
- | The best place to ask questions related to this core is ESP8266 community forum: http:// | ||
- | |||
- | ==== AT Firmware ==== | ||
- | |||
- | Manipulación del ESP8266 mediante comandos AT -> http:// | ||
- | Para descargar el firmare binario -> https:// | ||
- | |||
- | ==== NodeMCU - LUA ==== | ||
- | |||
- | http:// | ||
- | |||
- | An open-source firmware and development kit that helps you to prototype your IOT product within a few Lua script lines | ||
- | |||
- | **Features** | ||
- | |||
- | **Arduino-like hardware IO ** | ||
- | Advanced API for hardware IO, which can dramatically reduce the redundant work for configuring and manipulating hardware. Code like arduino, but interactively in Lua script. | ||
- | |||
- | **Nodejs style network API ** | ||
- | Event-driven API for network applicaitons, | ||
- | |||
- | **Lowest cost WI-FI ** | ||
- | Less than $2 WI-FI MCU ESP8266 integrated and esay to prototyping development kit. We provide the best platform for IOT application development at the lowest cost. | ||
- | |||
- | **Development Kit ** | ||
- | The Development Kit based on ESP8266, integates GPIO, PWM, IIC, 1-Wire and ADC all in one board. Power your developement in the fastest way combinating with NodeMCU Firmware! | ||
- | |||
- | **Se programa con esptool.py https:// | ||
- | A cute Python utility to communicate with the ROM bootloader in Espressif ESP8266. It is intended to be a simple, platform independent, | ||
- | |||
- | **Custom Builds de nodeMCU -> http:// | ||
- | You customize your NodeMCU firmware and we build it. Just for you. On the spot. | ||
- | |||
- | |||
- | ==== MicroPython - Python ==== | ||
- | |||
- | http:// | ||
- | |||
- | MicroPython is a lean and fast implementation of the Python 3 programming language that is optimised to run on a microcontroller. The MicroPython board is a small electronic circuit board that runs MicroPython on the bare metal, and gives you a low-level Python operating system that can be used to control all kinds of electronic projects. | ||
- | |||
- | ==== Smart.js - Javascript ==== | ||
- | |||
- | https:// | ||
- | |||
- | Smart.js is a generic, cross-platform, | ||
- | ==== Sming - C++ ==== | ||
- | |||
- | https:// | ||
- | |||
- | Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language. | ||
- | |||
- | **Summary** | ||
- | |||
- | * Fast & user friendly development | ||
- | * Work with GPIO in Arduino style | ||
- | * High effective in perfomance and memory usage (this is native firmware!) | ||
- | * Compatible with standard Arduino libraries - use any popular hardware in few lines of code | ||
- | * rBoot OTA firmware updating | ||
- | * Built-in file system: spiffs | ||
- | * Built-in powerfull network and wireless modules | ||
- | * Built-in JSON library: ArduinoJson | ||
- | * HTTP, AJAX, WebSockets support | ||
- | * MQTT protocol based on libemqtt | ||
- | * Networking based on LWIP stack | ||
- | * Simple and powerfull hardware API wrappers | ||
- | * Based on Espressif NONOS SDK 1.4.0 & 1.5.0 | ||
- | |||
- | ===== 3. Montaje de un programador para el ESP-12 ===== | ||
- | |||
- | El esquema que se muestra a continuación es utilizado para programar el ESP12, se debe tener el cuenta en cuenta que los pines **GPIO2** y **GPIO0** (cables morados en el esquema de la protoboard) se conectan de manera temporal mientras se programa. Para poner a funcionar el ESP-12 en modo de ejecución de programa estos dos pines deben ser desconectados. Adicionalmente es necesario agregar un cable al pin **REST** (reset - cable verde en el esquema de la protoboard) que justo en el momento que se está subiendo el programa desde el IDE de Arduino, se debe hacer contacto con **GND** para resetear el integrado. | ||
- | |||
- | {{http:// | ||
- | {{: | ||
- | {{: | ||
- | |||
- | ===== 4. Ejemplos ===== | ||
- | |||
- | ==== LED-Blink ==== | ||
- | |||
- | El builtin led para el ESP-12 no es el mismo que está definido dentro del código de arduino. Se debe renombrar esta variable y usar el **pin 2**. A continuación se muestra el código probado con la modificación mencionada. | ||
- | |||
- | <code c++> | ||
- | /* | ||
- | | ||
- | Blink the blue LED on the ESP-01 module | ||
- | This example code is in the public domain | ||
- | |||
- | The blue LED on the ESP-01 module is connected to GPIO1 | ||
- | | ||
- | |||
- | Note that this sketch uses BUILTIN_LED to find the pin with the internal LED | ||
- | */ | ||
- | |||
- | #define LED 2 | ||
- | |||
- | void setup() { | ||
- | pinMode(LED, | ||
- | } | ||
- | |||
- | // the loop function runs over and over again forever | ||
- | void loop() { | ||
- | digitalWrite(LED, | ||
- | // but actually the LED is on; this is because | ||
- | // it is acive low on the ESP-01) | ||
- | delay(1000); | ||
- | digitalWrite(LED, | ||
- | delay(2000); | ||
- | } | ||
- | </ | ||
- | |||
- | ==== Relevo wifi ==== | ||
- | |||
- | La idea es programar el ESP8266 para que de manera remota a través de una petición a un servidor web que se crea dentro del chip se encienda o se apage un pin. El código a continuación es tomado del ejemplo **WifiWebServer** de Arduino para ESP8266. Probamos usando el **pin GPIO2** para activar el relevo pero presentaba problemas con la conexión a la red. Lo cambiamos para el **pin GPIO4** | ||
- | |||
- | <code c> | ||
- | /* | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | | ||
- | */ | ||
- | |||
- | #include < | ||
- | |||
- | const char* ssid = " | ||
- | const char* password = " | ||
- | |||
- | // Create an instance of the server | ||
- | // specify the port to listen on as an argument | ||
- | WiFiServer server(80); | ||
- | |||
- | void setup() { | ||
- | Serial.begin(115200); | ||
- | delay(10); | ||
- | |||
- | // prepare GPIO2 | ||
- | pinMode(4, OUTPUT); | ||
- | digitalWrite(4, | ||
- | | ||
- | // 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.println(WiFi.localIP()); | ||
- | } | ||
- | |||
- | 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 req = client.readStringUntil(' | ||
- | Serial.println(req); | ||
- | client.flush(); | ||
- | | ||
- | // Match the request | ||
- | int val; | ||
- | if (req.indexOf("/ | ||
- | val = 0; | ||
- | else if (req.indexOf("/ | ||
- | val = 1; | ||
- | else { | ||
- | Serial.println(" | ||
- | client.stop(); | ||
- | return; | ||
- | } | ||
- | |||
- | // Set GPIO2 according to the request | ||
- | digitalWrite(4, | ||
- | | ||
- | client.flush(); | ||
- | |||
- | // Prepare the response | ||
- | String s = " | ||
- | s += (val)?" | ||
- | s += "</ | ||
- | |||
- | // Send the response to the client | ||
- | client.print(s); | ||
- | delay(1); | ||
- | Serial.println(" | ||
- | |||
- | // The client will actually be disconnected | ||
- | // when the function returns and ' | ||
- | } | ||
- | </ | ||
- | |||
- | {{https:// | ||
- | |||
- | |||
- | |||
- | ===== Registro ===== | ||
- | |||
- | {{: | ||
- | {{: | ||
- | {{: | ||
- | {{: | ||
- | {{: | ||
- | {{: | ||
- | {{: | ||
- | {{: | ||
- | {{: | ||
- | {{: | ||
- | {{: | ||
- | {{: | ||
- | {{: | ||
- | {{: | ||
- | {{: | ||
- | {{: | ||
- | {{: | ||
- | {{: | ||