   Serial.print("\n");  
 }
 
-float scaleVoltage(float voltage) {
-  return ( voltage * 5 * (settings.r1 + settings.r2)) / ( settings.r2 * 1024 );
-}
-
-float scaleCurrent(float current) {
-  return ( current * 5000 / 1024  - settings.offset) / settings.sensitivity;
+long scaleVoltage(float value) {
+  long v_out = value * 5000 / 1024;
+  long output = (v_out * float(settings.r1 + settings.r2)) / settings.r2;
+  return (output > 0) ? output : 0;
+}
+
+long scaleCurrent(float value) {
+  long v_out = value * 5000 / 1024;
+  long output = (float(v_out - settings.offset) / settings.sensitivity) * 1000.0;
+  return (output > 0) ? output : 0;
 }
 
 void resetSleep(long value) {

  Serial.print(",");
  Serial.print(REVISION);
  Serial.print(",");
  Serial.print(VFinal,3);
  Serial.print(",");
  Serial.print(IFinal,3);
  Serial.print(",");
  Serial.print(VFinal * IFinal,3);
  Serial.print(",");
  Serial.print(digitalRead(RELAYPIN));
  Serial.print(",");

    else if (cmd == 'D') {
      settings.sensitivity = value;
    }
    else if (cmd == 'T') {
      long value = 0;
      for(long i = 0; i < 1000; i++) {
        value += analogRead(CURRENTPIN);
      }
      int v_out = value * 5.0 / 1024;
      Serial.print("@offset: ");
      Serial.println(v_out);
      settings.offset = int(v_out);
    }
    else if (cmd == 'S') {
      if (value > 0) {
        digitalWrite(RELAYPIN, HIGH);
