In Chapter 4, Subscribing to Web Services, we wrote a Python program to access weather data from Yahoo! Weather. The class, CurrentWeather, from that program returned the temperature, weather conditions, and wind speed for the city value that the class was instantiated with.
We will revisit that code and change the class name to WeatherData. We will also add a method to return a value from 0-100 to indicate the weather. We will take the temperature and wind speed into account when determining this number, with 0 being extreme winter-like conditions and 100 being very hot extreme summer conditions. We will use this number to control our servo. We will also check to see whether it is raining and update our LED to indicate whether or not we need an umbrella:
- Open up Thonny from Application Menu | Programming | Thonny Python IDE
- Click on the...