Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 18:22 02 May 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Anyone any good with ESP Basic?

Author Message
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 03:44am 08 Apr 2017
Copy link to clipboard 
Print this post

I need some help.......

I'm trying to get the info from Wunderground to show on a weather station I'm building
I can get it to work fine using openweathermap.org but I can't get Wunderground to work and Wunderground has a lot more data available

Anyone able to help?

This is what works with openweathermap
[code]timesetup(1)
print time()
delay 1000
print time()
timer 10 * 1000, [RUNPROGRAM]
wait
[RUNPROGRAM]
cls
PRINT "TIME" & "," & time()
serialprintln "TIME" & "," & time()
let query = "api.openweathermap.org/data/2.5/weather?q=Denton,uk&lang=en&units=metric&appid=API_KEY_HERE"
delay 500
let ret = wget(query)
let temp = json(ret,"main.temp")
let press = json(ret,"main.pressure")
let humid = json(ret,"main.humidity")
let speed = json(ret,"main.speed")
speed1 = int(main.speed + 0.5)
let dir = json(ret,"main.deg")
let icon = json(ret,"main.icon")
let desc = json(ret,"description")
println "Today," & desc & "," & icon & "," & temp & "," & press &"," & speed1 & "," & dir & "," & humid[/code]

This is my code for Wunderground but it fails on LINE 22

[code]timesetup(1)
print time()
delay 1000
print time()
timer 10 * 1000, [RUNPROGRAM]
wait
[RUNPROGRAM]
cls
PRINT "TIME" & "," & time()
'println "TIME" & "," & time()
let query = "api.wunderground.com/api/API_KEY_HERE/conditions/q/UK/Audenshaw.json"
delay 10
let ret = wget(query)
let temp = json(ret,"temp_c")
let press = json(ret,"pressure_mb")
let humid = json(ret,"relative_humidity")
let speed = json(ret,"main.speed")
speed1 = int(wind_mph)
let dir = json(ret,"wind_degrees")
let icon = json(ret,"icon")
let desc = json(ret,"wind_string")
println "Today," & desc & "," & icon & "," & temp & "," & press &"," & speed1 & "," & dir & "," & humid
[/code]




This is the actual full return from the API call that I'm trying to parse


[quote]{
"response": {
"version":"0.1",
"termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
"features": {
"conditions": 1
}
}
, "current_observation": {
"image": {
"url":"http://icons.wxug.com/graphics/wu2/logo_130x80.png",
"title":"Weather Underground",
"link":"http://www.wunderground.com"
},
"display_location": {
"full":"Audenshaw, United Kingdom",
"city":"Audenshaw",
"state":"TAM",
"state_name":"United Kingdom",
"country":"UK",
"country_iso3166":"GB",
"zip":"00000",
"magic":"71",
"wmo":"03334",
"latitude":"53.45000076",
"longitude":"-2.11999989",
"elevation":"79.9"
},
"observation_location": {
"full":"Denton, Denton, ",
"city":"Denton, Denton",
"state":"",
"country":"GB",
"country_iso3166":"GB",
"latitude":"53.441669",
"longitude":"-2.149535",
"elevation":"256 ft"
},
"estimated": {
},
"station_id":"IDENTON2",
"observation_time":"Last Updated on April 7, 4:51 PM BST",
"observation_time_rfc822":"Fri, 07 Apr 2017 16:51:29 +0100",
"observation_epoch":"1491580289",
"local_time_rfc822":"Fri, 07 Apr 2017 16:52:09 +0100",
"local_epoch":"1491580329",
"local_tz_short":"BST",
"local_tz_long":"Europe/London",
"local_tz_offset":"+0100",
"weather":"Clear",
"temperature_string":"61.3 F (16.3 C)",
"temp_f":61.3,
"temp_c":16.3,
"relative_humidity":"46%",
"wind_string":"From the SSW at 7.2 MPH Gusting to 14.3 MPH",
"wind_dir":"SSW",
"wind_degrees":202,
"wind_mph":7.2,
"wind_gust_mph":"14.3",
"wind_kph":11.6,
"wind_gust_kph":"23.0",
"pressure_mb":"1026",
"pressure_in":"30.30",
"pressure_trend":"0",
"dewpoint_string":"40 F (5 C)",
"dewpoint_f":40,
"dewpoint_c":5,
"heat_index_string":"NA",
"heat_index_f":"NA",
"heat_index_c":"NA",
"windchill_string":"NA",
"windchill_f":"NA",
"windchill_c":"NA",
"feelslike_string":"61.3 F (16.3 C)",
"feelslike_f":"61.3",
"feelslike_c":"16.3",
"visibility_mi":"6.2",
"visibility_km":"10.0",
"solarradiation":"--",
"UV":"3","precip_1hr_string":"0.00 in ( 0 mm)",
"precip_1hr_in":"0.00",
"precip_1hr_metric":" 0",
"precip_today_string":"0.00 in (0 mm)",
"precip_today_in":"0.00",
"precip_today_metric":"0",
"icon":"clear",
"icon_url":"http://icons.wxug.com/i/c/k/clear.gif",
"forecast_url":"http://www.wunderground.com/global/stations/03334.html",
"history_url":"http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=IDENTON2",
"ob_url":"http://www.wunderground.com/cgi-bin/findweather/getForecast?query=53.441669,-2.149535",
"nowcast":""
}
}[/quote]

I'd like to get this working so I can then work on the forecast which again works fine in openweathermap*
Thanks in advance
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3661
Posted: 04:45am 08 Apr 2017
Copy link to clipboard 
Print this post

I've hardly used it but I don't think it has println. Just print.

John
 
Boppa
Guru

Joined: 08/11/2016
Location: Australia
Posts: 814
Posted: 05:51am 08 Apr 2017
Copy link to clipboard 
Print this post

Haven't used it myself either
but just looking at it
10 has 'printin
22 has printin


9 has a print statement with 10 having the same worded 'printin after it

22 doesnt have a print statement before it anywhere I noticed

could either of these be the issue?Edited by Boppa 2017-04-09
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 06:20am 08 Apr 2017
Copy link to clipboard 
Print this post

The println just means it prints to the console and puts a line return after printing
Print prints with no new line
 
Boppa
Guru

Joined: 08/11/2016
Location: Australia
Posts: 814
Posted: 06:43am 08 Apr 2017
Copy link to clipboard 
Print this post

whats with the ' in front of it?- does that have any special meaning
(its been years since I played with this stuff- about 30 in fact)
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 07:26am 08 Apr 2017
Copy link to clipboard 
Print this post

the ' means ignore that line, It was there in a previous version I forgot to remove
' instead of REM (not sure rem works)
Edited by lew247 2017-04-09
 
Boppa
Guru

Joined: 08/11/2016
Location: Australia
Posts: 814
Posted: 07:52am 08 Apr 2017
Copy link to clipboard 
Print this post

ok that explains that then (sorry its been a while and I started on applebasic, then commodore basic, then microbee, back to commodore, then various gw/ms/tandy basics- all had their own little quirks)

one other thing I just noticed, in 22 in the middle is this bit


press &","

in the middle of this

temp & "," & press &"," & speed1 & ","

??? maybe this

(no spc between & and ")
ie press &"," should be press & ","
???
Edited by Boppa 2017-04-09
 
MikeO
Senior Member

Joined: 11/09/2011
Location: Australia
Posts: 275
Posted: 04:07pm 08 Apr 2017
Copy link to clipboard 
Print this post

Lew I think the clue to the problem is the in the error line


I suspect that there is too much data comming back from WeatherUnderground for ESPbasic to handle, its a bit flakey handling large streams of web data i think, thats why the Openweather command has arguments to parse portions of data.

Mike




Codenquilts
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1676
Posted: 12:12am 09 Apr 2017
Copy link to clipboard 
Print this post

  MikeO said   Lew I think the clue to the problem is the in the error line

I suspect that there is too much data comming back from WeatherUnderground for ESPbasic to handle, its a bit flakey handling large streams of web data i think, thats why the Openweather command has arguments to parse portions of data.

Mike

Ah... I never actually considered that, it makes sense actually as there is a lot more data than Openweather
Shame as it would have been a better option for those who don't have an actual weather station to get the live conditions from
Thanks Mike
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024