   fauxmo.onMessage(callback); //function call for fauxmo state check.
 
 
-  //------------TMP102 Setup----------------------------------------------------------
-  // Initialize sensor0 settings
-  // These settings are saved in the sensor, even if it loses power
-
-  // set the number of consecutive faults before triggering alarm.
-  // 0-3: 0:1 fault, 1:2 faults, 2:4 faults, 3:6 faults.
-  sensor0.setFault(3);  // Trigger alarm immediately
-
-  // set the polarity of the Alarm. (0:Active LOW, 1:Active HIGH).
-  sensor0.setAlertPolarity(1); // Active HIGH
-
-  // set the sensor in Comparator Mode (0) or Interrupt Mode (1).
-  sensor0.setAlertMode(0); // Comparator Mode.
-
-  // set the Conversion Rate (how quickly the sensor gets a new reading)
-  //0-3: 0:0.25Hz, 1:1Hz, 2:4Hz, 3:8Hz
-  sensor0.setConversionRate(2);
-
-  //set Extended Mode.
-  //0:12-bit Temperature(-55C to +128C) 1:13-bit Temperature(-55C to +150C)
-  sensor0.setExtendedMode(0);
-
-  //set T_HIGH, the upper limit to trigger the alert on
-  sensor0.setHighTempF(77.0);  // set T_HIGH in F
-  //sensor0.setHighTempC(29.4); // set T_HIGH in C
-
-  //set T_LOW, the lower limit to shut turn off the alert
-  sensor0.setLowTempF(76.0);  // set T_LOW in F
-  //sensor0.setLowTempC(26.67); // set T_LOW in C
+  //------------AM2301 Setup----------------------------------------------------------
+
   //----------------------------------------------------------------------------------
 
   //------------USB Serial Comms Setup -----------------------------------------------

  display.drawString(0, 16, "TIME:");
  display.drawString(45, 16, (timeString));
}
//UPDATE TEMP FUNCTION (SHITSHOW CODE, BUT IT WORKS)
//------------------------------------------------------------------------------------------------

void updateTemp() {

  float temperature;
  String stringVal = "";
  boolean alertPinState, alertRegisterState;

  // read temperature data and write to OLED screen
  temperature = sensor0.readTempF();
  //temperature = sensor0.readTempC();

  // convert temperature float to string
  stringVal += String(int(temperature)) + "." + String(getDecimal(temperature)); //combining both whole and decimal part in string with a fullstop between them
  //Serial.print("stringVal: ");Serial.println(stringVal);              //display string value

  char charVal[stringVal.length() + 1];                    //initialise character array to store the values
  stringVal.toCharArray(charVal, stringVal.length() + 1);  //passing the value of the string to the character array

  //Serial.print("charVal: ");
  for (uint8_t i = 0; i < sizeof(charVal); i++) //Serial.print(charVal[i]); //display character array

    display.setTextAlignment(TEXT_ALIGN_LEFT);
  display.setFont(ArialMT_Plain_16);
  display.drawString(0, 32, "TEMP:");
  display.drawString(80, 32, "F");
  display.drawString(48, 32, (stringVal));

  // Check for Alert
  alertPinState = digitalRead(alertPin); // read the Alert from pin
  alertRegisterState = sensor0.alert();   // read the Alert from register

  /*
    // Print temperature and alarm state
    Serial.print("Temperature: ");
    Serial.print(temperature);

    Serial.print("\tAlert Pin: ");
    Serial.print(alertPinState);

    Serial.print("\tAlert Register:  ");
    Serial.println(alertRegisterState);
  */
}
//function to extract decimal part of float (SUB ROUTINE OF TEMP UPDATE)
long getDecimal(float val)
{
  int intPart = int(val);
  long decPart = 10 * (val - intPart); //I am multiplying by 1000 assuming that the foat values will have a maximum of 3 decimal places.
  //Change to match the number of decimal places you need
  if (decPart > 0)return (decPart);       //return the decimal part of float number if it is available
  else if (decPart < 0)return ((-1) * decPart); //if negative, multiply by -1
  else if (decPart = 0)return (00);       //return 0 if decimal part of float number is not available
}
//FAUXMO CALLBACK FUNCTION add devices here
//------------------------------------------------------------------------------------------------
void callback(uint8_t device_id, const char * device_name, bool state) {

// LIBRARY INITIALIZATION
SSD1306  display(0x3c, I2C_SDA, I2C_SCL); // SSD1306 Pin Assignments
fauxmoESP fauxmo;                         // Initialize fauxmo
Adafruit_MCP23017 mcp;                    // Adafruit-MCP23017-Arduino-Library
WiFiUDP ntpUDP;                           // Initalize WifiUDP library

