TeCoEd (Teaching Computing Education)
  • Home
    • Freelance
    • Book
    • Downloading
  • Python
    • Learn Python >
      • Python Modules
    • PyGame Zero
    • Python Programs >
      • Higher or Lower
      • Magic Calculator
      • Password Checker
      • Python Pit
    • What's News App
    • Pixels to Cells
    • Python Mosaics
    • Python OCR
    • L-1-AM
    • Web Scraping >
      • Scraping Trains
    • Weather App
    • Snakes and Windows
    • Python Web Server >
      • Flask
    • Python Picks
  • Raspberry Pi
    • All About the Pi
    • Getting Started
    • Remote Desktop and VNC
    • Static IP Address
    • Sonic Pi >
      • 3.14
    • Twitter Feed >
      • Tweepy
    • Android & Pi >
      • Advanced Apps
      • Odds
    • A.I on the the Pi
    • CRON
    • Pick Your Own
  • Pi Hardware
    • Pi HATS >
      • Sense Hat Hacks
      • AstroPi HAT
      • Unicorn-HAT >
        • Unicorn Alphabet Disco
        • Uni Codes / Programs
      • Skywriter
      • Piano HAT
    • STS Pi
    • Pi Camera >
      • Pi-Cam, Python & Email >
        • Time Lapse
      • Pi Noir
    • Pipsta >
      • Flask, Input & Printers
    • Raspberry Pi Power >
      • Energenie IR power
    • Pibrella
    • Distance Sensor
    • LCD Screen
    • Pi-Tooth
    • Robot Arm
    • PiGlow
    • PiFM
    • Accelerometer
    • PiFace >
      • Installing PiFace >
        • Python Commands
  • Pi-Hacks
    • Drone Hacks
    • Pi Glue Gun Hack
    • Blinkt!
    • Sonic Pixels
    • R2D2
    • Get to the chopper
    • Astro Bird
    • Twitter Translator
    • Hacking a Robot
    • Nature_Box >
      • Best Nature Photos
    • Wearable Tech >
      • Project New York
      • P.N.Y Part 2 Health
      • P.N.Y Part 3 Games
      • P.N.Y Part 4 Translation
    • Dino-Tweet
    • Other Links
  • Pi-Hacks 2
    • The Joker
    • Hologram Machine
    • Google Vision: Camera Tell
    • Yoda Tweets
    • Pi Phone
    • Darth Beats
    • Twitter Keyword Finder
    • Crimbo Lights Hack
    • Xmas Elf
    • Halloween 2016
    • Halloween Hack 2015
    • Socrative Zombie
    • Voice Translation
    • The Blue-Who Finder
    • GPIO, Twitter
    • Pi Chat Bot >
      • Dictionary Definitions
    • PiGlow & Email
    • Pibrella Alarm System
    • SMS with Python >
      • Spooking a Mobile
  • Pi-Hacks 3
    • Ferminal
    • Crypto Tracker
    • David Bowie
    • Lamp Prank >
      • TEST
    • Yoda FM
    • Retro Player
    • LED Pixel Art
    • TARDIS
    • Battleships
    • LED Board
    • Night Vision
    • Enviro+ Weather
  • Minecraft
    • Minecraft API
    • Minecraft Sweeper
    • PiGlove: Minecraft Power Up
    • Minecraft Photo-booth
    • Rendering Pixels
    • Speed Cube
    • Lucky Dip
  • Computing
    • Why Computing?
    • Can You Compute
    • micro:bit
    • Coding Resources
    • Learn to Code >
      • Coding with iPads
      • Apps Creation Tools
      • sKratchInn
      • Sound Editing
    • Cheat Sheets
    • Theory
    • HOUR OF CODING
    • BEBRAS Computing Challange
    • Computer Facts
    • Free Software and Links
  • Contact Me

PI PROJECTS: Weather App


What is it?


This project combines a Python Parser and Weather information pulled down from Yahoo Weather page.  A Parser is the process of analysing a string of symbols.
Picture

Python Weather App - Looping

Weather App writing to Text File


Install the Parser Module


In the LX Terminal :

Update your Pi     
Sudo apt-get update

Upgrade your Pi    
Sudo apt-get upgrade

Search for the python Parser in the repositories, 
Sudo apt-cache search feed parser

Install the Parser
sudo apt-get install python-feedparser

How To:


First go to the Yahoo Weather Website and enter the location where you want to draw the weather data from, eg London.

Yahoo Weather
Picture
In the address bar there will be a 5 digit number that denotes the ID of the location, for example London is http://uk.weather.yahoo.com/united-kingdom/england/london-44418/, ID number 44418, you will need the ID number for your own location. 

The basic code function is 
rss_link ='http://weather.yahooapis.com/forecastrss?w=44418u=c'
where the temperature is return in either 'c' Celsius or 'f' Fahrenheit then add the code 
d = feedparser.parse(rss_link)

Next use the Parser to pull down the required data, this is stored in categories which are listed at the Yahoo developer site. For example, 
atmosphere = d.feed.yweather_atmosphere 

This pulls down  the related related data from the atmosphere category  from this the humidity value can be selected and stored, 
humidity = atmosphere['humidity']

Then use the print function to display the data
print "Humidity for "+city, humidity

Program examples for London Weather:
Program 1 -Original program with looping feature
Program 2 - Weather data is written to a text file called weather_summary

Further development details can be found at Yahoo Developer 


Powered by Create your own unique website with customizable templates.