Logout succeed
Logout succeed. See you again!

ESP8266 Arduino Core Documentation PDF
Preview ESP8266 Arduino Core Documentation
ESP8266 Arduino Core Documentation Versión 2.4.0 Ivan Grokhotkov 12 de junio de 2020 Contenido: 1. Instalación 1 1.1. GestordeTarjetas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2. Usandolaversióngit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2. Referencia 5 2.1. DigitalIO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.2. Entradaanalógica . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.3. SalidasAnalógicas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.4. Tiemposyretrasos(delays) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.5. Serial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.6. Progmem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3. Librerías 9 3.1. WiFi(libreríaESP8266WiFi) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.2. Ticker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.3. EEPROM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.4. I2C(libreríaWire) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.5. SPI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.6. SoftwareSerial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.7. APIsespecificasdeESP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.8. RespondedormDNSyDNS-SD(libreríaESP8266mDNS) . . . . . . . . . . . . . . . . . . . . . . . 11 3.9. RespondedorSSDP(ESP8266SSDP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.10. ServidorDNS(libreríaDNSServer) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.11. Servo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3.12. LibreríamejoradaEEPROMparaESP(ESP_EEPROM) . . . . . . . . . . . . . . . . . . . . . . . . 12 3.13. Otraslibrerías(noincluidasconelIDE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 4. Sistemadeficheros 15 4.1. Esquemadelamemoriaflash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4.2. Limitacionesdelsistemadeficheros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 4.3. Subiendoficherosalsistemadearchivos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 4.4. ObjetosistemadeficherosSPIFFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 4.5. Estructuradeinformacióndelsistemadearchivos . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 4.6. ObjetodirectorioDir . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 4.7. ObjetoficheroFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 5. LibreríaESP8266WiFi 23 I 5.1. Introducción . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 5.2. Descripcióndelaclase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 5.3. Diagnóstico . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 5.4. ¿Quehaydentro? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 6. ActualizacionesOTA 39 6.1. Introducción . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 6.2. ArduinoIDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 6.3. BuscadorWeb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 6.4. ServidorHTTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 6.5. Interfazdetransmisión . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 6.6. ClaseUpdater . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 7. GuíaparaPROGMEMsobreESP8266yArduinoIDE 59 7.1. Introducción . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 7.2. Declararunacadenaflashenunbloquedecódigo. . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 7.3. FuncionesparaleerdesdePROGMEM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 7.4. ¿Comodeclarounacadenaglobalflashylauso? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 7.5. Comousocadenasalineadasflash? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 7.6. ¿ComodeclaroyusodatosenPROGMEM? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 7.7. ¿ComodeclaroalgunosdatosenPROGMEMyrecuperounbytedeél? . . . . . . . . . . . . . . . . 62 7.8. Enresumen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 8. UtilizandoGDBparadepuraraplicaciones 65 8.1. NotaCLIeIDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 8.2. PreparandotuaplicaciónparaGDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 8.3. Iniciandolasesióndedepuración . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 8.4. Ejemplodesesióndedepuración . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 8.5. LimitacionesdedepuracióndelHardwareESP8266 . . . . . . . . . . . . . . . . . . . . . . . . . . 70 9. Tarjetas 71 9.1. MóduloGenéricoESP8266 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 9.2. AdaptadorSerie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 9.3. ConfiguraciónHardwaremínimaparaBootloadingyejecución . . . . . . . . . . . . . . . . . . . . 72 9.4. ESPaSerie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 9.5. Mínimo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 9.6. Estabilidadmejorada . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 9.7. Mensajesdearranqueymodos. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 9.8. MóduloGenéricoESP8285 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 9.9. ESPDuino(MóduloESP-13). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 9.10. AdafruitFeatherHUZZAHESP8266 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 9.11. InventOne . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 9.12. XinaBoxCW01 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 9.13. ESPressoLite1.0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 9.14. ESPressoLite2.0. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 9.15. Phoenix1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 9.16. Phoenix2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 9.17. NodeMCU0.9(MóduloESP-12) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 9.18. NodeMCU1.0(MóduloESP-12E) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 9.19. OlimexMOD-WIFI-ESP8266(-DEV) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 9.20. SparkFunESP8266Thing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 9.21. SparkFunESP8266ThingDev. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 9.22. SweetPeaESP-210 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 9.23. LOLIN(WEMOS)D1R2&mini . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 9.24. LOLIN(WEMOS)D1miniPro . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 II 9.25. LOLIN(WEMOS)miniLite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 9.26. WeMosD1R1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 9.27. ESPino(MóduloESP-12) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 9.28. ThaiEasyElec’sESPino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 9.29. WifInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 9.30. Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 9.31. 4DSystemsgen4IoDRange. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 9.32. DigistumpOak . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 9.33. WiFiduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 9.34. AmperkaWiFiSlot. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 9.35. SeeedWioLink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 9.36. ESPectroCore . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 10.Preguntas-FAQ 83 10.1. Obtengoelerror«espcomm_syncfailed»cuandointentosubiramiESP.¿Comoresuelvoesteproblema? 83 10.2. ¿Porquénoapareceesptoolenelmenú«Programador»?¿ComosuboalESPsinél? . . . . . . . . . 83 10.3. MiESPsebloqueaalcorrerelprograma.¿Comoloresuelvo? . . . . . . . . . . . . . . . . . . . . . 83 10.4. ¿ComopuedoobteneralgunosKBsextraenlaflash? . . . . . . . . . . . . . . . . . . . . . . . . . . 84 10.5. SobreWPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 10.6. EstalibreríadeArduinonofuncionaenESP.¿Comolahagofuncionar? . . . . . . . . . . . . . . . . 84 10.7. EnelIDE,paraESP-12Equetieneunaflashde4M,puedoseleccionar4M(1MSPIFFS)o4M(3M SPIFFS).Noimportaloqueseleccione,elIDEmedicequelacapacidadmáximaesde1M.¿Donde vamiflash? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 10.8. HeobservadoqueESP.restart()nofunciona.Cualeslarazón. . . . . . . . . . . . . . . . . . . . . . 85 10.9. ¿Comosolucionarelerror«Boardgeneric(platformesp8266,packageesp8266)isunknown»? . . . 85 10.10.¿CómoborrarPCBsTCPenestadodeesperadetiempo?. . . . . . . . . . . . . . . . . . . . . . . . 85 10.11.¿Porquéhayungeneradordetarjetasyparaquesirve? . . . . . . . . . . . . . . . . . . . . . . . . . 86 11.ExceptionCauses(EXCCAUSE) 87 12.Depuración 89 12.1. Introducción . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 12.2. Información . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 13.Volcadosdepila 93 13.1. Introducción . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 14.UtilizarEclipseconArduinoESP8266 97 14.1. Quedescargar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 14.2. ConfigurarArduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 14.3. ConfigurarEclipse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 14.4. Eclipsenocompila . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 III IV 1 CAPÍTULO Instalación 1.1 Gestor de Tarjetas Esteeselmétodoelegidoparalosusuariosfinales. 1.1.1 Prerequisitos Arduino1.6.8,descárgalodelapáginawebdeArduino: Conexiónainternet 1.1.2 Instrucciones IniciaArduinoyabrelaventanaPreferencias. Introduce http://arduino.esp8266.com/stable/package_esp8266com_index.json en la casillaGestordeURLsAdicionalesdeTarjetas.PuedesañadirmúltiplesURLsseparándolasconcomas. AbreengestordetarjetasdesdeHerramientas>«Últimatarjetaseleccionada»>Gestordetarjetasybuscala plataformaesp8266. Seleccionelaversiónquedeseedelalista. ClickenelbotónInstalar. NoolvidesseleccionartutarjetaESP8266desdeHerramientas>Menúdetarjetastraslainstalación. Opcionalmente puedes usar el paquete staging desde el siguiente link: http://arduino.esp8266.com/ staging/package_esp8266com_index.json.Estecontienenuevascaracterísticas,peroalamismavezalgo puedenofuncionar. ParamasinformaciónsobreelGestordeTarjetas,ver: https://www.arduino.cc/es/guide/cores 1 ESP8266ArduinoCoreDocumentation,Versión2.4.0 1.2 Usando la versión git Estaeslainstalaciónsugeridaparacontribuidoresydesarrolladoresdelibrerías. 1.2.1 Prerequisitos Arduino1.6.8(omasmoderno,versiónactualfuncionando1.8.5) git Python_2.7(http://python.org) terminal,console,ointerpretedecomandos(dependiendodetuOS) ConexiónaInternet 1.2.2 Instrucciones - Windows 10 Primero,asegúresedequenotienelabibliotecaESP8266instaladaconelGestordeTarjetas(verarriba) InstalagitparaWindows(sinolotieneya;verhttps://git-scm.com/download/win) AbreunterminalyvealdirectoriodeArduinopordefecto.Estesuelesertudirectoriosketchbook(normalmen- teC:\users\{username}\Documents\Arduino),lavariabledeentorno%USERPROFILE%normal- mentecontieneC:\users\{username}). Clonaesterepositorioaldirectoriohardware/esp8266com/esp8266. cd %USERPROFILE%\Documents\Arduino\ if not exist hardware mkdir hardware cd hardware if not exist esp8266com mkdir esp8266com cd esp8266com git clone https://github.com/esp8266/Arduino.git esp8266 Deberías acabar con la siguiente estructura de directorios en C:\Users\{your username}\Documents\: Arduino | --- hardware | --- esp8266com | --- esp8266 | --- bootloaders --- cores --- doc --- libraries --- package --- tests --- tools --- variants --- platform.txt --- programmers.txt --- README.md (continuéenlapróximapágina) 2 Capítulo1. Instalación ESP8266ArduinoCoreDocumentation,Versión2.4.0 (provienedelapáginaanterior) --- boards.txt --- LICENSE Inicialicelossubmodulos cd %USERPROFILE%\Documents\hardware\esp8266com\esp8266 git submodule update --init SitienemensajesdeerrorsobrearchivosfaltantesrelacionadosconSoftwareSerialduranteelprocesode compilación,debeserporqueomitióestepasoyesnecesario. Descargalasherramientasbinarias: cd esp8266/tools python get.py ReiniciaArduino. Si utiliza el IDE de Arduino para Visual Studio (https://www.visualmicro.com/), asegúrese de hacer clic en Herramientas-VisualMicro-Volveraanalizarlascadenasdeherramientasylasbibliotecas Cuandoactualicemástardesubibliotecalocal,vayaaldirectorioesp8266yhagaungitpull: cd %USERPROFILE%\Documents\hardware\esp8266com\esp8266 git status git pull Tengaencuentaquepodría,enteoría,instalarenC:\Archivos de programa (x86)\Arduino\hardware sinembargo,estotieneimplicacionesdeseguridad,pornomencionarqueeldirectorioamenudosepierdealreinstalar el IDE de Arduino. Tiene la ventaja (o el inconveniente, según su perspectiva) de estar disponible para todos los usuariosensuPCqueutilizanArduino. 1.2.3 Instrucciones - Otros Sistemas Operativos Abra un terminal y ve al directorio de Arduino. Este puede ser su directorio sketchbook (normalmente <Documents>/Arduino),oeldirectoriodeinstalacióndeArduinomismamente,estuelección. Clona este repositorio al directorio hardware/esp8266com/esp8266. Alternativamente, clonalo en otro lugar y creaunenlacesimbólico,situsistemaoperativoloadmite. cd hardware mkdir esp8266com cd esp8266com git clone https://github.com/esp8266/Arduino.git esp8266 Deberíasacabarconlasiguienteestructuradedirectorios: Arduino | --- hardware | --- esp8266com | --- esp8266 | --- bootloaders (continuéenlapróximapágina) 1.2. Usandolaversióngit 3 ESP8266ArduinoCoreDocumentation,Versión2.4.0 (provienedelapáginaanterior) --- cores --- doc --- libraries --- package --- tests --- tools --- variants --- platform.txt --- programmers.txt --- README.md --- boards.txt --- LICENSE Inicialicelossubmodulos cd %USERPROFILE%\Documents\hardware\esp8266com\esp8266 git submodule update --init SitienemensajesdeerrorsobrearchivosfaltantesrelacionadosconSoftwareSerialduranteelprocesode compilación,debeserporqueomitióestepasoyesnecesario. Descargalasherramientasbinarias: cd esp8266/tools python get.py ReiniciaArduino. Cuandoactualicemástardesubibliotecalocal,vayaaldirectorioesp8266yhagaungitpull: cd hardware\esp8266com\esp8266 git status git pull 4 Capítulo1. Instalación