Hello All,
I have been trying to establish some building blocks for my weather station. I have a nuelectronics style Ethernet card. I actually got it from ekitszone, but I believe it is the same as all the code example etc work from nuelectronics.
I am using the libraries from http://openenergymonitor.org/emon/node/80.
I have managed to get a pachube feed to update, but am struggling with getting wunderground to update.
The address to update via is in this format.
I have tested the url in the code, it works fine. I have also tried GET, POST & PUT. I have also tried with and without the IP in the URL.
My code is below, would someone mind telling me where I am going wrong? Please!
#include "etherShield.h"
#include "NUClient.h"
/*
http://wiki.wunderground.com/index.php/PWS_-_Upload_Protocol
http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID=IESUSSEX2&PASSWORD=******&tempf=50&softwaretype=xAP&action=updateraw
http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID=IESUSSEX2&PASSWORD=******&dateutc=2011-03-13%2017:39:00&tempf=50&softwaretype=xAP&action=updateraw
*/
#define WU_STATION_ID "IESUSSEX2"
#define WU_PASSWORD "******"
byte mac[] = { 0x54,0x55,0x58,0x10,0x00,0x26 };
byte ip[] = { 192, 168, 1, 15 };
byte gateway[] = { 192, 168, 1, 1 };
byte server[] = { 38, 102, 136, 104 }; //wunderground.com 38.102.136.104 , 125
int port = 80;
//Create a client
NUClient client(mac,ip,gateway,server,port);
int content_length;
void setup () {
Serial.begin(9600);
client.init();
//Useful for debugging
//Serial.print outputs of what the client is doing.
client.debug(0);
//If your having trouble with timeouts
//try different timeout times it may sort it.
client.timeout(20,30);
}
void loop()
{
//Do things that need to be done even when
//the ethernet shield is connecting etc here.
//If the client has finished sending.
if (client.done)
{
//Increment values so that we can see something happening!
// valA += 1.2;
//Do things that only need to be done when
//the client has done sending.
delay(10000);
//Tell the client that it is not done and it needs to start sending again.
client.done=0;
Serial.println("start");
}
//client.process opens and closes the client connection
//It returns a one when the connection is at the data
//sending stage.
//client process will also check for pings
if(client.process()!=0)
{
Serial.println("data process");
//If your using a shared server you may need to include http://yourwebsite.org
//as below. If your server has a static ip its not needed.
client.print("PUT http://30.102.136.104/weatherstation/updateweatherstation.php?ID=IESUSSEX2&PASSWORD=******&dateutc=2011-03-14 19:05:00&tempf=55&softwaretype=Arduino&action=updateraw");
client.print(" HTTP/1.0\r\n");
client.print("Host: 38.102.136.104");
client.print("");
client.send();
Serial.println("data sent");
}
}
Many Thanks
Dan