Uploading to weatherunderground from a nodemcu 2866.

  • 2
  • Question
  • Updated 5 months ago
  • (Edited)
Hi all
I am wanting to confirm what the password would be when writing a sketch 

char server_wu [] = "rtupdate.wunderground.com";  
char WEBPAGE [] = "GET /weatherstation/updateweatherstation.php?";
char ID [] = "dqc7s0fs";
char PASSWORD [] = "######";

is it my login password to weather underground or an api key?
Also, dont know if im targeting the correct server as well so if someone could please confirm or provide some sample code even

thanks in advance

Andrew
Photo of andrew

andrew

  • 2 Posts
  • 1 Reply Like

Posted 5 months ago

  • 2
Photo of An Audi RS6

An Audi RS6

  • 3 Posts
  • 0 Reply Likes
Just to give you some form of answer, I would imagine it is the API key, but it would help to see the part of the code when the char PASSWORD is actually used.
Photo of andrew

andrew

  • 2 Posts
  • 1 Reply Like
Hi and thanks for the reply. Thingspeak data upload is working


// Example testing sketch for various DHT humidity/temperature sensors

// Written by ladyada, public domain


#include "DHT.h"

#include

#define DHTPIN 2 // what digital pin we're connected to


String apiKey = “########"; // Enter your Write API key from ThingSpeak


const char *ssid = "Carlton"; // replace with your wifi ssid and wpa2 key

const char *pass =

const char* server = "api.thingspeak.com";


///////////////Weather////////////////////////

char server_wu [] = "weatherstation.wunderground.com";

char WEBPAGE [] = "GET /weatherstation/updateweatherstation.php?";

char ID [] = "dqc7s0fs";

char PASSWORD [] = is this an api code?


// Uncomment whatever type you're using!

#define DHTTYPE DHT11 // DHT 11

//#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321

//#define DHTTYPE DHT21 // DHT 21 (AM2301)


// Connect pin 1 (on the left) of the sensor to +5V

// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1

// to 3.3V instead of 5V!

// Connect pin 2 of the sensor to whatever your DHTPIN is

// Connect pin 4 (on the right) of the sensor to GROUND

// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor


// Initialize DHT sensor.

// Note that older versions of this library took an optional third parameter to

// tweak the timings for faster processors. This parameter is no longer needed

// as the current DHT reading algorithm adjusts itself to work on faster procs.

DHT dht(DHTPIN, DHTTYPE);

WiFiClient client;


void setup() {

Serial.begin(9600);

Serial.println("DHTxx test!");


dht.begin();

Serial.println("Connecting to ");

Serial.println(ssid);


WiFi.begin(ssid, pass);


while (WiFi.status() != WL_CONNECTED)

{

delay(500);

Serial.print(".");

}

Serial.println("");

Serial.println("WiFi connected");

}


void loop() {

// Wait a few seconds between measurements.

delay(2000);


float h = dht.readHumidity();

float t = dht.readTemperature();


if (isnan(h) || isnan(t))

{

Serial.println("Failed to read from DHT sensor!");

return;

}


if (client.connect(server,80)) // "184.106.153.149" or api.thingspeak.com

{


String postStr = apiKey;

postStr +="&field1=";

postStr += String(t);

postStr +="&field2=";

postStr += String(h);

postStr += "\r\n\r\n";


client.print("POST /update HTTP/1.1\n");

client.print("Host: api.thingspeak.com\n");

client.print("Connection: close\n");

client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");

client.print("Content-Type: application/x-www-form-urlencoded\n");

client.print("Content-Length: ");

client.print(postStr.length());

client.print("\n\n");

client.print(postStr);


Serial.print("Temperature: ");

Serial.print(t);

Serial.print(" degrees Celcius, Humidity: ");

Serial.print(h);

Serial.println("%. Send to Thingspeak.");

}

client.stop();


Serial.println("Waiting...");


// thingspeak needs minimum 15 sec delay between updates, i've set it to 30 seconds

delay(20000);


//Get sensor data

float tempc = dht.readTemperature();


float humidity = dht.readHumidity();


//check sensor data

Serial.println("+++++++++++++++++++++++++");


Serial.print("tempC= ");

Serial.print(tempc);

Serial.println(" *C");

Serial.print("dew point= ");

Serial.print("humidity= ");

Serial.println(humidity);

//Send data to Weather Underground

Serial.print("connecting to ");

Serial.println(server_wu);

WiFiClient client;

if (!client.connect(server, 80)) {

Serial.println("Conection Fail");


}

client.print(WEBPAGE);

client.print("ID=");

client.print(ID);

client.print("&PASSWORD=");

client.print(PASSWORD);

client.print("&dateutc=");


client.print("&humidity=");

client.print(humidity);

client.print("&softwaretype=ESP%208266O%20version1&action=updateraw&realtime=1&rtfreq=2.5");

client.println();


Serial.print("Temperature: ");

Serial.print(tempc);

Serial.print(" degrees Celcius, Humidity: ");

Serial.print(humidity);

Serial.println("%. Send to WU.");

delay(2500);


}
(Edited)