to be taken to the Personal Weather Station Network page, and
then click the “Register” tab.
4. Click “Add New Device” (Figure 10-1).
5. On the Add New Device page, choose Raspberry Pi from the
drop down menu under Personal Weather Station and click
“Next”.
6. Now enter your home address (or wherever you want to use
your Pi weather station) and click “Next”. On the next screen,
give your device a name and enter a height above the ground at
which your device will be stored. Accept the Privacy Agreement
and click “Next.”
7. At this point your registration is complete (figure 10-2).Copy
the credentials down, as you’ll need them later, and then click
the “My Devices” button. Finally, on
that
page, click the API Keys
tab. Check the Terms of Service checkbox and click “Generate
New Key”. Your new API key will be generated and populated into
the text box. You should copy it somewhere and save it.
8. From here, if you click the “View API Documentation” button,
you’ll be taken to a Google docs page detailing the APIs that are
available to you. To learn more about how to use any of them,
click on its associated link at the right. For this project, click on
the “Forecast” link at the bottom.
9. This will take you to another Google doc page with five pages
of information about the fields available, what they each mean,
different API calls you can make, the parameters required
for each, and finally an example of a JSON response to one of
the API calls. Take a look at the first line, which shows the URL
needed to get the weather forecast at any location. Note that
embedded in the URL is your API key, as well as the latitude and
longitude of a particular weather station (I’m not sure which
one). The API key is not filled in in the example, but the latitude
and longitude are. If you want to see the forecast for any place
on earth, you can use your own API key, and just change the
location in the URL.
10. To try out the forecast API, copy the URL to your brows-
er address bar, substituting your API key where required. You
170 Getting Started with Raspberry Pi
GSW_RASPI_4ED_FIN.indd 170GSW_RASPI_4ED_FIN.indd 170 10/28/21 10:54 AM10/28/21 10:54 AM