To create a weather widget using Google Sheets, follow these steps:
To begin, create a free weatherstack account.
Make your own copy of this Google Sheet template.
On cell
A2
, enter your city as "City, CO
" whereCity
is the name of your city andCO
is a two-letter code identifier of your state (if in the US), or a two-letter code identifier of your country (if outside of the US). For a US city, you could enterNew York, NY
. For a city outside the US, you could enterLondon, UK
.On cell
A5
, enter your API Access Key for weatherstack (which you can find at https://weatherstack.com/dashboard?logged_in=1).On cell
A9
, enterm
to get the temperature in °C orf
to get the temperature in °FClick on the Tools menu and select the option Script editor.
You'll see a script. Click on the project's trigger's menu.
Click the + Add Trigger button in the bottom right corner of the page.
Set a trigger for the myFunction function, that runs from Head on a Time-driven source that's triggered on an Hourly timer.
Once you set the trigger (and so that you don't have to wait 1 hour to get data), run the script for the first time
That will retrieve (on cells
D2
andD3
) the weather for the city you entered on cellA2
on an hourly basis. You can use that weather data and our Spreadsheets data source to build a text widget using the concatenated cellD4
for your dashboard that will update hourly.
Now you'll know if you need the umbrella when you're heading out.
Tip
There are alternatives to Weatherstack you might want to try. This helpful article reviews several weather APIs that, used in conjunction with Google Sheets' =ImportData() function to retrieve JSON data, can pull detailed weather forecast data to a Google Sheet.