tecnologicos:start
Diferencias
Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previa | ||
tecnologicos:start [2015/10/17 20:02] – [Integrado ADS1118] brolin | tecnologicos:start [2015/10/22 20:59] (actual) – borrado myepes | ||
---|---|---|---|
Línea 1: | Línea 1: | ||
- | ====== Elementos tecnológicos del proceso ====== | ||
- | ==== Conexión y Programación del ESP8266 ==== | ||
- | |||
- | Los pines del ESP8266 están mapeados así. {{http:// | ||
- | |||
- | Se usa un arduino uno para tomar de el los 3v3 voltios y así alimentar el ESP. Para programarlo por medio de un integrado FTDI se sigue el siguiente esquema | ||
- | |||
- | {{http:// | ||
- | |||
- | Para programar el ESP es necesario poner el gpio0 al tierra, solo para programarlo. Esto lo dice acá http:// | ||
- | |||
- | obtenido de http:// | ||
- | |||
- | Todo se hace a través del IDE de Arduino después de configurarlo como se explica arriba ((http:// | ||
- | |||
- | |||
- | |||
- | ==== Configuración del IDE ==== | ||
- | |||
- | === Usar IDE de Arduino para programar ESP8266 === | ||
- | |||
- | Fuente -> https:// | ||
- | |||
- | {{: | ||
- | |||
- | This project brings support for ESP8266 chip to the Arduino environment. It lets you write sketches using familiar Arduino functions and libraries, and run them directly on ESP8266, no external microcontroller required. | ||
- | |||
- | ESP8266 Arduino core comes with libraries to communicate over WiFi using TCP and UDP, set up HTTP, mDNS, SSDP, and DNS servers, do OTA updates, use a file system in flash memory, work with SD cards, servos, SPI and I2C peripherals. | ||
- | 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). | ||
- | |||
- | === Programación con esptool === | ||
- | |||
- | " | ||
- | |||
- | Repositorio de la herramienta de python esptool -> https:// | ||
- | |||
- | Guía para usar **esptool** para programar NodeMCU -> http:// | ||
- | |||
- | Existen otros firmwares como dice en este wiki http:// | ||
- | |||
- | === ESPressif AT firmware === | ||
- | |||
- | espressif es la empresa que creó el integrado, la versión que se prueba es **at_v0.20_on_SDKv0.9.3** | ||
- | |||
- | https:// | ||
- | |||
- | Se programa con esptool en las siguiente direcciones de la flash | ||
- | |||
- | < | ||
- | Please download these bins to the specified address. | ||
- | |||
- | Bin | ||
- | boot_v1.1.bin----------------> | ||
- | user1.bin--------------------> | ||
- | esp_init_data_default.bin----> | ||
- | blank.bin--------------------> | ||
- | </ | ||
- | |||
- | < | ||
- | esptool.py --port / | ||
- | </ | ||
- | |||
- | < | ||
- | Connecting... | ||
- | Erasing flash... | ||
- | Writing at 0x0007ec00... (100 %) | ||
- | Erasing flash... | ||
- | Writing at 0x00000400... (100 %) | ||
- | Erasing flash... | ||
- | Writing at 0x00036c00... (100 %) | ||
- | |||
- | Leaving... | ||
- | </ | ||
- | |||
- | |||
- | |||
- | ===== NodeMCU firmware ===== | ||
- | |||
- | Este firmware convierte el ESP en un intérprete de comando lua. Posee un API para acceder a las características del microcontrolador: | ||
- | |||
- | **API NodeMCU** http:// | ||
- | |||
- | * node module | ||
- | * file module | ||
- | * wifi module | ||
- | * wifi.sta module | ||
- | * wifi.ap module | ||
- | * timer module | ||
- | * GPIO module | ||
- | * PWM module | ||
- | * net module | ||
- | * net.server module | ||
- | * net.socket module | ||
- | * i2c module | ||
- | * adc module | ||
- | * uart module | ||
- | * onewire module | ||
- | * bit module | ||
- | * spi module | ||
- | * mqtt module | ||
- | * mqtt client module | ||
- | |||
- | permite alojar scripts dentro de un sistema de archivos basado en (SPI Flash File System)https:// | ||
- | |||
- | {{: | ||
- | |||
- | Se crea un firmware a la medida con -> http:// | ||
- | |||
- | Y se baja con | ||
- | |||
- | < | ||
- | esptool.py --port / | ||
- | </ | ||
- | |||
- | El nodeMCU ejecuta una vez arranca, el archivo llamado **init.lua** y desde este se puede llamar otros scripts. | ||
- | Se prueba una serie de scripts (sacados de acá http:// | ||
- | |||
- | Los archivos que se suben son: | ||
- | |||
- | **init.lua** | ||
- | < | ||
- | timeout = 30 -- seconds to wait for connect before going to AP mode | ||
- | |||
- | statuses = {[0]=" | ||
- | [1]=" | ||
- | [2]=" | ||
- | [3]=" | ||
- | [4]=" | ||
- | [5]=" | ||
- | [255]=" | ||
- | |||
- | checkCount = 0 | ||
- | function checkStatus() | ||
- | checkCount = checkCount + 1 | ||
- | local s=wifi.sta.status() | ||
- | print(" | ||
- | if(s==5) then -- successful connect | ||
- | launchApp() | ||
- | return | ||
- | elseif(s==2 or s==3 or s==4) then -- failed | ||
- | startServer() | ||
- | return | ||
- | end | ||
- | if(checkCount >= timeout) then | ||
- | startServer() | ||
- | return | ||
- | end | ||
- | end | ||
- | |||
- | function launchApp() | ||
- | cleanup() | ||
- | print(" | ||
- | local task = ' | ||
- | local f=file.open(task, | ||
- | if(f == nil) then | ||
- | print(' | ||
- | return | ||
- | end | ||
- | file.close() | ||
- | dofile(task) | ||
- | end | ||
- | |||
- | function startServer() | ||
- | lastStatus = statuses[wifi.sta.status()] | ||
- | cleanup() | ||
- | print(" | ||
- | dofile(' | ||
- | end | ||
- | |||
- | function cleanup() | ||
- | -- stop our alarm | ||
- | tmr.stop(0) | ||
- | -- nil out all global vars we used | ||
- | timeout = nil | ||
- | statuses = nil | ||
- | checkCount = nil | ||
- | -- nil out any functions we defined | ||
- | checkStatus = nil | ||
- | launchApp = nil | ||
- | startServer = nil | ||
- | cleanup = nil | ||
- | -- take out the trash | ||
- | collectgarbage() | ||
- | -- pause a few seconds to allow garbage to collect and free up heap | ||
- | tmr.delay(5000) | ||
- | end | ||
- | |||
- | -- make sure we are trying to connect as clients | ||
- | wifi.setmode(wifi.STATION) | ||
- | wifi.sta.autoconnect(1) | ||
- | |||
- | -- every second, check our status | ||
- | tmr.alarm(0, | ||
- | </ | ||
- | |||
- | **configServer.lua** | ||
- | |||
- | < | ||
- | dofile(" | ||
- | |||
- | apRefresh = 15 -- how many seconds between when we scan for updated AP info for the user | ||
- | currentAPs = {} | ||
- | |||
- | newssid = "" | ||
- | |||
- | function listAPs_callback(t) | ||
- | if(t==nil) then | ||
- | return | ||
- | end | ||
- | currentAPs = t | ||
- | end | ||
- | |||
- | function listAPs() | ||
- | wifi.sta.getap(listAPs_callback) | ||
- | end | ||
- | |||
- | function sendPage(conn) | ||
- | conn: | ||
- | conn: | ||
- | |||
- | if(lastStatus ~= nil) then | ||
- | conn: | ||
- | end | ||
- | |||
- | if(newssid ~= "" | ||
- | conn: | ||
- | end | ||
- | |||
- | conn: | ||
- | |||
- | for ap,v in pairs(currentAPs) do | ||
- | conn: | ||
- | end | ||
- | |||
- | conn: | ||
- | conn: | ||
- | conn: | ||
- | |||
- | end | ||
- | |||
- | function url_decode(str) | ||
- | local s = string.gsub (str, " | ||
- | s = string.gsub (s, " | ||
- | function(h) return string.char(tonumber(h, | ||
- | s = string.gsub (s, " | ||
- | return s | ||
- | end | ||
- | |||
- | function incoming_connection(conn, | ||
- | if (string.find(payload, | ||
- | print(" | ||
- | elseif (string.find(payload, | ||
- | print(" | ||
- | sendPage(conn) | ||
- | else | ||
- | print(" | ||
- | local blank, plStart = string.find(payload, | ||
- | if(plStart == nil) then | ||
- | return | ||
- | end | ||
- | payload = string.sub(payload, | ||
- | args={} | ||
- | args.passwd="" | ||
- | -- parse all POST args into the ' | ||
- | for k,v in string.gmatch(payload, | ||
- | args[k]=url_decode(v) | ||
- | end | ||
- | if(args.ssid ~= nil and args.ssid ~= "" | ||
- | print(" | ||
- | print(" | ||
- | newssid = args.ssid | ||
- | wifi.sta.config(args.ssid, | ||
- | end | ||
- | if(args.reboot ~= nil) then | ||
- | print(" | ||
- | conn: | ||
- | node.restart() | ||
- | end | ||
- | conn: | ||
- | conn: | ||
- | end | ||
- | end | ||
- | |||
- | -- start a periodic scan for other nearby APs | ||
- | tmr.alarm(0, | ||
- | listAPs() -- and do it once to start with | ||
- | |||
- | -- Now we set up the Web Server | ||
- | srv=net.createServer(net.TCP) | ||
- | srv: | ||
- | sock: | ||
- | sock: | ||
- | sock: | ||
- | end) | ||
- | end) | ||
- | </ | ||
- | |||
- | **configServerinit.lua** | ||
- | |||
- | < | ||
- | apNamePrefix = " | ||
- | |||
- | apNetConfig = {ip = " | ||
- | | ||
- | | ||
- | |||
- | -- Set up our Access Point with the proper name and settings | ||
- | local apName = apNamePrefix .. " | ||
- | print(" | ||
- | wifi.setmode(wifi.STATIONAP) | ||
- | local apSsidConfig = {} | ||
- | apSsidConfig.ssid = apName | ||
- | wifi.ap.config(apSsidConfig) | ||
- | wifi.ap.setip(apNetConfig) | ||
- | </ | ||
- | |||
- | ===== Conexión ESP-12 | ||
- | {{http:// | ||
- | |||
- | Explicación detallada del chip http:// | ||
- | |||
- | http:// | ||
- | |||
- | Las boards que se compraron tienen la posibilidad de agregarles directamente el regulador de voltaje de 3v3 entonces al pin VCC no le llega corriente si no tiene este pegado en la board. Los reguladores que compramos para protoboard son más grandes que los que deben ir ahí. (FIXME) | ||
- | |||
- | Así quedó montado en protoboard nuestro programador: | ||
- | |||
- | {{: | ||
- | |||
- | ===== Sensor DHT-11 con esp-12 ===== | ||
- | |||
- | La conexión del circuito es muy sencilla como se ve en la siguiente imagen (tomada de http:// | ||
- | |||
- | {{http:// | ||
- | |||
- | Si genera la imagen del firmware desde http:// | ||
- | |||
- | {{: | ||
- | |||
- | Como lo hicimos antes, " | ||
- | |||
- | < | ||
- | esptool.py --port / | ||
- | </ | ||
- | |||
- | El programa que lee los datos del sensor DHT-11 es el siguiente (adaptando este http:// | ||
- | |||
- | < | ||
- | PIN = 7 -- data pin | ||
- | humi=0 | ||
- | temp=0 | ||
- | id=0 | ||
- | |||
- | --load DHT module and read sensor | ||
- | function ReadDHT() | ||
- | id = id + 1 | ||
- | dht=require(" | ||
- | -- dht.read(PIN) | ||
- | status, | ||
- | if( status == dht.OK ) then | ||
- | -- Integer firmware using this example | ||
- | print( | ||
- | string.format( | ||
- | " | ||
- | temp, | ||
- | temp_decimial, | ||
- | humi, | ||
- | humi_decimial | ||
- | ) | ||
- | ) | ||
- | -- Float firmware using this example | ||
- | print(" | ||
- | print(" | ||
- | elseif( status == dht.ERROR_CHECKSUM ) then | ||
- | print( "DHT Checksum error." | ||
- | elseif( status == dht.ERROR_TIMEOUT ) then | ||
- | print( "DHT Time out." ); | ||
- | end | ||
- | -- release module | ||
- | dht=nil | ||
- | package.loaded[" | ||
- | end | ||
- | -- send to https:// | ||
- | function sendTS(humi, | ||
- | local sensorId = " | ||
- | local json = ' | ||
- | conn = nil | ||
- | conn = net.createConnection(net.TCP, | ||
- | conn: | ||
- | conn: | ||
- | | ||
- | | ||
- | | ||
- | |||
- | -- Add the Application key to the header we send in the post request. | ||
- | .." | ||
- | .." | ||
- | |||
- | -- Add the length of the string we send. | ||
- | .." | ||
- | .." | ||
- | |||
- | -- Add the JSON string to the post object. | ||
- | ..json)end) | ||
- | |||
- | conn: | ||
- | conn: | ||
- | end | ||
- | ReadDHT() | ||
- | sendTS(humi, | ||
- | tmr.alarm(1, | ||
- | </ | ||
- | |||
- | En la primera línea del código se establece el pin a través del cual voy a leer los datos del sensor. El mapeo de pines de **nodeMCU** corresponde a los pines físicos de la tarjeta ESP-8266 según la siguiente tabla: | ||
- | |||
- | ^ IO index ^ ESP8266 pin^ | ||
- | | 0 [*] | ||
- | | 1 | ||
- | | 2 | ||
- | | 3 | ||
- | | 4 | ||
- | | 5 | ||
- | | 6 | ||
- | | 7 | ||
- | | 8 | ||
- | | 9 | ||
- | | 10 |GPIO1 | ||
- | | 11 |GPIO9| | ||
- | | 12 |GPIO10| | ||
- | |||
- | |||
- | ===== Optimizar el consumo de potencia ===== | ||
- | |||
- | Leer e implementar | ||
- | |||
- | https:// | ||
- | |||
- | https:// | ||
- | |||
- | ===== El ESP8266 ESP-12 solo tiene un pin ADC expuesto y el ESP-01 no tiene, ¿cómo leer sensores análogos entonces? | ||
- | |||
- | Agregando un ADC por funcione por i2c -> http:// | ||
- | |||
- | De este producto en tindie https:// | ||
- | |||
- | En una versión anterior usaron el chip de microchip MCP3021 https:// | ||
- | |||
- | Hay algunos diseños en github para el MCP3008 como https:// | ||
- | |||
- | * Acá hay muchos diseños de hardware interesantes para mirar https:// | ||
- | * Driver genérico i2c -> https:// | ||
- | * Explicación detallada de la arquitectura y algunas funcionalidades del ESP8266 -> https:// | ||
- | |||
- | ==== Integrado ADS1118 ==== | ||
- | |||
- | http:// | ||
- | |||
- | ==== Integrado ADS1115 ==== | ||
- | |||
- | http:// | ||
- | |||
- | ===== Comunicación SPI del ESP8266 ===== | ||
- | |||
- | http:// | ||
- | https:// | ||
- | https:// | ||
- | |||
- | ===== Introducción a los protocolos I2C y SPI ===== | ||
- | |||
- | http:// | ||
- | |||
- | New kid in the block http:// | ||
- | |||
- | |||
- | |||
- | ---- | ||
- | |||
- | ==== Construcción de sistemas completos ==== | ||
- | * IoTBox -> http:// | ||
- | * Weather Station -> http:// | ||
- | * ESP8266 MQTT battery monitor project -> http:// | ||
- | * Irrigation Controller -> http:// | ||
- | * Wifi internet relay -> http:// | ||
- | * ESP8266 + RaspberryPi -> http:// | ||
- | |||
- | |||
- | ---- | ||
- | |||
- | ===== Referentes ===== | ||
- | |||
- | *GardenBot -> http:// | ||
- | |||
- | *Wiki ESP -> http:// | ||
- | |||
- | * Pulsum Plantae, Leslie García \\ http:// | ||
- | |||
- | * https:// | ||
- | |||
- | Estas pagínas son plataformas IOT que corren en la web. | ||
- | |||
- | * IoT http:// | ||
- | |||
- | Esta herramienta provee una interfaz visual por nodos para interconectar dispositivos hardware . Esta construido en node.js y corre en servidores linux y Osx. | ||
- | |||
- | * IoT http:// | ||
- | |||
- | Kaa es una plataforma middleware para crear soluciones rapidas a IoT. | ||
- | Puedo entender en la descripción de la pagina que es muy customizable y puede manejar grandes datos de información. | ||
- | |||
- | * IoT http:// | ||
- | |||
- | Esta es una plataforma que le gusta trabajar con wordpress, zencart y otras plataformas abiertas. | ||
- | |||
- | * IoT http:// | ||
- | |||
- | Open Remote es otra solucion middleware para el internet de las cosas, aúnque provee algunos servicios que se compran por separado. | ||
- | |||
- | * IoT http:// | ||
- | |||
- | Contiki es un sistema operativo para el internet de las cosas, posee caracteristicas muy notables como full networking. | ||
- | |||
- | * IoT http:// | ||
- | * IoT https:// | ||
- | * IoT http:// | ||
- | * IoT http:// | ||
- | * IoT http:// | ||
- | * IoT https:// | ||
- | * IoT https:// | ||
- | * IoT http:// | ||
- | * IoT http:// | ||
- | |||
- | * IoT y ESP8266 http:// | ||
- | |||
- | * ESP8266 http:// | ||
- | * ESP8266 http:// | ||
- | * ESP8266 https:// | ||
- | * ESP8266 Comparación de las diferentes versiones del módulo http:// | ||
- | * ESP8266 http:// | ||
- | * FTDI http:// | ||
- | |||
- | * Arduino programming -> http:// | ||
- | * IoT.js a node.js for devices with limited resources -> http:// | ||
- | * IoT no paga las cuentas -> http:// | ||
- | |||
- | * ESP8266 community forum -> http:// | ||
- | ====== Otras páginas relacionadas ====== | ||
- | |||
- | * [[tecnologicos: | ||
- | * [[tecnologicos: |
tecnologicos/start.1445112151.txt.gz · Última modificación: 2015/10/17 20:02 por brolin