meta data de esta página
Diferencias
Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previa | ||
electronica:esp8266:bateria [2017/04/19 23:52] – [Referencias] lc | electronica:esp8266:bateria [2023/01/18 14:36] (actual) – editor externo 127.0.0.1 | ||
---|---|---|---|
Línea 1: | Línea 1: | ||
{{tag> | {{tag> | ||
===== Ahorrar Baterías ===== | ===== Ahorrar Baterías ===== | ||
+ | Para reducir el consumo de nuestro esp8266 tenemos dos aproximaciones que lo hacen posible. La primera sería modificando el código de programación para que nuestro esp8266 entre en reposo y la segunda sería usando un micro controlador AtTiny13A para que active o desactive nuestro esp8266. | ||
+ | |||
+ | ^Características del deep-sleep ^ ^ | ||
+ | |WiFI|OFF| | ||
+ | |System Clock|OFF| | ||
+ | |RTC|ON| | ||
+ | |CPU|OFF| | ||
+ | |Consumo|~0.02mA| | ||
+ | |||
+ | <note warning> | ||
+ | |||
+ | El tiempo máximo que se puede especificar según las especificaciones del ESP8266 es de 4, | ||
+ | |||
+ | < | ||
+ | |||
+ | |||
+ | |||
+ | ==== Mediante programación ==== | ||
+ | |||
+ | Lo que hacemos es añadir a nuestro código una variable con el tiempo de reposo y llamamos a la función **ESP.deepSleep** | ||
+ | |||
+ | <sxh> | ||
+ | const int sleepTimeS = 10; | ||
+ | |||
+ | Dentro de setup() | ||
+ | |||
+ | Serial.println(" | ||
+ | ESP.deepSleep(sleepTimeS * 1000000); | ||
+ | </ | ||
+ | |||
+ | Un ejemplo completo sería | ||
+ | <sxh> | ||
+ | // Library | ||
+ | #include < | ||
+ | |||
+ | // WiFi settings | ||
+ | const char* ssid = " | ||
+ | const char* password = " | ||
+ | |||
+ | // Time to sleep (in seconds): | ||
+ | const int sleepTimeS = 10; | ||
+ | |||
+ | // Host | ||
+ | const char* host = " | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | |||
+ | // Serial | ||
+ | Serial.begin(115200); | ||
+ | Serial.println(" | ||
+ | | ||
+ | // Connect to WiFi | ||
+ | WiFi.begin(ssid, | ||
+ | while (WiFi.status() != WL_CONNECTED) { | ||
+ | delay(500); | ||
+ | Serial.print(" | ||
+ | } | ||
+ | Serial.println("" | ||
+ | Serial.println(" | ||
+ | | ||
+ | // Print the IP address | ||
+ | Serial.println(WiFi.localIP()); | ||
+ | |||
+ | // Logging data to cloud | ||
+ | Serial.print(" | ||
+ | Serial.println(host); | ||
+ | | ||
+ | // Use WiFiClient class to create TCP connections | ||
+ | WiFiClient client; | ||
+ | const int httpPort = 80; | ||
+ | if (!client.connect(host, | ||
+ | Serial.println(" | ||
+ | return; | ||
+ | } | ||
+ | | ||
+ | // This will send the request to the server | ||
+ | client.print(String(" | ||
+ | " | ||
+ | " | ||
+ | delay(10); | ||
+ | | ||
+ | // Read all the lines of the reply from server and print them to Serial | ||
+ | while(client.available()){ | ||
+ | String line = client.readStringUntil(' | ||
+ | Serial.print(line); | ||
+ | } | ||
+ | | ||
+ | Serial.println(); | ||
+ | Serial.println(" | ||
+ | |||
+ | // Sleep | ||
+ | Serial.println(" | ||
+ | ESP.deepSleep(sleepTimeS * 1000000); | ||
+ | | ||
+ | } | ||
+ | |||
+ | void loop() | ||
+ | { | ||
+ | |||
+ | } | ||
+ | </ | ||
+ | |||
+ | ==== Usando el AtTiny13A ===== | ||
+ | Se consigue reducir el consumo a .005mA durante el reposo. El circuito y el código fuente se encuentra en http:// | ||
+ | |||
+ | Para programa el microcontrolador http:// | ||
Línea 10: | Línea 117: | ||
* http:// | * http:// | ||
* https:// | * https:// | ||
+ | * http:// | ||
+ | * https:// |