 #define DHTPIN 2
 #define DHTTYPE DHT11
 
-char auth[] = "<AUTH-KEY>";
-
-SimpleTimer timer;
-
 DHT dht(DHTPIN, DHTTYPE);
 
-#define VPIN_HUMIDITY V1
-#define VPIN_TEMP V2
+#include "Adafruit_MQTT.h"
+#include "Adafruit_MQTT_Client.h"
+
+#define AIO_SERVER      "<MQTT-SERVER>"
+#define AIO_SERVERPORT  1883
+
+Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT);
+Adafruit_MQTT_Publish when = Adafruit_MQTT_Publish(&mqtt, "arduino/yun/time");
+Adafruit_MQTT_Publish humidity = Adafruit_MQTT_Publish(&mqtt, "arduino/yun/humidity");
+Adafruit_MQTT_Publish temperature = Adafruit_MQTT_Publish(&mqtt, "arduino/yun/temperature");
+Adafruit_MQTT_Publish heatIndex = Adafruit_MQTT_Publish(&mqtt, "arduino/yun/heatIndex");
 
 void setup()
 {
-  Serial.begin(9600);
   dht.begin();
   delay(10);
   Blynk.begin(auth);
+  Bridge.begin();
+
+  // run an initial date process. Should return:
+  // seconds since 1970-01-01 00:00:00 UTC.
+  if (!date.running()) {
+    date.begin("date");
+    date.addParameter("+%s");
+    date.run();
+  }
+
   // Setup a function to be called every second
-  timer.setInterval(10000L, sendUptime);
+  timer.setInterval(2000L, sendValues);
 }
 
-void sendUptime()
+void sendValues()
 {
   //Read the Temp and Humidity from DHT
   float h = dht.readHumidity();

  if (isnan(h) || isnan(t)) {
    return;
  }
  
  float hic = dht.computeHeatIndex(t, h, false);
  Blynk.virtualWrite(1, h);
  Blynk.virtualWrite(2, t);
  Blynk.virtualWrite(3, hic);
}

void loop()
{
  Blynk.run();
  timer.run();
}


#include <Process.h>
#include <Bridge.h>
#include <BridgeClient.h>

Process date;
int32_t whenTime;
int32_t lastTime = -1;
BridgeClient client;

#include <BlynkSimpleYun.h>

#define VPIN_HUMIDITY V1
#define VPIN_TEMP V2

char auth[] = "<AUTH-KEY>"; 

#include <SimpleTimer.h>

SimpleTimer timer;

#include <DHT.h>
#include <DHT_U.h>
