How Can An ESP8266 SSD1306 OLED/BME280 Sensor Weather Station Be Battery Operated?

Introduction

This post describes a work-in-progress project wherein the title question had to be answered first. The goal is to make a simple device that can be taken anywhere and does not need a power plug. Only the display is read: temperature, pressure, and humidity. No WIFI, no http server, no MQTT publisher. Most importantly, the battery life must be practical, that is, must last more than a few months if not longer.

This project is not one of the kits that can be found on the web that use the ESP8266 or ESP32. Rather an ESP8266 SOM is mounted to a custom board and used with the BME280 sensor and a 128×64 SSD1306 display both purchased on Amazon.

Modes of Operation: Possibilities

The obvious goal is to operate the device in the lowest power mode consistent with practical utility, that is, the user needs to see displayed a recent reading whenever desired. Since all of the parameters being measured change only slowly as the weather changes, the measurement does not need to be updated very often.

1. The ESP8266 makes a measurement, writes to the display, leaves the measurement in the display RAM so it remains visible continously, then enters deep sleep for a period to be determined. Upon wake up, the device reboots and repeats this cycle.

2. Display the updated measurement for limited time so user can read it, then blank the display RAM before deep sleeping for a short while. Repeat the cycle often enough to that the user need not wait very long for the next display of data.

3. Display the updated measurement for a limited time so user can read it, then blank the display RAM before deep sleeping indefinitely. To obtain a reading the user depresses momentarily a reset button and then the device wakes up and repeats the cycle.

4. Forget about using deep sleep. The device remains completely powered off until the user depresses a momentary ON pushbutton and keeps it depressed long enough for a reading to appear on the display. After all, wake up from deep sleep produces a device reboot which is not different from a power on reset.

    It shall be seen, based upon measurements and comparison to the ampacity of AA and AAA alkaline batteries, that only number 4 produces practical battery life.

    Before discussing the measurements and analysis it is worth discussing the hardware used and some top level description of the code.

    Hardware

    The custom board normally consists of the ESP8266, a 5 to 3.3 volt regulator, a filter capacitor, reset pushbutton, a two pin header for reset, USB male to connect to a 5 volt USB charger, and a 10 pin header that carries the UART pins, 3.3 v, ground, and the SDA and SCL pins needed in this application. Additionally there are some resistors that are required to carry out reset and flash functions. As seen in the image the 3.3 v regulator is instead put on a separate board and the connection between the two boards is cabled with terminals available so that an ammeter can be connected.

    ESP8266 board and power source.

    In deep sleep only the RTC timer operates and everything else is shut down (CPU and RAM, although supply voltage stays on and therefore power flows to the display and sensor). Upon wake up the 3.3 volts on GPIO16 is pulled to ground which in turn pulls to ground the 3.3 volts on RST through the 470 ohm connection. If GPIO16 were directly connected to RST like is described in the Espressif documents, normal reset by the on board pushbutton would not reset the device since the 3.3 volts on the GPIO16 pin would oppose it. Some authors suggest also using a Schottky diode here rather than a resistor.

    The display and sensor is breadboarded as shown in the next image.

    128×64 OLED display with pressure, temperature, humidity sensor.

    As mentioned at the beginning this project is a work-in-progress and the plan is to package all components with a AAA two cell battery holder.

    Software

    Program structure: i2c is initialized, a queue is created followed by the creation of a display task and a sensor task. Sensor data is sent to the queue and the display reads the queue and then displays the data. The call back function vApplicationIdleHook() is used to put the device in deep sleep when the two tasks each set a global flag that tells the idle task that the respective task is ready to be shutdown.

    SDK: This is an Espressif project that use the ESP8266-RTOS-SDK v3.4. Tool chain version esp-2020r3-49-gd5524c1. Compiler version 8.4.0.

    Device drivers: This project was originally built using esp-open-rtos and ESP-Open-SDK v0.0.1. To build in the newer ESP8266-RTOS-SDK it was found some effort was needed to find the correct device drivers. In any event the solution was as follows:

      Results

      There are essentially only three measurements that are relevant.

      1. The ESP8266 operating with its peripherals powered but with the display dark. ->36 mA

      2. The ESP8266 in deep sleep with its peripherals powered and the display is showing the last result. -> 4 mA.

      3. The ESP8266 in deep sleep with its peripherals powered but with the display dark. -> 0.8 mA.

      Analysis

      In order to analyze these results one needs to know the ampacity of typical alkaline AA and AAA batteries. More particularly one needs to know the ampacity at 1.25 volts under conditions of low current draw (a few tens of milliamperes). The ESP8266 can operate down to 2.5 volts before it quits and since there will be two cells in series one cannot draw down below 1.25 volts. For this purpose the datasheets for Duracell’s Coppertop AA and AAA alkaline batteries were referenced. The discharge curves for a constant 25 mA current draw was chosen to reasonably represent this application.

      It was estimated that the AA cell would provide about 1700 mAh and the AAA cell would provide about 750 mAh.

      Operation mode 1. In order to turn on and update the display the ESP8266 can do this in about 1 second (current consumption is 36 mA + 4 mA). Then suppose that the ESP8266 deep sleeps for one hour before an update (current consumption is 4 mA). Straightforward algebra shows the batteries last only 18 days for AA and 8 days for AAA. The steady 4 mA draw from the peripherals is the killer.

      Operation mode 2. Here the display is on for a limited time and then off while the ESP8266 deep sleeps. One might imagine a sequence such as: ESP8266 wakes up, turns on display and updates, then deep sleeps while the display is left on. Then the ESP8266 wakes up in order to turn off the display and goes back into deep sleep. This cycle repeats. A user will look at the device and find the display either on or off. If on, a reading is observed. If off, the user expects it to turn on fairly soon and waits. This scenario is mostly the display toggling between on and off while the ESP8266 is only on twice per cycle for perhaps one second each. For the user to be able to read all three values it is reason to assume the display must be on for perhaps a minimum of 10 seconds (current consumption is 4 mA). A reasonable off time for the display is perhaps 10 seconds (current consumption is 0.8 mA). One can find the average current consumption as follows: [ (36 +4)*1 + 4*10 + (36+0.8)*1 + 0.8*10 ] / 22 = 5.67 mA. This is way too much current! The AA cell will last only 13 days and the AAA will last 6 days.

      Operation mode 3 and 4. It should be obvious that deep sleep in mode 3 differs essentially in the use of the pushbutton that the user is required to operate as well as having a constant continuous current draw of 0.8 mA. In mode 3 the pushbutton is only momentarily depressed while in mode 4 the user keeps the button depressed while reading the display. For analysis one may assume the display is on for 10 seconds at least in each case. For mode 3 the ESP8266 is on for 1 second to turn on the display and update it, then deep sleeps for 10 seconds, then wakes for 1 second to turn off the display. The average consumed mAh of capacity is dependent upon how often the user reads the device. However, the 0.8 mAh continuous draw will limit the battery life to 90 days for the AA cell and 40 days for the AAA cell. While this is a significant improvement over modes 1 and 2, mode 4 operation will greatly exceed mode 3 battery life.

      Mode 4 analysis can be done by assuming the user holds the pushbutton depressed for typically 10 seconds on average when reading the device. Current draw will be (36 mA +4 mA) * 10 seconds = 400 mA-seconds = 0.11 mAh. With AA cells the user can do 10 second reads of the device for over 15,000 times and over 6000 times with AAA cells! The batteries can last for years in the typical case.

      One last note comparing mode 3 and mode 4. If the display is spending time in the off state and a user has to interact with the device via a pushbutton, it seems there is little offered to the user to consider mode 3.

      Conclusion

      The answer to the question in the title is a portable, battery operated weather station must be full off when not being read by a user and operated with a pushbutton to obtain a reading. Any other mode of operating it ranges from very poor battery life to a few months at most.

      You may also like...

      Leave a Reply

      Your email address will not be published. Required fields are marked *