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

learning worksheet problem

Tue Dec 06, 2016 6:07 am

Hello!

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
DougieLawson
Posts: 29760
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()
print(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

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 43 guests