 char buffer[BUFFER_SIZE];
 
 long lastPeriod = -1;
+
+// dallas onewire configuration
+OneWire oneWire(DPIN_ONEWIRE);
+DallasTemperature oneWireSensors(&oneWire);
+DeviceAddress thermometerInside  = { 0x10, 0x9B, 0x96, 0x53, 0x02, 0x08, 0x00, 0xF0 };
+DeviceAddress thermometerOutside  = { 0x10, 0x74, 0x6C, 0x53, 0x02, 0x08, 0x00, 0xE6 };
+
+// container for sensor data
+SensorData sensorData;
+SensorThresholds sensorThresholds;
 
 
 /******************************************************************************

  Serial.println(VERSION);
  
  // radio initialization
  radio.Initialize(MYID, FREQUENCY, NETWORKID, 0);
  radio.Encrypt((byte*)KEY);
  sprintf(buffer, "Transmitting at %d Mhz...", FREQUENCY == RF12_433MHZ ? 433 : FREQUENCY== RF12_868MHZ ? 868 : 915);
  Serial.println(buffer);
  
  // define default sensor thresholds
  setup_sensor_thresholds();

/* -----------------------------------------------------------------------------
   Freezer Monitor
  
   Accepts item numbers from PS/2 connection and submits initiates an Item
   process via a RESTful web service.
 
   Circuit:
   * RFM12B attached to digital pins 10, 11, 12, 13
   * LDR sensor attached to analog pin 0
   * OneWire bus attached to digital pin 3
   * Hall Effect sensor attached to digital pin 7
   * Sensor Status LED attached to digital pin 8
   * RF Status LED attached to digital pin 9
 
   Created 19-JAN-2014 by Jon Brule
----------------------------------------------------------------------------- */

#include <RFM12B.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <TimerOne.h>

#define VERSION "v0.7"

#define MYID       2       // node ID used for this unit
#define NETWORKID  99
#define GATEWAYID  1
#define FREQUENCY  RF12_915MHZ //Match this with the version of your Moteino! (others: RF12_433MHZ, RF12_915MHZ)
#define KEY        "ABCDABCDABCDABCD"
#define ACK_TIME   50  // # of ms to wait for an ack
#define TRANSMITPERIOD 600 //transmit a packet to gateway so often (in ms)

#define SERIAL_BAUD      115200

#define BUFFER_SIZE  50
#define CMD_BOOT     0x10
#define CMD_READING  0x11

#define APIN_LDR        0  // data connection for photocell
#define DPIN_ONEWIRE    3  // data connection for the Dallas OneWire bus
#define DPIN_HALL       7  // data connection for hall effect
#define DPIN_SENSOR_LED 8
#define DPIN_RF_LED     9

struct SensorData {
  boolean available;
  unsigned int ldr;
  unsigned int hall;
  float tempInsideC;
  float tempOutsideC;
};

struct SensorThresholds {
  unsigned int light;
  unsigned int door;
  float minTempInsideC;
  float maxTempInsideC;
  float minTempOutsideC;
  float maxTempOutsideC;
};

// rfm12b radio
int interPacketDelay = 1000; //wait this many ms between sending packets
char input = 0;
RFM12B radio;
