Acquisition of weather information (DarkSky)

background

To make it the display content of the LCD attached to the Raspberry Pi I tried to link with an external API.

Method

There was a lot of information about Livedoor's weather information API, Since the LCD does not support kanji, I decided to look for it, including overseas ones.

I made it with DarkSKy. It's English, but I didn't find it so difficult. Free up to 1,000 calls per day. In my case, I only went to pick it up once every 20 minutes, so First of all, it does not exceed.

  1. Create an account with SIGN UP on the upper right.
  2. After email authentication, your secret will be displayed, so set it
  3. Set the weather of the day while looking at the API document
url2='https://api.darksky.net/forecast/(secret)/(longitude latitude)
    data=requests.get(url2).json()
    separated_data=data['daily']['data'][0]['summary'].split()
    len(separated_data)
    forecast_time=date.fromtimestamp(data['daily']['data'][0]['time'])
    payload5=str(forecast_time.month)+"-"+str(forecast_time.day)+" "+separated_data[0]
    separated_data_l2=separated_data.pop(0)
    payload6=' '.join(separated_data)
   print(payload5)
   print(payload6)
   lcd_string(payload5, LCD_LINE_1)
   lcd_string(payload6, LCD_LINE_2)
   time.sleep(5)  

Status

I tried it for a few days, but I haven't removed it at the overview level, so Is it enough to see on a 16-digit, 2-line LCD? ..

Recommended Posts

Acquisition of weather information (DarkSky)
Slack notification of weather information on OpenWhisk
Basics of Quantum Information Theory: Entropy (2)
Notify LINE of train operation information
Get weather information with Python & scraping