I'm not familiar with this Client stuff and posting to a web site. I think this is a simple fix but I'm stuck! so close but so far .
I have a remote xbee sending a preformatted string to another xbee which is sending by serial to the Esp8266
This is Arduino ide programmed with this code below so it receives the serial and posts directly to wunderground as one update post. So all I need to do is join the serial incoming to the http and post as one.
But I'm lost ... any ideas guys.. I'm not even sure if this is even right.
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
const char* ssid = "kiwi";
const char* password = "1########";
///////////////Weather////////////////////////
char server [] = "rtupdate.wunderground.com";
char WEBPAGE [] = "GET /weatherstation/updateweatherstation.php";
char ID [] = "K#########";
char PASSWORD [] = "###########";
void setup() {
Serial.begin(9600);
delay(1000);
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
delay(500);
Serial.print(".");
}
void loop() {
if (WiFi.status() != WL_CONNECTED) {
Serial.println("[loop] no wifi");
delay(500);
} else {
Serial.println("[loop] WiFi connected");
Serial.print("[loop] IP address: ");
Serial.println(WiFi.localIP());
delay(500);
}
const uint16_t port = 80;
const char * host = "http://rtupdate.wunderground.com/weatherstation/updateweatherstation.php?ID=###################";
Serial.print("connecting to ");
Serial.println(host);
Serial.print("");
// Use WiFiClient class to create TCP connections
WiFiClient client;
if (!client.connect(host, port)) {
Serial.println("connection failed");
Serial.println("wait 5 sec...");
delay(5000);
return;
}
// This will send the request to the server
client.print(Serial);
//read back one line from server
String line = client.readStringUntil('\r');
client.println(line);
Serial.println("closing connection");
client.stop();
Serial.println("wait 5 sec...");
delay(5000);
}