#Test Shield Battery LiPo for Wemos D1 Mini (voltage measurement and level of charge)

shield battery lipo wemos d1 mini resistor measure tension top

We continue our series of Shields presentation articles (expansion cards) for the ESP8266 Wemos D1 Mini. An essential shield for the realization of connected objects, models or micro-robotics is the Shield Battery. Sold less than €3 direct from china, it allows to power the Wemos D1 Mini using a rechargeable battery and to manage the recharging of it.

Unpacking the Shield Battery for Wemos D1 Mini

The Shield Battery LiPo is delivered in an anti-static pouch with a set of connectors (3 different types). The charging circuit is built around the TP5410 charger suitable for recharging LiPo batteries. The card is equipped with two connectors. The first connector is micro-USB (OTG). It recharges the battery from a 5 Volt power supply. You can use a charger or the USB port of a computer. The other connector is JST XH2-2.54mm. It allows to connect a LiPo battery (3.3V to 4.2V). The card is also equipped with a converter allowing to increase the voltage of 3.7V delivered by the battery up to 5 Volts.

Technical characteristics :

  • Charging voltage: nominal 5V (max 10V)
  • Load current: 0.5A by default. Solder the jumper J1 to increase to 1A (be careful, check the compatibility with the battery before any modification)
  • Supported Lithium Battery: 3.3 to 4.2V
  • Voltage converter up to 5V (max. 1A)
  • Battery connector in JST XH2-2.54mm
  • Micro-USB connector (OTG) for recharging (5V, max 10V)
  • Green LED: On when charging is complete
  • Red LED: lit during charging
  • Jumper J1: Increases the load current from 0.5A to 1A
All technical data given as an indication. They may vary from one manufacturer to another. Check the compatibility with your battery and charger before using the Shield Battery. Never exceed the maximum permissible voltage of the battery. Failure to observe the instructions may cause the battery to explode.

wemos battery shield circuit

Warning. The connector is different from the JST-PH usually used for LiPo battery charging modules

If the LiPo battery that you purchased is not equipped with the correct connector, you will need to replace it. You can easily find lots of cables with the connector JST XH2-2.54mm.

Welding and length adjustment of connectors

Free to everyone to optimize the stacking of shields on the Wemos D1 Mini. Here I soldered a long connector allowing to add other Shields over the Shield Battery.

Before welding the connectors, make sure to follow the continuity of the pins (TX in front of TX …) otherwise the Wemos will not work.

To properly weld the connectors, I advise you to position the connectors on a breadboard the time of the welding.

shield battery wemos d1 mini positionnement connecteur

Depending on the manufacturer (vendor), the connectors can really be far too long. So that the shields are not too far apart (which would be a shame), it is best to cut the legs of the connectors. For a precise cut, you can make a small guide with a sheet of paper. Mark the part to be cut with an indelible pen before cutting each pin with a cutting pliers. Here the pins measure 8mm.

shield wemos d1 mini decoupe pattes broches trop longues

A clean and compact stack is thus obtained.

shield battery empile sur wemos d1 mini

Measure the voltage and charge level of the LiPo battery

When developing connected objects running on battery, it is convenient to know the remaining level in order to predict the recharge (or replacement) of the latter. The Wemos D1 Mini is based on an ESP8266 (model ESP-12x), so it has an analog input that can be used to monitor the charge level of the battery. In the previous tutorial, we saw how to calculate the battery voltage theoretically using a divider bridge. Here we will use a simpler method.

It will be necessary to reduce the voltage delivered by the battery so as not to exceed the 3.3V admissible by the A / D converter. For this purpose, you can use a 1.5MΩ resistor, for example. Solder the resistance between the positive pin of the battery connector and the A0 pin of the Shield Battery.

shield battery lipo wemos d1 mini resistor measure tension shield battery lipo wemos d1 mini resistor measure tension top
Be careful not to overheat the components or make tin fuse on the tracks of the Shield. This operation voids all warranty

Then make several voltage readings with a multimeter by retrieving the level of the A / D converter. Here is for example the statement I made for a 3.7V LiPo battery with a capacity of 1100 mAh.

shield battery wemos d1 mini batterie lipo tension niveau convertisseur analogique a0

In general, a battery will discharge linearly under normal conditions of temperature and use. The easiest way to do this is to use the map function to link the level of the A/D converter to the associated physical quantity. Small point of detail, the map function does not support decimal numbers. The problem will be solved very easily by multiplying the voltages by 100, then dividing by 100 the voltage returned by the map function.

float getVoltage(){
  float raw = analogRead(A0);                      
  float volt = map(raw, 140, 227, 338, 511);             // Avec une résistance 1M5 - With a 1M5 resistor
  volt = volt / 100;
  Serial.print("A0 "); Serial.println(raw);
  Serial.print("Voltage "); Serial.println(volt);
  return volt;
}

It is also easy to determine the charge level of the battery. You can very easily determine the battery threshold that corresponds to a 100% charge depending on the battery used. You will undoubtedly notice an increase in voltage during recharging the recharge. It is therefore necessary to do some cleaning if the level exceeds 100%.

float getLevel(){
  float raw = analogRead(A0);
  int level = map(raw, 140, 227, 0, 100);                // Avec une résistance 1M5 - With a 1M5 resistor
  if ( level < 0 ) { level = 0; }
  if ( level > 100 ) { level = 100; }
  Serial.print("Level: "); Serial.println(level);
  return level;
}

This method will give you a pretty good idea of the level of charge of the battery. Be careful, it is more an indicator than a precise measurement.

    Subscribe to the weekly newsletter

    No spam and no other use will be made of your email. You can unsubscribe anytime.

    DIY Projects