Pages: [1]   Go Down
Author Topic: Posting to Weatherunderground (wunderground) via PHP  (Read 1569 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php?ID=KCASANFR5&PASSWORD=XXXXXX&dateutc=2000-01-01+10%3A32%3A35&winddir=230&windspeedmph=12&windgustmph=12&tempf=70&rainin=0&baromin=29.1&dewptf=68.2&humidity=90&weather=&clouds=&softwaretype=vws%20versionxx&action=updateraw

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!
Code:
#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
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 631
Posts: 50157
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Typically, the end of client data is indicated by outputting a blank line, using client.println(). You don't output any blank lines. Also, each type of data is output with a carriage return/linefeed following it (as done by println()).
Logged

New Jersey
Offline Offline
God Member
*****
Karma: 2
Posts: 535
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dan,

I'm interested in sending data to Weather Underground.  Did you ever get your code to work?
Logged

Pages: [1]   Go Up
Jump to: