Jump to content

Component: BBC Weather Forecast (Comms: IoT/Cloud): Difference between revisions

From Flowcode Help
No edit summary
No edit summary
Line 17: Line 17:
==Component Source Code==
==Component Source Code==


Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_BBCWeatherForecast.fcfx FC_Comp_Source_BBCWeatherForecast.fcfx]
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_temp/BBCWeatherForecast.fcfx FC_Comp_Source_temp/BBCWeatherForecast.fcfx]


Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_BBCWeatherForecast.fcfx FC_Comp_Source_BBCWeatherForecast.fcfx]
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_temp/BBCWeatherForecast.fcfx FC_Comp_Source_temp/BBCWeatherForecast.fcfx]


==Detailed description==
==Detailed description==
Line 85: Line 85:


On an embedded device you would need a TCP/IP component to allow the communications to the BBC server. This then links to the Network Comms component.
On an embedded device you would need a TCP/IP component to allow the communications to the BBC server. This then links to the Network Comms component.




Line 92: Line 94:
==Macro reference==
==Macro reference==


===GetMaxTemperature===
===GetDayName===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetDayName'''
|-
| colspan="2" | Gets the name of the currently selected day as a string. 
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
 
 
===GetDaySummary===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetMaxTemperature'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetDaySummary'''
|-
| colspan="2" | Gets the summary of the currently selected day as a string. 
|-
|-
|-
| colspan="2" | Reads the forecast maximum temperature in the selected scale for the selected day. 
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
 
 
===GetHumidity===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetHumidity'''
|-
|-
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL
| colspan="2" | Reads the forecast humidity in Relative Humdity for the selected day. 
| width="90%" | Scale
|-
|-
| colspan="2" | 0 = Celcius, 1 = Farenheit 
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




===GetVisibility===
===GetLocationName===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetVisibility'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetLocationName'''
|-
|-
| colspan="2" | Reads the forecast visibility for the selected day. 
| colspan="2" | Reads the reported location name as a string. 
|-
|-
|-
|-
Line 125: Line 150:




===GetDaySummary===
===GetMaxTemperature===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetDaySummary'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetMaxTemperature'''
|-
| colspan="2" | Reads the forecast maximum temperature in the selected scale for the selected day. 
|-
|-
|-
| colspan="2" | Gets the summary of the currently selected day as a string. 
| width="10%" align="center" | [[File:Fc9-bool-icon.png]] - BOOL
| width="90%" | Scale
|-
|-
| colspan="2" | 0 = Celcius, 1 = Farenheit 
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-s16-icon.png]] - INT
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}
Line 158: Line 188:




===GetWindDirection===
===GetPollution===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetWindDirection'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetPollution'''
|-
|-
| colspan="2" | Reads the forecast wind direction as a string for the selected day. 
| colspan="2" | Reads the forecast pollution as a string for the selected day. 
|-
|-
|-
|-
Line 172: Line 202:




===RequestData===
===GetPressure===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''RequestData'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetPressure'''
|-
|-
| colspan="2" | Requests data about your selected location from the BBC weather service. Returns true if the request was successful. Must be called before trying to call any of the GetXXX macros. 
| colspan="2" | Reads the forecast air pressure in milli bar (mb) for the selected day. 
|-
|-
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-bool-icon.png]] - BOOL
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




===GetPollution===
===GetSunrise===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetPollution'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetSunrise'''
|-
|-
| colspan="2" | Reads the forecast pollution as a string for the selected day. 
| colspan="2" | Reads the forecast sunrise time as a string for the selected day. 
|-
|-
|-
|-
Line 214: Line 244:




===GetHumidity===
===GetUVRisk===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetHumidity'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetUVRisk'''
|-
|-
| colspan="2" | Reads the forecast humidity in Relative Humdity for the selected day. 
| colspan="2" | Reads the forecast UV Risk for the selected day. 
|-
|-
|-
|-
Line 228: Line 258:




===GetDayName===
===GetVisibility===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetDayName'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetVisibility'''
|-
|-
| colspan="2" | Gets the name of the currently selected day as a string. 
| colspan="2" | Reads the forecast visibility for the selected day. 
|-
|-
|-
|-
Line 242: Line 272:




===GetWindSpeed===
===GetWindDirection===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetWindSpeed'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetWindDirection'''
|-
|-
| colspan="2" | Reads the reported wind speed in MPH for the selected day. 
| colspan="2" | Reads the forecast wind direction as a string for the selected day. 
|-
|-
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




===SetLocationCode===
===GetWindSpeed===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetLocationCode'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetWindSpeed'''
|-
|-
| colspan="2" | Allows the location code to be altered from the default location code set in the component properties. After changing the location the RequestData macro must be called to refresh the forecast variables. 
| colspan="2" | Reads the reported wind speed in MPH for the selected day. 
|-
|-
|-
|-
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="90%" | NewLocation
|-
| colspan="2" | New location string, see Location property tooltip for more info. 
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




===GetSunrise===
===Initialise===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetSunrise'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
|-
|-
| colspan="2" | Reads the forecast sunrise time as a string for the selected day. 
| colspan="2" | Sets up the component ready to collect weather data. 
|-
|-
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}




===GetPressure===
===RequestData===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetPressure'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''RequestData'''
|-
|-
| colspan="2" | Reads the forecast air pressure in milli bar (mb) for the selected day. 
| colspan="2" | Requests data about your selected location from the BBC weather service. Returns true if the request was successful. Must be called before trying to call any of the GetXXX macros. 
|-
|-
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u16-icon.png]] - UINT
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-bool-icon.png]] - BOOL
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
|}
Line 322: Line 347:




===GetUVRisk===
===SetLocationCode===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetUVRisk'''
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''SetLocationCode'''
|-
|-
| colspan="2" | Reads the forecast UV Risk for the selected day. 
| colspan="2" | Allows the location code to be altered from the default location code set in the component properties. After changing the location the RequestData macro must be called to refresh the forecast variables. 
|-
|-
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-u8-icon.png]] - BYTE
| width="10%" align="center" | [[File:Fc9-string-icon.png]] - STRING
| width="90%" style="border-top: 2px solid #000;" | ''Return''
| width="90%" | NewLocation
|}
 
 
===GetLocationName===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''GetLocationName'''
|-
| colspan="2" | Reads the reported location name as a string. 
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-string-icon.png]] - STRING
| width="90%" style="border-top: 2px solid #000;" | ''Return''
|}
 
 
===Initialise===
{| class="wikitable" style="width:60%; background-color:#FFFFFF;"
|-
| width="10%" align="center" style="background-color:#D8C9D8;" align="center" | [[File:Fc9-comp-macro.png]]
| width="90%" style="background-color:#D8C9D8; color:#4B008D;" | '''Initialise'''
|-
| colspan="2" | Sets up the component ready to collect weather data. 
|-
|-
| colspan="2" | New location string, see Location property tooltip for more info. 
|-
|-
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID
| width="10%" align="center" style="border-top: 2px solid #000;" | [[File:Fc9-void-icon.png]] - VOID

Revision as of 11:59, 3 February 2023

Author MatrixTSL
Version 1.0
Category Comms: IoT/Cloud


BBC Weather Forecast component

Easily allows you to collect three day forecasted weather metrics for your area using the BBC Weather data service. Supports Min/Max temperature, Wind Direction, Wind Speed, Visibility, Pressure, Humidty, UV Risk, Pollution and Sun Rise/Set times for your selected area.

Component Source Code

Please click here to download the component source project: FC_Comp_Source_temp/BBCWeatherForecast.fcfx

Please click here to view the component source code (Beta): FC_Comp_Source_temp/BBCWeatherForecast.fcfx

Detailed description

No detailed description exists yet for this component

Examples

Here is a basic example to read the three day forecast data and report the information on a graphical display.

BBCWeatherForecastDemo


The location can be set by adjusting the BBC Weather location property, see the component property tooltips for more information on how to do this.

On an embedded device you would need a TCP/IP component to allow the communications to the BBC server. This then links to the Network Comms component.




Macro reference

GetDayName

GetDayName
Gets the name of the currently selected day as a string. 
- STRING Return


GetDaySummary

GetDaySummary
Gets the summary of the currently selected day as a string. 
- STRING Return


GetHumidity

GetHumidity
Reads the forecast humidity in Relative Humdity for the selected day. 
- BYTE Return


GetLocationName

GetLocationName
Reads the reported location name as a string. 
- STRING Return


GetMaxTemperature

GetMaxTemperature
Reads the forecast maximum temperature in the selected scale for the selected day. 
- BOOL Scale
0 = Celcius, 1 = Farenheit 
- INT Return


GetMinTemperature

GetMinTemperature
Reads the forecast minimum temperature in the selected scale for the selected day. 
- BOOL Scale
0 = Celcius, 1 = Farenheit 
- INT Return


GetPollution

GetPollution
Reads the forecast pollution as a string for the selected day. 
- STRING Return


GetPressure

GetPressure
Reads the forecast air pressure in milli bar (mb) for the selected day. 
- UINT Return


GetSunrise

GetSunrise
Reads the forecast sunrise time as a string for the selected day. 
- STRING Return


GetSunset

GetSunset
Reads the forecast sunset time as a string for the selected day. 
- STRING Return


GetUVRisk

GetUVRisk
Reads the forecast UV Risk for the selected day. 
- BYTE Return


GetVisibility

GetVisibility
Reads the forecast visibility for the selected day. 
- STRING Return


GetWindDirection

GetWindDirection
Reads the forecast wind direction as a string for the selected day. 
- STRING Return


GetWindSpeed

GetWindSpeed
Reads the reported wind speed in MPH for the selected day. 
- BYTE Return


Initialise

Initialise
Sets up the component ready to collect weather data. 
- VOID Return


RequestData

RequestData
Requests data about your selected location from the BBC weather service. Returns true if the request was successful. Must be called before trying to call any of the GetXXX macros. 
- BOOL Return


SetForecastDay

SetForecastDay
Chooses which day of the three day forecast to look at.  
- BYTE Day
0 = Today, 1 = Tomorrow, 2 = Day After Tomorrow 
- VOID Return


SetLocationCode

SetLocationCode
Allows the location code to be altered from the default location code set in the component properties. After changing the location the RequestData macro must be called to refresh the forecast variables. 
- STRING NewLocation
New location string, see Location property tooltip for more info. 
- VOID Return



Property reference

Properties
LinkTo
 
BBC IP Address
IP Address linked to the following URL: weather-broker-cdn.api.bbci.co.uk 
Location Code
BBC code for your area. In a web browser go to www.bbc.co.uk/weather/ Then type in your city in the search bar and your code will be shown at the end of the URL. For example Manchester in the UK = 2643123 In the UK you can also use the first half of your post code, e.g. HX1 
Receive Timeout
Maximum time to wait for valid incoming data.