     tiltMsg.concat(tiltState);
 //    tiltMsg.concat(",");
 //    tiltMsg.concat(time);
-    char message_buff[tiltMsg.length()];//TODO test that length() does not need +1 !!!!!!!!!!!!!
+    char message_buff[30];
     tiltMsg.toCharArray(message_buff, tiltMsg.length()+1);
     //send tilt state to the tilt queue
-    boolean result = client.publish("arduino-tilt-exchange", message_buff);
-    Serial.print("DEBUG :: Result of tilt sensor push is : ");
-    Serial.println(result);
+    client.publish("arduino-tilt-exchange", message_buff);
 //  }
   
+}
+
+void connectToMQTT() {
+    Serial.println("INFO :: Connecting to RabbitMQ");
+    if (client.connect(clientName, user, pwd)) {
+      Serial.println("INFO :: Connected to RabbitMQ");
+    } else {
+      Serial.println("ERROR :: Failed to Connect to RabbitMQ");
+    }
 }
 
 void publishTempHumMsg(String temp, String humidity) {

#define MODE_ON     1  // not sensing light, LED on
#define MODE_SENSE  2  // sensing light, LED controlled by software
int senseMode = 0;
//char message_buff[100];

WiFiClient wifiClient;
//setup MQTT
PubSubClient client(serverRabbit, port, callback, wifiClient);
  
void setup() {
  // initialize serial and wait for the port to open:
  Serial.begin(9600);
  while (!Serial);
  connectToWifi();
  // set the LED pins as outputs
  // the for() loop saves some extra coding
  for (int pinNumber = 2; pinNumber < 5; pinNumber++) {


void loop() {
  Serial.println("DEBUG :: loop()");
  float tempVar = readTemperature();
  float humVar = getDHT11HumidityReadings();
  char temp[10];
  char humidity[10];
  dtostrf(tempVar, 2, 2, temp);
  dtostrf(humVar, 2, 2, humidity);
  Serial.print("DEBUG :: Temp value return is : ");
  Serial.println(temp);
  Serial.print("DEBUG :: Humidity value return is : ");
  Serial.println(humidity);
  publishTempHumMsg(temp, humidity);
  checkTiltState();
  // MQTT client loop processing
  client.loop();
}

void checkTiltState() {
