Hi Guys , I have a problem that Its driving me nuts and im sure its simple but Im learning.
I have a Adafruit Huzzah (ide) and its receiving a Serial string, weather
( &dateutc=now$,tempF=73.74,windspeedmph=0.00,winddir=216,#&action=updateraw)
I need to read the serial string and send it to my PWS .. but im not sure on this String Arrays or posting
The right format, i know the string i need to post but if its "post" or "get" and if its Url or Server.. get ver confusing.
I have read alot but just cant get my head around it.. I have like half it going but after trying combos im lost.?
here is my code to date
I would appreciate any help in any way. Thanks . Les.
#include <ESP8266WiFi.h>
#include <SoftwareSerial.h>
SoftwareSerial SSoft (14, 12, false, 256); // rx, tx
String postStr;
const char* ssid = "ID";
const char* password = "XXXXXXX";
const char* WUID = "xxxxxxx";
const char* WUPASS = "xxxxxx";
char server [] = " http://rtupdate.wunderground.com/weatherstation/updateweatherstation.php?ID=xxxxxxxx&PASSWORD=xxxxxx";
WiFiClient client;
void setup() {
Serial.begin(9600);
delay(10);
SSoft.begin(9600);
WiFi.begin(ssid, password);
Serial.println();
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");
}
void loop() {
String postStr = (SSoft.readString());
postStr += "\r\n";
Serial.print( server + postStr);
if (client.connect(server,80)) {
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(String ("POST ") + server + "HTTP/1.1\r\n"+
"SSoft: " + postStr + "\r\n");
char c = client.read();
client.print("POST /update HTTP/1.1\n");
client.print("\n\n");
}
while(client.connected()) {
while (client.available()) {
char c = client.read();
Serial.write(c);
}
client.stop();
client.print("Connection: close\n");
Serial.println("Waiting…");
delay(2000);