 	//ina219.setCalibration_16V_400mA();
 
 	Serial.println("Measuring voltage and current with INA219 ...");
+
+	lastSecond = millis();
 }
 
 void loop () {
-	float shuntvoltage_A = ina219_A.getShuntVoltage_mV();
-	float busvoltage_A = ina219_A.getBusVoltage_V();
-	float current_mA_A = ina219_A.getCurrent_mA();
+	//Print readings every second
+	if (millis() - lastSecond >= 10000)
+	{
 
-	float shuntvoltage_B = ina219_B.getShuntVoltage_mV();
-	float busvoltage_B = ina219_B.getBusVoltage_V();
-	float current_mA_B = ina219_B.getCurrent_mA();
+		lastSecond += 10000;
 
-//	// wake up the XBee
-//	pinMode(XBee_wake, OUTPUT);
-//	digitalWrite(XBee_wake, LOW);
-//	delay(ws_short_delay);
+		shuntvoltage_A = ina219_A.getShuntVoltage_mV();
+		busvoltage_A = ina219_A.getBusVoltage_V();
+		current_mA_A = ina219_A.getCurrent_mA();
 
-	Serial.print("$LOAD:");
-	Serial.print(counter);
-	Serial.print(":BusVolt:");
-	Serial.print(busvoltage_A);
-	Serial.println("V*");
+		// wake up the XBee
+		pinMode(XBee_wake, OUTPUT);
+		digitalWrite(XBee_wake, LOW);
 
-	Serial.print("$LOAD:");
-	Serial.print(counter);
-	Serial.print(":Current:");
-	Serial.print(current_mA_A);
-	Serial.println("mA*");
+		shuntvoltage_B = ina219_B.getShuntVoltage_mV();
+		busvoltage_B = ina219_B.getBusVoltage_V();
+		current_mA_B = ina219_B.getCurrent_mA();
 
-	float shuntvoltage_C = ina219_A.getShuntVoltage_mV();
-	float busvoltage_C = ina219_A.getBusVoltage_V();
-	float current_mA_C = ina219_A.getCurrent_mA();
+		Serial.print("$LOAD:");
+		Serial.print(counter);
+		Serial.print(":BusVolt:");
+		Serial.print(busvoltage_A);
+		Serial.println("V*");
 
-	Serial.print("$CHARGER:");
-	Serial.print(counter);
-	Serial.print(":BusVolt:");
-	Serial.print(busvoltage_B);
-	Serial.println("V*");
+		Serial.print("$LOAD:");
+		Serial.print(counter);
+		Serial.print(":Current:");
+		Serial.print(current_mA_A);
+		Serial.println("mA*");
 
-	Serial.print("$CHARGER:");
-	Serial.print(counter);
-	Serial.print(":Current:");
-	Serial.print(current_mA_B);
-	Serial.println("mA*");
+		shuntvoltage_C = ina219_A.getShuntVoltage_mV();
+		busvoltage_C = ina219_A.getBusVoltage_V();
+		current_mA_C = ina219_A.getCurrent_mA();
 
-	Serial.print("$LOADXB:");
-	Serial.print(counter);
-	Serial.print(":BusVolt:");
-	Serial.print(busvoltage_C);
-	Serial.println("V*");
+		Serial.print("$CHARGER:");
+		Serial.print(counter);
+		Serial.print(":BusVolt:");
+		Serial.print(busvoltage_B);
+		Serial.println("V*");
 
-	Serial.print("$LOADXB:");
-	Serial.print(counter);
-	Serial.print(":Current:");
-	Serial.print(current_mA_C);
-	Serial.println("mA*");
-	Serial.println("");
+		Serial.print("$CHARGER:");
+		Serial.print(counter);
+		Serial.print(":Current:");
+		Serial.print(current_mA_B);
+		Serial.println("mA*");
+
+		Serial.print("$LOADXB:");
+		Serial.print(counter);
+		Serial.print(":BusVolt:");
+		Serial.print(busvoltage_C);
+		Serial.println("V*");
+
+		Serial.print("$LOADXB:");
+		Serial.print(counter);
+		Serial.print(":Current:");
+		Serial.print(current_mA_C);
+		Serial.println("mA*");
+		Serial.println("");
+
+		// put the XBee to sleep
+		pinMode(XBee_wake, INPUT); // put pin in a high impedence state
+		digitalWrite(XBee_wake, HIGH);
 
 		counter++;
 		if (counter == 100)

			counter = 10;
		}

//	// put the XBee to sleep
//	pinMode(XBee_wake, INPUT); // put pin in a high impedence state
//	digitalWrite(XBee_wake, HIGH);

	LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
}

#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/wdt.h>
#include <avr/io.h>
#include <avr/interrupt.h>

#include <Wire.h>
#include "Adafruit_INA219.h"

Adafruit_INA219 ina219_A;
Adafruit_INA219 ina219_B(0x44);

int counter=10;

long lastSecond; //The millis counter to see when a second rolls by

const int XBee_wake = 9;

