Hi - Building a DIY weather station and trying to upload weather data using an Adafruit ESP8266 Feather Huzzah. I think I have my code correct but it is not showing up online. I don't get any connection errors. Where am I going wrong?
#include <ESP8266WiFi.h>
#include <Arduino.h>
#include <Wire.h>
const char* ssid = "Robots";
const char* password = "xxxxxxx";
const int sleepTimeS = 180; //18000 for Half hour, 300 for 5 minutes etc.
//char server [] = "weatherstation.wunderground.com";
char server [] = "rtupdate.wunderground.com";
char WEBPAGE [] = "GET /weatherstation/updateweatherstation.php?";
char ID [] = "KNCRALEI304";
char PASSWORD [] = "xxxxxxx";
void setup()
{
Serial.begin(115200);
Serial.println("ESP8266 Weather 2");
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {
Serial.println("ESP8266 Weather 2 main loop");
//Get sensor data
float tempc = 29;
float tempf = (tempc * 9.0) / 5.0 + 32.0;
float humidity = 68;
//check sensor data
Serial.println(" ");
Serial.print("tempF= ");
Serial.print(tempf);
Serial.println(" *F");
Serial.print("tempC= ");
Serial.print(tempc);
Serial.println(" *C");
Serial.print("humidity= ");
Serial.println(humidity);
//Send data to Weather Underground
Serial.print("connecting to ");
Serial.println(server);
WiFiClient client;
if (!client.connect(server, 80)) {
Serial.println("Conection Fail");
return;
}
client.print(WEBPAGE);
client.print("ID=");
client.print(ID);
client.print("&PASSWORD=");
client.print(PASSWORD);
client.print("&dateutc=");
client.print("now");
client.print("&tempf=");
client.print(tempf);
client.print("&humidity=");
client.print(humidity);
client.print("&softwaretype=Arduino%20UNO%20version1&action=updateraw&realtime=1&rtfreq=2.5");
client.println();
delay(2500);
sleepMode();
}
void sleepMode() {
Serial.print(F("Sleeping..."));
ESP.deepSleep(sleepTimeS * 1000000);
}