0 votes
in ESPaper by (440 points)
I received my 2.9″ ESPaper Plus Kit, very nice.  Uploaded code works; however, charged percentage never exceeds 76%.  I've confirmed 100% battery by removing LiPo from device and charging with an external hobby charger.  

How do I fix display to say 100% charge?

Libraries used:
Mini Grafx 0.0.14
ESP8266 Weather Station 1.3.2
Json Streaming Parser 1.0.5
SimpleDSTadjust 1.2.0

1 Answer

+1 vote
by (10.0k points)
Hi Cheerlights

Yes, this is a bug in the current code. The values here have to be adjusted: https://github.com/squix78/espaper-weatherstation/blob/master/espaper-weatherstation.ino#L380

I hopefully will get to fix that in the next days, but if you cannot wait then please charge your battery full and then adjust the numbers until you get a 100%

Daniel
by (440 points)
Daniel,

Thanks for getting back to me.  I used the following values to get 100% battery.  Not sure if it's correct.  See below.

void drawBattery() {
  uint8_t percentage = 100;
  float power = analogRead(A0) * 4.2 / 1024.0;
  if (power > 3.8) percentage = 100;                               
  else if (power < 3.0) percentage = 0;
  else percentage = (power - 3.0) * 100 / (3.9 - 3.0);
by (100 points)
Agree I noticed this as well after adding my Lipo. I verified the charge circuit and battery voltage with an external LiPo charger and seems to be fully charged (4.20 V).
by (100 points)
Is there schematics for the 2.9" PCB design and specifically the ADC input? I have 100% showing up on afull charge but the reading of the 4.2V does not appear to be scaled properly on the ADC input. Would like to understand the divider values chosen and how it's wired. I could reverse engineer the board but thought I better ask first.
by (440 points)
Has anyone gotten this to read correctly?
by (10.0k points)
I'm currently using this function and it looks pretty good:

void drawBattery() {
  uint8_t percentage = 100;
  float adcVoltage = analogRead(A0) / 1024.0;
  // This values where empirically collected
  float batteryVoltage = adcVoltage * 4.945945946 -0.3957657658;
  if (batteryVoltage > 4.2) percentage = 100;
  else if (batteryVoltage < 3.3) percentage = 0;
  else percentage = (batteryVoltage - 3.3) * 100 / (4.2 - 3.3);

  gfx.setColor(MINI_BLACK);
  gfx.setFont(ArialMT_Plain_10);
  gfx.setTextAlignment(TEXT_ALIGN_RIGHT);
  gfx.drawString(SCREEN_WIDTH - 22, -1, String(batteryVoltage, 2) + "V " + String(percentage) + "%");
  gfx.drawRect(SCREEN_WIDTH - 22, 0, 19, 10);
  gfx.fillRect(SCREEN_WIDTH - 2, 2, 2, 6);
  gfx.fillRect(SCREEN_WIDTH - 20, 2, 16 * percentage / 100, 6);
}
by (440 points)
Squi78,

My battery now reads 100%.

Looks good, thank you so much!
by (320 points)
I updated my ESPaper with the new drawBattery code. After the charging light goes off, mine show 4.12v 93%.
by (100 points)
It will depend upon many factors. I asked above for the schematics so I could calculate the value based on the resistor divider settings going into the ADC input. I ended up just hacking around the lack of info and determined that 4.57 for my setup worked out to be about 4.2V when the battery was fully charged. This value may differ depending upon the tolerance of the resistors used on the board. If 1% precision parts were not called out then this value will likely change per individual board. Recall that in hardware the ADC only has a 1V maximum input range. Hardware designers will scale the measured voltage down into the range. In this case a simple voltage divider with resistors was likely used.  Anyway here is how I fixed mine. See below.

// void drawBattery() {
   uint8_t percentage = 100;
   float power = analogRead(A0) * 4.57 / 1024.0;  // 4.57 had to be played with to find 4.2V when fully charged.
   if (power > 4.18) percentage = 100;
   else if (power < 3.0) percentage = 0;
   else percentage = (power - 3.0) * 100 / (4.18-3.0);

Welcome to ThingPulse Q&A, where you can ask questions and receive answers from other members of the community.

https://thingpulse.com

...