 unsigned char canbus_tx_buffer[CANBUS_LENGTH];  // Buffer to store the incoming data
 
 // Objects
-OneWire oneWire(TEMP_ENGINE_PIN);
+OneWire oneWire(TEMP_SENSOR_PIN);
 DallasTemperature ds18b20(&oneWire);
-DHT dht(DHT_PIN, DHT_TYPE);
 RunningMedian temperature_history = RunningMedian(SAMPLES);
 RunningMedian moisture_history = RunningMedian(SAMPLES);
 

  // Initialize USB
  Serial.begin(BAUD);
  delay(10);

  // Initialise MCP2515 CAN controller at the specified speed
  int canbus_attempts = 0;
  while (!canbus_status) {
    canbus_status = Canbus.init(CANSPEED_500);
    delay(10);
  }

  // Sensors
  ds18b20.begin();

  // Relays
  pinMode(FAN_RELAY_PIN, OUTPUT);
  digitalWrite(FAN_RELAY_PIN, fan_off);

}

/* --- Loop --- */
void loop() {

  // Check Temperature Sensor and Set Cooling Fan (Dual Threshold Method)
  for (int i = 0; i < SAMPLES; i++) {
    ds18b20.requestTemperatures();
    temperature_history.add(ds18b20.getTempCByIndex(0));
  }
  temperature_pv = int(temperature_history.getAverage());
  internal_humidity = dht.readHumidity();
  internal_temperature = dht.readTemperature();

  // Check CANBus
  if (canbus_status) {

    // Check CANBUS
    unsigned int UID = Canbus.message_rx(canbus_rx_buffer); // Check to see if we have a message on the Bus

    // Check ODB via CAN
    if (UID != 0) {
      // Read from network
      StaticJsonBuffer<JSON_LENGTH> json_buffer;
      JsonObject& root = json_buffer.createObject();
    }
  }

  // Print Data to JSON Buffer
  StaticJsonBuffer<JSON_LENGTH> json_buffer;
  JsonObject& root = json_buffer.createObject();
  root["temp"] = temperature_pv;
  root.printTo(data_buffer, sizeof(data_buffer));
  int chksum = checksum(data_buffer);
  sprintf(output_buffer, "{\"data\":%s,\"chksum\":%d}", data_buffer, chksum);
  Serial.println(output_buffer);

  // Wait
  delay(UPDATE_INTERVAL);

}

/* --- Functions --- */

const unsigned int UPDATE_INTERVAL = 15000;
const unsigned int DIGITS = 2;
const unsigned int PRECISION = 2;

/* --- Variables --- */
int chksum;
bool canbus_status = 0;
bool pump_off = false;
bool fan_off = false;
bool irrigation_required = false;
bool cooling_required = false;
int moisture_sp_low = 30;
int moisture_sp_high = 60;
int temperature_sp_low = 25;
int temperature_sp_high = 35;
int temperature_pv = 0;
int volts_a = 1024;
int volts_b = 0;
int moisture_a = 0;
int moisture_b = 100;
int moisture_pv = 0;

// Buffers
char output_buffer[OUTPUT_LENGTH];
