   }
 }
 
-void temp_msg() {
-  /* cmdMessenger.sendCmd(kSTATUS, "Request for temperature received"); */
-  char temp[5];
-  itoa(temperatureToInt(temperature), temp, 10);
-  cmdMessenger.sendCmd(kTEMPERATURE, temp);
-}
+void setPIDonoff_msg() {
+  Serial << STATMSG << "Set PID on off msg received" << ENDMSG;
+  while (cmdMessenger.available()) {
+    char buf[350] = {'\0'};
+    cmdMessenger.copyString(buf, 350);
+    if (strncmp(buf, "1", 1) == 0) {
+      temperaturePID.SetMode(AUTOMATIC);
+    }
+    else {
+      temperaturePID.SetMode(MANUAL);
+    }
+  }
+}
+
+void getINOUTSET_msg() {
+  Serial << STATMSG << "Get Input Output Setpoint msg received" << ENDMSG;
+  Serial << INOUTSETMSG << temperature << "," << dutyCycle << "," \
+	 << setpoint << ENDMSG;
+}
+  
 
 void arduino_ready() {
   // In response to ping. We just send a throw-away ack to say "im alive"

  cmdMessenger.attach(5, temp_msg);
  cmdMessenger.attach(6, heater_msg);
  cmdMessenger.attach(7, setPIDonoff_msg);
  arduino_ready();
}

unsigned long currentMillis;
unsigned long previousMillis;
byte slowCount;
void loop () {
  currentMillis = millis();
  cmdMessenger.feedinSerialData();

    unsigned long onTime = intDutyCycle * (windowSize / 100);
    
    // Shift window time if  needed
    if (currentMillis - windowStartTime > windowSize)
      windowStartTime += windowSize;

    if (currentMillis - windowStartTime < onTime) {
      heaterOn();
    }
    else {
