The PiWake uses text-to-speech software to daily notify me when I wake up what the high temperature and suggested clothing are for a particular day. This is based off my Weather Texter tutorial (except this speaks and doesn’t text). However, you are welcome to combine both programs (it shouldn’t take too long) and have it both speak AND text!

Note that you will need speakers that can plug into the headphone jack of the Raspberry Pi.

I’m assuming that you have set up the Pi with Raspbian Wheezy and have Internet set up. If not, check out this tutorial.

Step 1: Enable SSH

Before we start, we will want to enable SSH if it is not enabled already. Hook up the Pi to an external screen such as a TV. In the terminal of the Raspberry Pi, type in sudo raspi-config, go down to SSH, press enter, go down to Enable, and press OK.

Once you are back in the terminal, you will need to find your IP address. This can be done by typing in hostname -I.

You will no longer need the external screen.

Using your SSH software (for Windows you will have to install PuTTY, while Linux/Mac users can use the Terminal), log into the Raspberry Pi from your computer. PuTTY will just have to type in the IP address in the field next to the port (which should be 22); Terminal users will have to type in pi@INSERT_IP_ADDRESS_HERE. Once you press enter, you will reach a rather basic login screen:

If you haven’t changed the username already, it will by pi by default. So, type in pi and press enter. The password, if not changed, will be raspberry, so type raspberry and press enter.

You will see some Linux messages and then see a command prompt:

Step 2: Install Voice Command

Run the following commands in the Terminal if you do not have Python/Pip set up on your Raspberry Pi:

sudo apt-get install festival

Step 3: Python Coding

First, cd Desktop.

Either transfer the following code to the Raspberry Pi via FTP (save on your computer, then transfer to a place like the Desktop), or type it in manually in SSH (cd Desktop, sudo nano weather_sound.py). I will be calling the file weather_sound.py. Either way, you will have to make the edits needed along the way:

#!/usr/bin/env python import urllib, os from xml.dom import minidom wurl = 'http://xml.weather.yahoo.com/forecastrss?p=%s' # weather rss wser = 'http://xml.weather.yahoo.com/ns/rss/1.0' def weather_for_zip(zip_code): url = wurl % zip_code +'&u=f' dom = minidom.parse(urllib.urlopen(url)) forecasts = [] for node in dom.getElementsByTagNameNS(wser, 'forecast'): forecasts.append({ 'high': node.getAttribute('high'), # gets high temperature attribute }) ycondition = dom.getElementsByTagNameNS(wser, 'condition')[0] return { 'forecasts': forecasts , 'title': dom.getElementsByTagName('title')[0].firstChild.data } a=weather_for_zip("60126") # Insert your zip code here hight = a['forecasts'][0]['high'] # Defines hight as the high temperature temp = int(hight) stt = str(temp) if temp < 60: string = ' echo "Good Morning Master! It will be %s degrees. As it will be cold, may I suggest you wear a hoodie?" | festival --tts' % (stt) os.system(string) elif temp >= 60 and temp < 85: string = ' echo "Good Morning Master! It will be %s degrees. It is the perfect day to wear a button down shirt with your Calvin Klein Jeans!" | festival --tts' % (stt) os.system(string) else: string = ' echo "Good Morning Master! It will be %s degrees. I believe a t-shirt and shorts will suffice!"| festival --tts' % (stt) os.system(string)

Save the code by pressing Ctrl-X, Y, then enter.

Step 4: Plug in the Speakers, and do a test run.

Plug in the speakers. Then type python weather_sound.py. It will take a few seconds, but soon you will hear a voice telling you good morning, the high temperature, and what you should wear.

Step 5: Make it run daily

Step 6: Run it Daily

I want the Python program to run daily at 6 am. To do this, we must do two things: set the correct time zone and set up a cron job to run daily.

In order to do this, type in the following code and press tab:

sudo cp /usr/share/zoneinfo

You should see a bunch of subfolders:

Keep typing in the correct subfolder and tab until you have the correct time zone or closest city. For example, I would have typed in:

sudo cp /usr/share/zoneinfo/America/Chicago

Add the following to to the end (with a space at the beginning):

/etc/localtime

My line should look like this:

sudo cp /usr/share/zoneinfo/America/Chicago /etc/localtime

Press enter to confirm the changes. Then type in sudo crontab -e. This will open up crontab, which runs tasks at certain times. Scroll down to the bottom of the document, and type in the following:

0 6 * * * python /path/to/program/weather.py

Insert the path to your program where it says /path/to/program. If your program is on the Desktop (like mine is), you should have typed this:

0 6 * * * python /home/pi/Desktop/weather.py

You can change the 0 to the certain minute (0-59) and 6 to the certain hour (0-23) you want the program to run.

Press Ctrl-X to exit and Y to save. You should see the following message:

That’s it! The program will now run once at a day at the time specified!

I did want to provide special thanks to python-catalin for the Simple Python script! You can edit my script and add more parameters such as current temperature and conditions. Just click here for helpful information!