       digitalWrite(4, LOW);
     }
   }
+
+#if DEBUG
+  Serial.println("connected");
+#endif
+  // Set current value to whatever the last reading was
+  datastreams[0].setFloat(batteryReadings[kReadingsPerReport-1].getFloat());
+  datastreams[1].setInt(chargingReadings[kReadingsPerReport-1].getInt());
+  datastreams[2].setInt(sensorReadings[kReadingsPerReport-1].getInt());
+  datastreams[3].setInt(freeMemReadings[kReadingsPerReport-1].getInt());
   
-  // Record what our battery level is now too  
-  // A4 is measuring the mid-point of a 100k/100k voltage divider
-  datastreams[0].setFloat(analogRead(A4)*2.0*3.3/1023.0);
-  // And whether or not we're charging
-  datastreams[1].setInt(analogRead(A5));
+  // Sort out the times FIXME!!!
+  for (int idx = 0; idx < kReadingsPerReport; idx++)
+  {
+    batteryReadings[idx].setTime(readingsTime);
+    chargingReadings[idx].setTime(readingsTime);
+    sensorReadings[idx].setTime(readingsTime);
+    freeMemReadings[idx].setTime(readingsTime);
+    readingsTime += kReadingInterval*60;
+  }
   
-  datastreams[2].setInt(aCount); 
-  
+#if DEBUG
+  Serial.println("putting data");
+  Serial.println(feed);
+#endif
   if (xivelyclient.put(feed, xivelyKey) < 0)
   {
     // Something went wrong

  }
}

void reportMovementCount(int aCount)
{
  GSM gsmAccess;     // include a 'true' parameter to enable debugging
  GPRS gprs;
  GSMClient client;
  XivelyClient xivelyclient(client);

  // connection state
  boolean notConnected = true;
  // After starting the modem with GSM.begin()

#include <SPI.h>
#include <GSM.h>
#include <HttpClient.h>
#include <Time.h>
#include <Xively.h>
#include <FreeMemory.h>

//============================================================
// IMPORTANT!
