An E-Ink Status Display - Battery Status

An E-Ink Status Display - Battery Status



The firebeetle 2 supports charging and being powered via a LiPo battery. This means it can be moved around and left without being plugged into a USB cable for extended periods of time. In addition the firebeetle also supports a deep sleep mode that reduces its power consumption hugely (one for a later post).

To get hold of the current battery voltage you can use a sensor in esphome :

sensor:
- platform: adc
  name: "Device Battery voltage"
  pin: GPIO34
  accuracy_decimals: 2
  update_interval: 60s
  attenuation: 12dB
  samples: 10
  id: device_battery_voltage
  filters:
    - multiply: 2.0

To calculate the minimum/maximum voltage supplied by the battery, I simply kept printing the current voltage to the e-ink screen until the screen stopped updating. A nice feature of e-ink is that it retains the last image.

So, for me, the max voltage for the battery was 4.16V, and the minimum voltage was 2.96V.

So to add a simple status line in my display showing the last time the display was updated and the current battery charge percentage, you can add the following code to the lambda section of the yaml :

lambda: |-
  // grab the current data/time and format it
  char time_string[30];
  time_t currTime = id(homeassistant_time).now().timestamp;
  strftime(time_string, sizeof(time_string), "%Y-%m-%d %H:%M",localtime(&currTime));

  float min_voltage=2.96; // min voltage I've seen with this battery
  float max_voltage=4.15; // max voltage I've seen with this battery
  float current_voltage=id(device_battery_voltage).state;
  float battery_percentage=100*((current_voltage-min_voltage)/(max_voltage-min_voltage));

  // simple limit mod in case of drift.
  if (battery_percentage>100)
    battery_percentage=100;
  else if (battery_percentage <0)
    battery_percentage=0;
  it.printf(x_loc, y_loc,id(tinyfont), "Last Update %s Charge %.0f %%",time_string,battery_percentage);

tinyfont is another font defined as per the previous example. It just has a smaller size as it’s for a status value.

Screen Shot Showing date/time and battery percentage