 #include <ESP8266WiFi.h>
+#include <Wire.h>
 
-String apiKey ="<YOUR-API-KEY>";
+String API_KEY ="<YOUR-API-KEY>";
 const char* MY_SSID = "<YOUR-SSID>"; 
 const char* MY_PWD = "<YOUR-PASSWORD>";
 
-const int pin_clk = 5;
-const int pin_soil = A0; 
-const int pin_led = 7;
-const char* server = "api.thingspeak.com";
+const int PIN_CLK = D5;
+const int PIN_SOIL = A0; 
+const int PIN_LED = D7;
+const char* SERVER = "api.thingspeak.com";
+const int TMP_ADDR = 0x48;
 
 int sent = 0;
 


void setup() {
  Serial.begin(115200);
  
  pinMode(pin_clk, OUTPUT);
  pinMode(pin_soil, INPUT);
  pinMode(pin_led, OUTPUT);
  digitalWrite(pin_led, LOW);
  
  analogWriteFreq(40000);
  analogWrite(pin_clk, 400);
  delay(500);
  connectWifi();
}

void loop() {
  //char buffer[10];
  digitalWrite(pin_led, HIGH);
  delay(500);
  digitalWrite(pin_led, LOW);
  float hum=0,temp=0,soil_hum=0;
  Serial.println("Requesting Temperature...");
  
  // Read temperature as Celsius (the default)
  // TODO
  temp = 25;

  delay(1000);
  soil_hum = readSoilVal(8);
  Serial.print("Soil_Humidity:");
  Serial.println(soil_hum);
  delay(1000);
  
  sendData(temp, soil_hum);
  //ESP.deepSleep(SLEEP_TIME, WAKE_RF_DEFAULT);
}


  int j = 0;

  for(i=0;i<n;i++){
    ValBuf[i] = analogRead(PIN_SOIL);
    Serial.println(ValBuf[i]);
  }

  for(i=0;i<n-1;i++){
