Posts: 1
Joined: Tue Dec 06, 2016 5:56 am

learning worksheet problem

Tue Dec 06, 2016 6:07 am


I've been following the instructions for this worksheet, and I'm having problems with the rain.

Every location I check (even places where it's been storming) the rainfall always comes back as 0. Is there a way to fix this?

User avatar
Posts: 32361
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: learning worksheet problem

Wed Dec 07, 2016 8:08 am

Try the Web interface http://openweathermap.org/city/2656192 (search for your own city) make sure their data is correct.

sudo pip3 install pyowm

Try this python3 program

Code: Select all

import pyowm

owm = pyowm.OWM('ed2fredactedapikeyc500206b3fbde4')  # You MUST provide your valid API key
observation = owm.weather_at_place('Basingstoke,uk') ## CHANGE ME ##
weather = observation.get_weather()
rain = weather.get_rain()
wind = weather.get_wind()
humidity = weather.get_humidity()
temp = weather.get_temperature('celsius')
print ("Rain:", rain, " Wind:",  wind, " Humidity:",  humidity, "Temp:", temp)
Which isn't getting any sensible rain value for me. So the problem may exist with the OpenWeather API not with your Scratch program.

Run that with python3 myweather.py

You can test your API key with http://api.openweathermap.org/data/2.5/ ... 206b3fbde4 you will need to change that URL to use your API key not my redacted version.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 8 guests