 }
 
 void buildPayload() {
+  battery = readVcc();
+  
   // Switch on DHT22
-  pinMode(27, OUTPUT);
-  digitalWrite(27, HIGH);
-
-  delay(1);
+  digitalWrite(DHT_VCC, HIGH);
+  delay(1000);
   DHT.read22(DHT22_PIN);
-  digitalWrite(27, LOW);
 
   temp_c = int16_t(DHT.temperature*100);
   humidity = int16_t(DHT.humidity*100);
-  battery = readVcc;
-
+  digitalWrite(DHT_VCC, LOW);
+
+  Serial.println(temp_c);
+  Serial.println(humidity);
+  Serial.println(battery);
 
   txBuffer[0] = byte(temp_c>>8);
   txBuffer[1] = byte(temp_c);

  result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000
  return result; // Vcc in millivolts
}


dht DHT;

#define DHT22_PIN 11
#define DHT_VCC 27

// LoRaWAN NwkSKey, network session key
static const u1_t NWKSKEY[16] = { 0xD4, 0x99, 0xE5, 0x84, 0x58, 0x24, 0x69, 0x17, 0xFD, 0x01, 0xFE, 0x8F, 0xBC, 0xA7, 0xDC, 0xA0 };

// LoRaWAN AppSKey, application session key
static const u1_t APPSKEY[16] = { 0x14, 0xEA, 0x44, 0x24, 0x13, 0x1E, 0xFF, 0x92, 0x30, 0x1C, 0x15, 0x6B, 0x75, 0x71, 0x5F, 0x05 };

// LoRaWAN end-device address (DevAddr)
static const u4_t DEVADDR = 0x2601186F;
