 MqttWrapper *mqtt;
 DHT *dht;
 
-void init_dht(DHT **dht, uint8_t pin, uint8_t dht_type);
-void read_dht(DHT *dht, float *temp, float *humid);
 
+
+void connect_wifi()
+{
+    WiFi.begin(ssid, pass);
+
+    int retries = 0;
+    while ((WiFi.status() != WL_CONNECTED))
+    {
+        Serial.print(".");
+        retries++;
+        delay(500);
+    }
+
+    Serial.println("WIFI CONNECTED ");
+}
 
 void callback(const MQTT::Publish& pub) {
     if (pub.payload_string() == "0") {


void setup() {
    Serial.begin(115200);
    delay(10);

    init_dht(&dht, DHTPIN, DHTTYPE);

    connect_wifi();

    mqtt = new MqttWrapper("128.199.104.122");
    mqtt->connect(callback);

void loop() {
    mqtt->loop();

    if (digitalRead(0) == LOW) {
        while(digitalRead(0) == LOW) { 
            mqtt->loop();
            yield(); 
        }
        mqtt->sync_pub(String("0"));
    }

}
