storca / ArdUnground

🌤 A library to update arduino weather stations on WeatherUnderground 🌤

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ArdUnground

Travis ci

ArdUnground is an arduino library that updates weather station data to WeatherUnderground or another rapidfire server.

Prerequisites

You need to have the Ethernet.h library installed (native arduino library).
See https://www.arduino.cc/en/Guide/Libraries for further information.

Reference and projects used for this library

Installation

Arduino IDE

Grab the latest release (ArdUnground[...].zip) here and extract the content in your arduino/libraries folder as usual.
See https://www.arduino.cc/en/Guide/Libraries for further information.

Contribution

In atom or vscode, run Crtl+Shift+P then search for 'git clone' and eter the git url https://github.com/storca/ArdUnground.git

Usage

First include the two libraries as follow :

#include <Ethernet.h>
#include <ArdUnground.h>

Declare a 'WeatherStation' object :

WeatherStation station("your station id", "your station password", "the station name");

/!\ The communications are made via http which means that your password may be intercepted /!\
Use a unique password for you weather station

Declare an 'EthernetClient' object:

EthernetClient client;

Set your 'client' object as usual

Some functions

Set the temperature to send in Farenheight :

WeatherStation.setTempF(float tempF);

Set the humidity to send in % :

WeatherStation.setHumidity(float humidity);

Set the dew point to send in Farenheight :

WeatherStation.setDewptf(int dewptf);

Set the wind direction to send in degrees :

WeatherStation.setWinddir(int windir);

Set the wind speed to send in mph :

WeatherStation.setWindspeedmph(int windspeedmph);

More functions to come here, this is just a draft of the library

Post the PWS data to WeatherUnderground : Where 'timestamp' is optional, it's "now" by default : the timestamp "now" will be interpreted as the current time (UTC+0) by the rapidfire server.
The content of the 'timestamp' variable will be url escaped automaticly, no need to do it.
See http://wiki.wunderground.com/index.php/PWS_-_Upload_Protocol_ for more information

WeatherStation.post(EthernetClient client, String timestamp = "now");

Full example

WeatherStation.ino

//Local directory
#include <ArdUnground.h>
//Native library
#include <Ethernet.h>

//Reference for Ethernet library : https://www.arduino.cc/en/Tutorial/WebClient
//Mac address for the ethernet client
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

//If the dhcp server fails
IPAddress ip(192, 168, 0, 177);

EthernetClient client;

WeatherStation station("id", "password", "Arduino Custom station");

void setup()
{
  Serial.begin(9600);

  if (!Ethernet.begin(mac))
  {
    Serial.println("Failed to configure Ethernet using DHCP");
    // try to congifure using IP address instead of DHCP:
    Ethernet.begin(mac, ip);
  }

  // give the Ethernet shield a second to initialize:
  Serial.println("connecting...");
  delay(1000);

	station.set("rtupdate.wunderground.com", "GET /weatherstation/updateweatherstation.php?");
  /*
   Not necessary, these values are set by default in ArdUnderground.h
   */
}

void loop()
{
	float temp = 67.65444; //In °F
  float humidity = 40.65; //In %
  /*
   * See http://wiki.wunderground.com/index.php/PWS_-_Upload_Protocol#GET_parameters
   * For further information about unities
   */

   station.setTempF(temp);
   station.setHumidity(humidity);
   /*
    * Set the temperature and humidity before posting it
    */

    station.post(client);
    /*
     * That's one way to do it
     * The second argument has a default value of "now"
     * When the timestamp has a value of "now" ; the server will produce a timestamp by itself
     * http://wiki.wunderground.com/index.php/PWS_-_Upload_Protocol#GET_parameters
     */
    station.post(client, "2001-01-01 10:32:35");
    /*
     * Another way to do it
     * Note : the timestamp will be url escaped later, no need to do it here
     */
}

About

🌤 A library to update arduino weather stations on WeatherUnderground 🌤

License:MIT License


Languages

Language:C++ 100.0%