Integrations and Dark Skies

Some integrations are available for Adafruit IO Plus members only. For example, we have a Weather service that hooks into Dark Sky, a premier forecasting service. Once you start building IoT projects, you’ll notice that getting weather data on demand isn’t easy - almost every service requires authentication and most require payment. With our Dark Sky integration, it's quite easy to get weather data whenever you like, which you can use to make projects that react to current conditions in the local area, or really anywhere you like.

Once you have upgraded to Adafruit IO Plus, add a location to your service. Say, Thief River Falls, Minnesota. Now you can query the forecast or current weather for that location. For example, here’s some Python code that will get the current weather condition and forecast, and print it out. When I run it, we see...it’s crisp and cool this winter afternoon.

"""
'weather.py'
================================================
Dark Sky Hyperlocal for IO Plus
with Adafruit IO API

Author(s): Brent Rubell for Adafruit Industries
"""
# Import JSON for forecast parsing
import json
# Import Adafruit IO REST client.
from Adafruit_IO import Client, Feed, RequestError

# Set to your Adafruit IO key.
ADAFRUIT_IO_USERNAME = 'YOUR_IO_USERNAME'
ADAFRUIT_IO_KEY = 'YOUR_IO_PASSWORD'

# Create an instance of the REST client.
aio = Client(ADAFRUIT_IO_USERNAME, ADAFRUIT_IO_KEY)

# Grab the weather JSON
weather = aio.receive_weather(1234)
weather = json.dumps(weather)
forecast = json.loads(weather)

# Parse the current forecast
current = forecast['current']
print('Current Forecast')
print('It is {0} and {1}.'.format(current['summary'], current['temperature']))

# Parse the two day forecast
forecast_days_2 = forecast['forecast_days_2']
print('\nWeather in Two Days')
print('It will be {0} with a high of {1}F and a low of {2}F.'.format(
            forecast_days_2['summary'], forecast_days_2['temperatureLow'], forecast_days_2['temperatureHigh']))

# Parse the five day forecast
forecast_days_5 = forecast['forecast_days_5']
print('\nWeather in Five Days')
print('It will be {0} with a high of {1}F and a low of {2}F.'.format(
            forecast_days_5['summary'], forecast_days_5['temperatureLow'], forecast_days_5['temperatureHigh']))

We’ve gone over just about all of the amazing features that Adafruit IO provides, and Adafruit is constantly adding more. In fact, there are probably more services and features that have been added since. You can always get updates on the latest news by checking out the Adafruit blog, and the most recent documentation, available here!

This guide was first published on Mar 14, 2019. It was last updated on Mar 19, 2024.

This page (Adafruit IO Plus Integrations) was last updated on Mar 19, 2024.

Text editor powered by tinymce.