Beware that response could be a bit delayed. You have to wait for it.
Beware that response could be a bit delayed. You have to wait for it.
Explore... Chat... Share...
void loop() {
if ( (millis() - timer > loopTime) || first) { //
timer = millis(); // reset the timer
first=false;
getData();
delay(100);
inString="";
while(client.available()==0){}
while(client.available()){
inChar=client.read();
inString +=inChar;
Serial.print(inChar);
}
}
}
void getData(){
if (client.connect(servername, 80)) {
Serial.println("connected");
client.println("GET /forecast/e27c5d841c807341ce775e793268ff9a/49.8192,8.6449?exclude=hourly,flags,minutely,daily/units=si HTTP/1.1");
client.println("Host: api.darksky.net");
client.println("Connection: close");
}
else {
Serial.println("connection failed"); //error message if no client connect
}
}
Mikejstb wrote:Warning - long and rambling post follows - LOL!
After looking at my weather history DB and various online weather api products I have to agree that the openweather.org data is the most inaccurate that I've found.
The odd thing is that the data retrieved from their api is even different from what's returned from their web browser interface! Neither one is correct, but their web interface returns slightly closer data in my area.
The temperature is slightly off, the humidity is totally wrong, and the barometric pressure is also totally wrong.
I tried retrieving data from other nearby areas but it just never is very accurate. Surprising.
The best that I've found is the forecastIO/Dark Sky api.
It has similar icon recommendations but uses names like "cloudy" or "sunny" instead of the number scheme.
Another nice thing about it is it returns some previous history as well so it should be possible to for instance look at what the trend in the barometric pressure is - rising or falling,etc.
As I mentioned earlier I am already retrieving, processing, and storing data from dark sky in my Node Red setup running on a Raspberry Pi. So it was pretty simple to play with parsing out everything that I'd like to show on the little oled display and then sending that out in an mqtt message whenever my display asks for it. It requests new data with another mqtt message...
Back to the little display...
At first I thought it might be fairly easy to just use the Dark Sky api instead of openweather, but I'm not at all savvy with doing the tcp type of requests to get the info from the api, like you do in your example.
Then I got thinking that maybe the much larger data that gets returned might be too much to parse in Lua on the ESP?
Then I thought I'd just try to make a Lua mqtt listener, get the data from my Node Red, and display that on the oled using your u8g icon display code. But the simplest little example I could try was too big to compile in Lua. So I don't think that'll work either. As I mentioned before I am very impressed with how much functionality you were able to get into the limited Lua memory space!
What I liked the best of your example are the pretty icons - and those turn out to be about the only accurate data that I get from openweather - so I still have my little display, now mounted in a little plastic box, sitting on my desk, showing the nice weather icons you made!
It takes about 20-25 seconds for home assistant c[…]
I tried to upgrade tof my sonoff basic R2 with the[…]
a problem Perhaps you want to define "Probl[…]
Rebooting your router will not give you a faster I[…]
There are no other notifications from esptool.py i[…]
Using the Arduino IDE, you'll learn how to set up […]
In this project, you will post to Twitter using an[…]
In this project, we will build a water level contr[…]
I guess I'm late, but I had the same problem and f[…]
Last night I received my first D1 Minis for a lear[…]
Although I am aware that this is an old post, I fe[…]