proyectos:jardin_delicias:tecnologicos:esp8266_ota
Diferencias
Muestra las diferencias entre dos versiones de la página.
| Próxima revisión | Revisión previa | ||
| proyectos:jardin_delicias:tecnologicos:esp8266_ota [2016/10/06 17:12] – creado brolin | proyectos:jardin_delicias:tecnologicos:esp8266_ota [2016/10/06 20:50] (actual) – brolin | ||
|---|---|---|---|
| Línea 1: | Línea 1: | ||
| ====== OTA (over the air) firmware upload for ESP8266 ====== | ====== OTA (over the air) firmware upload for ESP8266 ====== | ||
| + | |||
| + | <WRAP center round todo 60%> | ||
| + | * Explicar ¿qué es OTA? | ||
| + | * Explicar cuáles son las ventajas de usarlo | ||
| + | </ | ||
| http:// | http:// | ||
| https:// | https:// | ||
| + | https:// | ||
| + | https:// | ||
| + | https:// | ||
| ===== Ejemplo de arduino ===== | ===== Ejemplo de arduino ===== | ||
| + | |||
| + | El ejemplo de github está desactualizado y no funciona, tomado desde el IDE de arduino si funciona. | ||
| https:// | https:// | ||
| + | |||
| + | Se fusiona el código de OTA con la librería {{https:// | ||
| + | |||
| + | <WRAP center round info 60%> | ||
| + | Con este programa y la modificación que se explica abajo en el archivo **platformio.ini** la actualizaciones siguientes del firmware del esp se harán a través de wifi | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| + | <code c> | ||
| + | /* | ||
| + | * El código de los ejemplos de github es diferente al de el IDE de arduino. El de github no funcionó | ||
| + | */ | ||
| + | |||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | void setup() { | ||
| + | Serial.begin(115200); | ||
| + | Serial.println(" | ||
| + | |||
| + | // | ||
| + | //Local intialization. Once its business is done, there is no need to keep it around | ||
| + | WiFiManager wifiManager; | ||
| + | //reset saved settings | ||
| + | // | ||
| + | | ||
| + | //set custom ip for portal | ||
| + | // | ||
| + | |||
| + | //fetches ssid and pass from eeprom and tries to connect | ||
| + | //if it does not connect it starts an access point with the specified name | ||
| + | // | ||
| + | //and goes into a blocking loop awaiting configuration | ||
| + | wifiManager.autoConnect(" | ||
| + | //or use this for auto generated name ESP + ChipID | ||
| + | // | ||
| + | |||
| + | | ||
| + | //if you get here you have connected to the WiFi | ||
| + | Serial.println(" | ||
| + | |||
| + | |||
| + | // Port defaults to 8266 | ||
| + | // ArduinoOTA.setPort(8266); | ||
| + | |||
| + | // Hostname defaults to esp8266-[ChipID] | ||
| + | // ArduinoOTA.setHostname(" | ||
| + | |||
| + | // No authentication by default | ||
| + | // ArduinoOTA.setPassword((const char *)" | ||
| + | |||
| + | ArduinoOTA.onStart([]() { | ||
| + | Serial.println(" | ||
| + | }); | ||
| + | ArduinoOTA.onEnd([]() { | ||
| + | Serial.println(" | ||
| + | }); | ||
| + | ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { | ||
| + | Serial.printf(" | ||
| + | }); | ||
| + | ArduinoOTA.onError([](ota_error_t error) { | ||
| + | Serial.printf(" | ||
| + | if (error == OTA_AUTH_ERROR) Serial.println(" | ||
| + | else if (error == OTA_BEGIN_ERROR) Serial.println(" | ||
| + | else if (error == OTA_CONNECT_ERROR) Serial.println(" | ||
| + | else if (error == OTA_RECEIVE_ERROR) Serial.println(" | ||
| + | else if (error == OTA_END_ERROR) Serial.println(" | ||
| + | }); | ||
| + | ArduinoOTA.begin(); | ||
| + | Serial.println(" | ||
| + | Serial.print(" | ||
| + | Serial.println(WiFi.localIP()); | ||
| + | } | ||
| + | |||
| + | void loop() { | ||
| + | ArduinoOTA.handle(); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | También hay que editar el archivo **platformio.ini** donde se agrega la línea upload_board | ||
| + | <code c> | ||
| + | ; PlatformIO Project Configuration File | ||
| + | ; | ||
| + | ; Build options: build flags, source filter, extra scripting | ||
| + | ; | ||
| + | ; | ||
| + | ; | ||
| + | ; Please visit documentation for the other options and examples | ||
| + | ; http:// | ||
| + | |||
| + | [env: | ||
| + | platform = espressif8266 | ||
| + | board = esp12e | ||
| + | framework = arduino | ||
| + | lib_install = 567 | ||
| + | lib_deps = WiFiManager | ||
| + | upload_port = 192.168.1.71 ; la ip que me entregó el router de la casa | ||
| + | </ | ||
| + | Funciona con platformio no se con arduino cómo sería pero se que también se puede | ||
proyectos/jardin_delicias/tecnologicos/esp8266_ota.1475773937.txt.gz · Última modificación: por brolin
