 const int DOOR_CLOSED = LOW;   // Door closed when LOW
 const int DIO_OFFSET = 3;      // DIO is port num + 3
 
+// global variables
+int batt_loop_count = 99;      // Make high so we get data first time
+int has_lowbat = false;        // Start out assuming it's fine
 
 // Basic macro for debugging
 // Ideally change this to a function once I figure out how to accept anything


  tempc = get_temperature(temp_dev1);
  DEBUG_PRINT(tempc);
  payload[0] = int(tempc * 100);

  rf12_sleep(RF12_WAKEUP);
  rf12_sendNow(JEELINK_ID, &payload, sizeof payload);
  rf12_sendWait(2);

}


// Payload consists of 5 words:
// - Is battery low? (will be 1 if so)
// - Values from each of the 4 ports
void loop() {
  float tempc = 0;
  int door_status_4 = digitalRead(DIO4);
  word payload[5] = {0,0,0,0,0};

  // Update low battery every 30 minutes
  // TODO: Does this even save power?
  if (batt_loop_count >= 30) {
    has_lowbat = rf12_lowbat();
    batt_loop_count = 0;
  }
  else {
    batt_loop_count++;
  }

#ifdef DEBUG
  if (door_status_4 == DOOR_OPEN) {
