 
 void loop()
 {
+  MaintainUptime();
+  
   // serial input
   ReadSerial();
   if (IsConnected) CheckCommandTimeout();
   if (driveEnabled) CheckDriveCommandTimeout();
-  UpdateVA();
+  ReadAmps();
+  DisplayVA();
   
   // motors
   if (motor_counter > 0) motor_counter--;
   if (motor_counter == 0) updateMotors();
 }
 
-void UpdateVA()
+void MaintainUptime()
+{
+  if (millis() % 1000 <= 500 && HalfSecond == 0)
+  {
+    NewSecond = 1;
+    HalfSecond = 1;
+  }
+
+  if (millis() % 1000 > 500) HalfSecond = 0;
+
+  if (NewSecond == 1)
+  {
+    uptimeSeconds++;
+    NewSecond = 0;
+  }
+} 
+
+//=======================================
+
+//          in-robot Volts/Amps measurment
+
+//=======================================
+
+void ReadAmps()
+{
+  unsigned long ampsTime = millis();
+  if (ampsTime < lastAmpsTime) lastAmpsTime = 0;
+  if (ampsTime - lastAmpsTime > AMPS_INTERVAL)
+  {
+    lastAmpsTime = ampsTime;
+    amps[ampsIndex] = int(ina219.getCurrent_mA()); 
+    ampsIndex++;
+    if (ampsIndex >= AMPS_SIZE)
+    {
+      ampsIndex = 0;
+      UpdateUAh();
+    }
+  }
+}
+
+int getAvgAmps()
+{
+  long ampsSum = 0;
+  for (int i = 0; i < AMPS_SIZE; i++) ampsSum += amps[i];
+  return int(ampsSum / AMPS_SIZE);
+}
+
+void UpdateUAh()
+{
+  int mA = getAvgAmps();
+  uAh += int(mA * 5 / 12);
+}
+
+void DisplayVA()
 {
   unsigned long tmTime = millis();
   if (tmTime < lastTmTime) lastTmTime = 0;

#include <TM1650.h>

#define LED_PIN 13
#define RC_RX_PIN 12
#define RC_TX_PIN 11
#define SSC_RX_PIN 10
#define SSC_TX_PIN 9
// power management //

  digitalWrite(MOTOR_ENABLE_PIN, LOW);
  digitalWrite(POWER_PIN, LOW);
  digitalWrite(MOTOR_DISABLE_PIN, LOW);
  motorPower(false);
  
  // TM1650 display setup
  Wire.begin();
