Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please提交你r question from the Ask a Question page.


Log inorregister张贴在论坛/答复。

Pulling data from wunderground api into cr6


Sublyime Oct 18, 2021 03:31 AM

I was bored and wrote the is horrible ugly program to do it, 98% compete and working... looking to beautify it.. any pointers? I removed my api key but feel free to use your own station ID and key to test .. lemme know what you think .. I have thick skin. Lol

'CR6 Datalogger'在第1行中列出的数据记录器类型确定默认指令集,“编译器和帮助文件用于使用.dld或.crb程序”日期:10-16-21“程序作者:Ty Fairchild'公共变量公共PTEMP作为浮法公共BATT_VOLT作为浮动公钥作为字符串* 500个公共国家作为字符串* 10'国家代码公共时代作为浮子的浮动时间在UNIX秒公共湿度作为浮动的空气相对湿度。Public LAT作为PWS公共LON的浮动的纬度,作为PWS公共社区的浮动“经度”,与PWS位置公共障碍关联的字符串* 24'obstipelocal作为String * 24'时间观察通过TimeZone  -  TZ公共贸易局在当地明显时间有效作为String * 24'GMT(UTC)时间公共QCSTATUS作为浮动的质量控制指示:'-1:没有质量控制检查'0:这种观察由我们的质量控制算法1的可能不正确:这种观察通过质量控制检查公共场所的数据报告的频率,以分钟公共软仪表在数分钟的公共软件包中作为字符串* 24'软件类型的PWS公共独资独容播放,作为浮动的太阳辐射公共版本作为字符串* 24'ID,如Wunderground.com公共UV注册浮动'UV读取太阳辐射公共Windir的强度作为浮动'风向公共帝国作为字符串* 24'对象,其中包含使用定义的度量单位的字段。对象标签取决于请求中分配的单位参数。'“帝国”,“公制”,“metric_si”,“uk_hybrid”,“uk_hybrid”将API Docs公众度量标准视为String * 24',请参阅公共Metric_SI上方的Iperial Notes,如字符串* 24',请参阅公共uk_hybrid上方的英制注释为字符串* 24'参见帝国上面的公共拆开的注意事项为浮动'必须在恒定压力下冷却空气以达到饱和的温度。露点也是空气湿度的间接测量。 The Dew Point will never exceed the Temperature. When the Dew Point and Temperature are equal, clouds or fog will typically form. The closer the values of Temperature and Dew Point, the higher the relative humidity. Public elev As Float 'Elevation Public heatIndex As Float 'Heat Index - An apparent temperature. It represents what the air temperature “feels like” on exposed human skin due to the combined effect of warm temperatures and high humidity. 'When the temperature is 70°F or higher, the Feels Like value represents the computed Heat Index. Public precipRate As Float 'Rate of precipitation - instantaneous precipitation rate. How much rain would fall if the precipitation intensity did not change for one hour Public precipTotal As Float 'Accumulated precipitation for today from midnight to present. Public pressure As Long 'Mean Sea Level Pressure, the equivalent pressure reading at sea level recorded at this station Public temp As Float 'Temperature in defined unit of measure. Public windChill As Float 'Wind Chill - An apparent temperature. It represents what the air temperature “feels like” on exposed human skin due to the combined effect of the cold temperatures and wind speed. 'When the temperature is 61°F or lower the Feels Like value represents the computed Wind Chill so display the Wind Chill value. Public windGust As Float 'Wind Gust - sudden and temporary variations of the average Wind Speed. The report always shows the maximum wind gust speed recorded during the observation period. It is a required display field if Wind Speed is shown. Public windSpeed As Float 'Wind Speed - The wind is treated as a vector; hence, winds must have direction and magnitude (speed). The wind information reported in the hourly current conditions corresponds to a 10-minute average called the sustained wind speed. Sudden or brief variations in the wind speed are known as “wind gusts” and are reported in a separate data field. 'Wind directions are always expressed as ""from whence the wind blows"" meaning that a North wind blows from North to South. If you face North in a North wind the wind is at your face. Face southward and the North wind is at your back. 'defining of object start points, an appended number "1" indicates position from beginning of the api call probably in JSON format Public country1 As String * 10 Public epoch1 As String * 24 Public humidity1 As String * 24 Public lat1 As Float Public lon1 As Float Public neighborhood1 As String * 24 Public obsTimeLocal1 As String * 24 Public obsTimeUtc1 As String * 24 Public qcStatus1 As String * 24 Public realtimeFrequency1 As String * 24 Public softwareType1 As String * 24 Public solarRadiation1 As String * 24 Public stationID1 As String * 24 Public uv1 As String * 24 Public winddir1 As String * 24 Public imperial1 As String * 24 Public metric1 As String * 24 Public metric_si1 As String * 24 Public uk_hybrid1 As String * 24 Public dewpt1 As String * 24 Public elev1 As String * 24 Public heatIndex1 As String * 24 Public precipRate1 As String * 24 Public precipTotal1 As String * 24 Public pressure1 As String * 24 Public temp1 As String * 24 Public windChill1 As String * 24 Public windGust1 As String * 24 Public windSpeed1 As String * 24 'defining of object values 'actual starting positions of objects, an appended number "2" indicates position from beginning of the api call probably in JSON format Public country2 As Float Public epoch2 As Float Public humidity2 As Float Public lat2 As Float Public lon2 As Float Public neighborhood2 As Float Public obsTimeLocal2 as FLOAT Public obsTimeUtc2 As String * 24 Public qcStatus2 As String * 24 Public realtimeFrequency2 As String * 24 Public softwareType2 As String * 24 Public solarRadiation2 As String * 24 Public stationID2 As String * 24 Public uv2 As String * 24 Public winddir2 As String * 24 Public imperial2 As String * 24 Public metric2 As String * 24 Public metric_si2 As String * 24 Public uk_hybrid2 As String * 24 Public dewpt2 As String * 24 Public elev2 As String * 24 Public heatIndex2 As String * 24 Public precipRate2 As String * 24 Public precipTotal2 As String * 24 Public pressure2 As String * 24 Public temp2 As String * 24 Public windChill2 As String * 24 Public windGust2 As String * 24 Public windSpeed2 As String * 24 'units define here Units PTemp=c 'deg celcius Units Batt_volt=v 'vdc Units epoch=sec 'UNIX seconds Units rh=% 'in percent Units AT=c 'deg c -40 - +50 Units ws=m/s 'in meters per sec Units wd=deg 'degrees 0-359 Units solar=w/m2 'watt meter squared Units baro=mb 'millibar 'Alias Alias acurite_api = api Alias humidity = rh Alias temp = AT Alias windSpeed = ws Alias winddir = wd Alias pressure = baro Alias precipRate = rain_rate Alias precipTotal = rain_total Alias solarRadiation = solar 'Data Tables 'logger status table DataTable (logger_status,1,-1) DataInterval (0,15,Sec,10) Sample (1,PTemp,FP2) Sample (1,Batt_volt,FP2) EndTable 'api table DataTable (api_table,1,-1) DataInterval (0,15,Sec,10) Sample (1,acurite_api,String) EndTable 'Full station info table DataTable (full_Observations,1,-1) 'set table size to # of records, or -1 to autoallocate. DataInterval (0,15,Sec,10) Sample 1,country,String Sample 1,epoch,IEEE8 Sample 1,humidity,FP2 Sample 1,lat,FP2 Sample 1,lon,FP2 Sample 1,neighborhood,String Sample 1,obsTimeLocal,String Sample 1,obsTimeUtc,String Sample 1,qcStatus,FP2 Sample 1,realtimeFrequency,FP2 Sample 1,softwareType,String Sample 1,solarRadiation,FP2 Sample 1,stationID,String Sample 1,uv,FP2 Sample 1,winddir,FP2 Sample 1,imperial,String Sample 1,metric,String Sample 1,metric_si,String Sample 1,uk_hybrid,String Sample 1,dewpt,IEEE4 Sample 1,elev,FP2 Sample 1,heatIndex,FP2 Sample 1,precipRate,FP2 Sample 1,precipTotal,FP2 Sample 1,pressure,IEEE4 Sample 1,temp,FP2 Sample 1,windChill,FP2 Sample 1,windGust,FP2 Sample 1,windSpeed,FP2 EndTable 'Location info table DataTable (Location_info,1,-1) 'Set table size to # of records, or -1 to autoallocate. DataInterval (0,15,Sec,10) Sample 1,stationID,String Sample 1,country,String Sample 1,neighborhood,String Sample 1,lon,FP2 Sample 1,lat,FP2 Sample 1,obsTimeUtc,String EndTable 'MET for SAFER output table DataTable (SAFER_modbus_out,1,-1) 'Set table size to # of records, or -1 to autoallocate. DataInterval (0,15,Sec,10) Sample 1,windSpeed,FP2 Sample 1,winddir,FP2 Sample 1,temp,FP2 Sample 1,humidity,FP2 Sample 1,solarRadiation,FP2 Sample 1,pressure,IEEE4 Sample 1,precipRate,FP2 Sample 1,precipTotal,FP2 EndTable 'Main Program BeginProg PanelTemp (PTemp,15000) Battery (Batt_volt) Scan (15,Sec,0,0) 'calling the api HTTPGet ("https://api.weather.com/v2/pws/observations/current?stationId=ststionID&format=json&units=e&apiKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",acurite_api,"Accept-Encoding: gzip",30) 'defining object filter values country1 = "country" epoch1 = "epoch" humidity1 = "humidity" lat1 = "lat" lon1 = "lon" neighborhood1 = "neighborhood" obsTimeLocal1 = "obsTimeLocal" obsTimeUtc1 = "obsTimeUtc" qcStatus1 = "qcStatus" realtimeFrequency1 = "realtimeFrequency" softwareType1 = "softwareType" solarRadiation1 = "solarRadiation" stationID1 = "stationID" uv1 = "uv" winddir1 = "winddir" imperial1 = "imperial" metric1 = "metric" metric_si1 = "metric_si" uk_hybrid1 = "uk_hybrid" dewpt1 = "dewpt" elev1 = "elev" heatIndex1 = "heatIndex" precipRate1 = "precipRate" precipTotal1 = "precipTotal" pressure1 = "pressure" temp1 = "temp" windChill1 = "windChill" windGust1 = "windGust" windSpeed1 = "windspeed" 'parsing the api json to find start point for objects and extracting country2 = InStr (1,acurite_api,country1,2)+10 country = Mid (acurite_api,country2,2) epoch2 = InStr (1,acurite_api,epoch1,2)+8 epoch = Mid (acurite_api,epoch2,10) humidity2 =InStr (1,acurite_api,humidity1,2)+11 humidity = Mid (acurite_api,humidity2,2) lat2 = InStr (1,acurite_api,lat1,2)+6 lat = Mid (acurite_api,lat2,8) lon2 = InStr (1,acurite_api,lon1,2)+6 lon = Mid (acurite_api,lon2,8) neighborhood2 = InStr (1,acurite_api,neighborhood1,2)+16 neighborhood = Mid (acurite_api,neighborhood2,24) obsTimeLocal2 = InStr (1,acurite_api,obsTimeLocal1,2)+16 obsTimeLocal = Mid (acurite_api,obsTimeLocal2,24) obsTimeUtc2 = InStr (1,acurite_api,obsTimeUtc1,2)+14 obsTimeUtc = Mid (acurite_api,obsTimeUtc2,23) qcStatus2 = InStr (1,acurite_api,qcStatus1,2)+11 qcStatus = Mid (acurite_api,qcStatus2,2) realtimeFrequency2 = InStr (1,acurite_api,realtimeFrequency1,2)+20 realtimeFrequency = Mid (acurite_api,realtimeFrequency2,4) softwareType2 = InStr (1,acurite_api,softwareType1,2)+16 softwareType = Mid (acurite_api,softwareType2,14) solarRadiation2 = InStr (1,acurite_api,solarRadiation1,2)+17 solarRadiation = Mid (acurite_api,solarRadiation2,4) stationID2 = InStr (1,acurite_api,stationID1,2)+12 stationID = Mid (acurite_api,stationID2,12) uv2 = InStr (1,acurite_api,uv1,2)+4 uv = Mid (acurite_api,uv2,3) winddir2 = InStr (1,acurite_api,winddir1,2)+10 winddir = Mid (acurite_api,winddir2,3) imperial2 = InStr (1,acurite_api,imperial1,2)+11 imperial = Mid (acurite_api,imperial2,20) metric2 = InStr (1,acurite_api,metric1,2) metric = Mid (acurite_api,metric2,20) metric_si2 = InStr (1,acurite_api,metric_si1,2) metric_si = Mid (acurite_api,metric_si2,20) uk_hybrid2 = InStr (1,acurite_api,uk_hybrid1,2) uk_hybrid = Mid (acurite_api,uk_hybrid2,20) dewpt2 = InStr (1,acurite_api,dewpt1,2)+8 dewpt = Mid (Batt_volt,dewpt2,2) elev2 = InStr (1,acurite_api,elev1,2)+7 elev = Mid (acurite_api,elev2,4) heatIndex2 = InStr (1,acurite_api,heatIndex1,2)+12 heatIndex = Mid (acurite_api,heatIndex2,2) precipRate2 = InStr (1,acurite_api,precipRate1,2)+13 precipRate = Mid (acurite_api,precipRate2,4) precipTotal2 = InStr (1,acurite_api,precipTotal1,2)+14 precipTotal = Mid (Batt_volt,precipTotal2,4) pressure2 = InStr (1,acurite_api,pressure1,2)+11 pressure = Mid (pressure1,pressure2,5) temp2 = InStr (1,acurite_api,temp1,2)+7 temp = Mid (acurite_api,temp2,3) windChill2 = InStr (1,acurite_api,windChill1,2)+12 windChill = Mid (acurite_api,windChill2,3) windGust2 = InStr (1,acurite_api,windGust1,2)+11 windGust = Mid (acurite_api,windGust2,2) windSpeed2 = InStr (1,acurite_api,windSpeed1,2)+12 windSpeed = Mid (acurite_api,windSpeed2,3) CallTable SAFER_modbus_out CallTable Location_info CallTable full_Observations CallTable api_table CallTable logger_status NextScan EndProg


Thein Dec 1, 2021 11:14 AM

Hi,

Your program looks nice. Try tested, it doesn't work for me. Error come outs as api = "Http comms Error". All parameters got NAN. The code works on web brawser. Here it is

{"observations":[{"stationID":"IJOHORBA4","obsTimeUtc":"2021-12-01T11:10:39Z","obsTimeLocal":"2021-12-01 19:10:39","neighborhood":"AME Senai Airport City","softwareType":null,"country":"MY","solarRadiation":null,"lon":103.680107,"realtimeFrequency":null,"epoch":1638357039,"lat":1.59889,"uv":null,"winddir":157,"humidity":70,"qcStatus":-1,"imperial":{"temp":89,"heatIndex":103,"dewpt":78,"windChill":89,"windSpeed":5,"windGust":null,"pressure":29.66,"precipRate":null,"precipTotal":0.00,"elev":131}}]}

Do I need to do something with the datalogger communication settings?

Rgds,
Thein

Log inorregister张贴在论坛/答复。
Baidu