Posting to Wunderground.com via UNO/MEGA-2560

Greetings,
I would like to know if anyone else is using the UNO or MEGA for POSTING to:
“GET /weatherstation/updateweatherstation.php?” ?
I have been able to use the MEGA with an ADAFRUIT CC3000 WiFi BoB with some success and am wondering if anyone else has had some success . after random "posts’ the unit hangs for no known reason (i think it’s the CC3000 library hanging), so after FIVE loops i disconnect the CC3000 and reconnect to my router and start all over again.
My main thought is to simplify the “post” with all sensor data and text into one string to send it to wunderground so I can use the RAPID FIRE reporting. as i have it now it takes sometime to go line by line to send the data.
PART ONE of Full Code Below!
PART TWO NEXT POST
I am A learner, so be nice please :slight_smile:

/*************************************************** 
 * This is an example for the Adafruit CC3000 Wifi Breakout & Shield
 * 
 * Designed specifically to work with the Adafruit WiFi products:
 * ----> https://www.adafruit.com/products/1469
 * 
 * Adafruit invests time and resources providing this open source code, 
 * please support Adafruit and open-source hardware by purchasing 
 * products from Adafruit!
 * 
 * Written by Limor Fried & Kevin Townsend for Adafruit Industries.  
 * BSD license, all text above must be included in any redistribution
 ****************************************************/

/*
This example does a test of the TCP client capability:
 * Initialization
 * Optional: SSID scan
 * AP connection
 * DHCP printout
 * DNS lookup
 * Optional: Ping
 * Connect to website and print out webpage contents
 * Disconnect
 SmartConfig is still beta and kind of works but is not fully vetted!
 It might not work on all networks!
 */
#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <Wire.h>
#include <DHT.h>
#include <Adafruit_BMP085.h>
#include "RTClib.h"
//Pins 
#define led  12
#define anemometer  2         // Wind speed
//#define rainTip = 3;  // Digital 3, Receive the pulse from Rain HALL EFFECT sensor on pin 3/Interupt 1
#define ADAFRUIT_CC3000_IRQ   3  // MUST be an interrupt pin!
#define ADAFRUIT_CC3000_VBAT  5
#define ADAFRUIT_CC3000_CS    10
#define DHTPIN  A0            // DHT 22  (AM2302)
#define winDir  A2            // Wind direction
#define WLAN_SECURITY   WLAN_SEC_WPA2
#define IDLE_TIMEOUT_MS  3000      // Amount of time to wait (in milliseconds) with no data 
#define period  5000          // Measurement period (miliseconds)
#define Wait  5000          // Amount of Time to wait till Re-connecting
#define WLAN_SSID       "XXXXXXXXXXX"           // cannot be longer than 32 characters!
#define WLAN_PASS       "XXXXXXXXX"
#define ID              "KFLFORTM63" //wunderground station
#define PASSWORD        "XXXXXX"
//#define WEBSITE      "rtupdate.wunderground.com"// RapidFire Server 2.5 sec interval
#define WEBSITE      "weatherstation.wunderground.com"//standard server
#define WEBPAGE      "GET /weatherstation/updateweatherstation.php?"
#define DHTTYPE DHT22             // DHT 22  (AM2302)
Adafruit_CC3000 cc3000 = Adafruit_CC3000(ADAFRUIT_CC3000_CS, ADAFRUIT_CC3000_IRQ, ADAFRUIT_CC3000_VBAT,
SPI_CLOCK_DIV2); // you can change this clock speed
DHT dht(DHTPIN, DHTTYPE);         // DHT 22  (AM2302)
Adafruit_BMP085 bmp;              // BMP Sensor

RTC_DS1307 rtc;
const float pi = 3.14159265;      // pi, not apple, not pumpkin, not pizza, not even related to Raspberry Pi. http://www.raspberrypi.org/ This is the REAL PI for Wind speed calculations
//int period = 5000;          // Measurement period (miliseconds)
//int Wait = 5000;          // Amount of Time to wait till Re-connecting
const int radio = 65;             // Radius from vertical anemometer axis to a cup center (mm)
unsigned int counter = 0;         // pulse count for wind sensor 
unsigned int RPM = 0;             // Revolutions per minute
unsigned int Sample = 0;          // Sample number
//unsigned int timesConnected = 0;  // WiFi conections
float speedwind = 0 / 0.445 ;      // Wind speed (m/s)
float winddir = 0;         // Wind direction

//---DEWPOINT
double dewPoint(double tempf, double Humi)
{
  double A0= 373.15/(273.15 + tempf);
  double SUM = -7.90298 * (A0-1);
  SUM += 5.02808 * log10(A0);
  SUM += -1.3816e-7 * (pow(10, (11.344*(1-1/A0)))-1) ;
  SUM += 8.1328e-3 * (pow(10,(-3.49149*(A0-1)))-1) ;
  SUM += log10(1013.246);
  double VP = pow(10, SUM-3) * Humi;
  double T = log(VP/0.61078);   // temp var
  return (241.88 * T) / (17.558-T);
}
//---DEWPOINT

uint32_t ip;
void setup(void)
{  
  Serial.begin(115200);
  pinMode(led, OUTPUT);
 digitalWrite(led, LOW); 
  bmp.begin();
  Wire.begin();
  
  pinMode(anemometer, INPUT);
  digitalWrite(anemometer, HIGH);
  rtc.begin();
  //rtc.adjust(DateTime(__DATE__, __TIME__));
  Serial.println(F("CC3000 Wunderground Test!\n")); 
  dht.begin();// Connect the DHT22 sensor
  Serial.println(F("\nInitializing..."));
  if (!cc3000.begin())
  {
   // Serial.println(F("Couldn't begin()! Check your wiring?"));
    while(1);
  }
  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F("Failed!"));
    while(1);
  }
  Serial.println(F("Connected!"));
  Serial.println(F("Request DHCP"));
  while (!cc3000.checkDHCP())
    ip = 0;
  Serial.print(WEBSITE); 
  Serial.print(F(" -> "));
  while (ip == 0) {
    if (! cc3000.getHostByName(WEBSITE, &ip)) {
      Serial.println(F("Couldn't resolve!"));
    }
    delay(500);
  }
  cc3000.printIPdotsRev(ip);
  //timesConnected++;
  Serial.println();
}
void loop(void)
{
  if (Sample >= 5){

    Sample = 0;
   Serial.println(F("\n\nDisconnecting"));
  cc3000.disconnect();
  delay(10);
    Serial.println(F("\nInitializing..."));
  if (!cc3000.begin())
  {
   // Serial.println(F("Couldn't begin()! Check your wiring?"));
    while(1);
  }
  if (!cc3000.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F("Failed!"));
    while(1);
  }
  Serial.println(F("Connected!"));
  Serial.println(F("Request DHCP"));
  while (!cc3000.checkDHCP())
    ip = 0;
  Serial.print(WEBSITE); 
  Serial.print(F(" -> "));
  while (ip == 0) {
    if (! cc3000.getHostByName(WEBSITE, &ip)) {
      Serial.println(F("Couldn't resolve!"));
    }
    delay(500);
  }
  cc3000.printIPdotsRev(ip);
  //timesConnected++;
  Serial.println();
 }
Sample ++;
windvelocity();
RPMcalc();
WindSpeed();
Heading();
  float tempf = dht.readTemperature(2);
  float Humi = dht.readHumidity();
  float baromin = bmp.readPressure()* 0.0002953;
  float maxwind = 0 / 0.445;
  float Dew = (dewPoint(dht.readTemperature(2), dht.readHumidity()));
  if (speedwind > maxwind) {
    maxwind = speedwind;
  }
  Adafruit_CC3000_Client client = cc3000.connectTCP(ip, 80);
  if (client.connected()) {
    Serial.println("Sending DATA ");
    digitalWrite(led, HIGH); 
    Serial.print(" Sample # ");
    Serial.println(Sample);
    Serial.println("-------------------------------------");
    DateTime now = rtc.now();
    //  Serial.print(WEBSITE);
    client.print("GET /weatherstation/updateweatherstation.php?");
    client.print("ID=");
    client.print(ID);
    client.print("&PASSWORD=");
    client.print(PASSWORD);
    client.print("&dateutc=");
    client.print(now.year());
    client.print("-");
    client.print(now.month());
    client.print("-");
    client.print(now.day());
    client.print("+");
    client.print(now.hour()+ 5);
    client.print("%3A");
    client.print(now.minute()+ 2);
    client.print("%3A");
    client.print(now.second());
    digitalWrite(led, LOW);
    client.print("&winddir=");
    client.print(winddir);
    digitalWrite(led, HIGH);
    client.print("&windspeedmph=");
    client.print(speedwind);
    digitalWrite(led, LOW);
    client.print("&windgustmph=");
    client.print(maxwind);
    digitalWrite(led, HIGH);
    client.print("&rainin=0");
    //client.print("0");
    digitalWrite(led, LOW);
    client.print("&tempf=");
    client.print(tempf);
    digitalWrite(led, HIGH);
    client.print("&baromin=");
    client.print(baromin);
    digitalWrite(led, LOW);
    client.print("&dewptf=");
    client.print(Dew);
    digitalWrite(led, HIGH);
    client.print("&humidity=");
    client.print(Humi);
    digitalWrite(led, LOW);
    client.print("&action=updateraw");
    client.println();
    digitalWrite(led, HIGH);
    //delay(10);
    digitalWrite(led, LOW);
  } 
  else {
    Serial.println(F("Connection failed"));    
    return;
  }
  Serial.println("Server Responce!");
  unsigned long lastRead = millis();
  while (client.connected() && (millis() - lastRead < IDLE_TIMEOUT_MS)) {
    while (client.available()) {
      char c = client.read();
      Serial.print(c);
      lastRead = millis();
    }
  }
  client.close();
  Serial.println("-------------------------------------");
  Serial.print("Waiting ");
  Serial.print(Wait/1000.0);
  Serial.println(" seconds.");
  delay(Wait);// 30sec
  Serial.println();
  Serial.println("-------------------------------------");
 
}//end loop

//PART TWO of TWO

void listSSIDResults(void)
{
  uint8_t valid, rssi, sec, index;
  char ssidname[33]; 
  index = cc3000.startSSIDscan();
  Serial.print(F("Networks found: ")); 
  Serial.println(index);
  Serial.println(F("================================================"));
  while (index) {
    index--;
    valid = cc3000.getNextSSID(&rssi, &sec, ssidname);
    Serial.print(F("SSID Name    : ")); 
    Serial.print(ssidname);
    Serial.println();
    Serial.print(F("RSSI         : "));
    Serial.println(rssi);
    Serial.print(F("Security Mode: "));
    Serial.println(sec);
    Serial.println();
  }
  Serial.println(F("================================================"));

  cc3000.stopSSIDscan();
}
bool displayConnectionDetails(void)
{
  uint32_t ipAddress, netmask, gateway, dhcpserv, dnsserv;
  if(!cc3000.getIPAddress(&ipAddress, &netmask, &gateway, &dhcpserv, &dnsserv))
  {
    Serial.println(F("Unable to retrieve the IP Address!\r\n"));
    return false;
  }
  else
  {
    Serial.print(F("\nIP Addr: ")); 
    cc3000.printIPdotsRev(ipAddress);
    Serial.print(F("\nNetmask: ")); 
    cc3000.printIPdotsRev(netmask);
    Serial.print(F("\nGateway: ")); 
    cc3000.printIPdotsRev(gateway);
    Serial.print(F("\nDHCPsrv: ")); 
    cc3000.printIPdotsRev(dhcpserv);
    Serial.print(F("\nDNSserv: ")); 
    cc3000.printIPdotsRev(dnsserv);
    Serial.println();
    //timesConnected++;
    return true;
  }
}
void windvelocity(){
  speedwind = 0;
  counter = 0;  
  attachInterrupt(0, addcount, RISING);//anemometer
  unsigned long millis();                     
  long startTime = millis();
  while(millis() < startTime + Wait) {
  }
  detachInterrupt(0);
}
void RPMcalc(){
  RPM=((counter*2)*60)/(period/1000);  // Calculate revolutions per minute (RPM)
}
void WindSpeed(){
  speedwind = ((2 * pi * radio * RPM)/60) / 1000;
}
void addcount(){
  counter++;
}
void Heading(){
  analogRead(winDir)* 5.00 / 1023.0;//Wind direction, Tweek the voltage returns below to match your resistor
  if ((winDir > 4.94)||(winDir < 0.01))
    (winddir = 0);
  if ((winDir >= 0.02)&&(winDir < 0.30))
    (winddir = 22.5);
  if ((winDir >= 0.31)&&(winDir < 0.72))
    (winddir = 45);
  if ((winDir >= 0.72)&&(winDir < 0.99))
    (winddir= 67.5);
  if ((winDir >= 1.00)&&(winDir < 1.25))
    (winddir = 90);
  if ((winDir >= 1.26)&&(winDir < 1.52))
    (winddir= 112.5);
  if ((winDir >= 1.53)&&(winDir < 1.91))
    (winddir= 135);
  if ((winDir >= 1.92)&&(winDir < 2.40))
    (winddir = 157.5);
  if ((winDir >= 2.41)&&(winDir < 2.73))
    (winddir = 180);
  if ((winDir >= 2.74)&&(winDir < 2.96))
    (winddir = 202.5);
  if ((winDir >= 2.97)&&(winDir < 3.37))
    (winddir = 225);
  if ((winDir >= 3.38)&&(winDir < 3.55))
    (winddir = 247.5);
  if ((winDir >= 3.56)&&(winDir < 3.85))
    (winddir = 270);
  if ((winDir >= 4.13)&&(winDir < 4.06))
    (winddir = 292.5);
  if ((winDir >= 4.07)&&(winDir < 4.32))
    (winddir = 315);
  if ((winDir >= 4.33)&&(winDir < 4.93))
    (winddir = 337.5);
}

I am hoping to do the same thing, and am even more of a learner :slight_smile:

Have you updated the firmware on the cc3000? Adafruit's example code can do it.

My understanding is that the newest version (1.13) is a bit quirky with UDP, but more stable with HTTP, and the previous version (1.12) is a bit more balanced.

Hope it works out, I would love to get my arduino weather station off the ethernet cable too!

I have updated the firmware to 1.14 and it seems to have fixed the hanging part after connecting to the wunderground server.
I have added a few other sensors as well and so far it's still posting
As of 9:30AM est 12/16/2014
now 4:09PM est 12/16/2014 this is the longest time It has gone without a HANG.
I think this is around 400 posts to wunderground.