     if( charging || discharging )
     {
         current_mA = ina219.getCurrent_mA();
+        if( discharging )
+        {
+            unsigned long currentTime = millis();
+            long elapsedTime = currentTime - lastMeassureTime;
+            if(elapsedTime < 0)
+            {
+                //TODO: handle overflow!
+            }
+            mAh += (current_mA * ((double)elapsedTime/1000.0)) / (60 * 60);
+            dtostrf(mAh, 8, 0, str_mAh);
+        }
     }
     else
     {

            {
                digitalWrite(3, LOW);
                discharging = true;
            }
        }
        if( voltage < 3.0 )
        {
            digitalWrite(3, HIGH);
            discharging = false;
        }

double current_mA = 0;
bool charging = false;
bool discharging = false;
bool discharged = false;

enum MODE_ENUM
{
