Intro: Read Email With Arduino and Wave Shield
As part of my project here https://www.instructables.com/id/Sound-Switcher/ (that project is in a contest so if you like this then vote for that!) that uses an Arduino to interrupt an extrernal sound source (i.e. iPod) to let you know about things going on around you, I had it also interrupt on emails and read you who the who the email is from and the subject line (so you know if you want to stop what you're doing and check it). Since have an Arduino with a Wave Shield read your email might be useful to others, I spun it off into it's own instructable here. This uses serial to transfer the data. I'm just using the USB interace on the Arduino, but you should be able to accomplish the same thing wirelessly with XBees from what I understand.
So basically the stuff in this instructable will
1. Check your email
2. If something's new it will convert it to a wav file
3. then it will send it to the arduino via serial
4. then the Arduino will play it
The biggest TODO is speeding up the file transfer. My idea is to have the computer send over 100 bytes or so, then wait for an acknowledgement response from the Arduino before it sends more. It would also be nice to have some error checking as well since a partial binary file isn't much better than none at all in some case.
Step 1: Command Line Text to Speech Utility
Here's a little utility I wrote really quick to covert text to speech. It's written in C# with the free Visual C# 2008 Express Edition . You'll probably need .Net 3.5 to run this. The code is included, but if you just want the exe you can get it in CommandLineText2Speech/CommandLineText2Speech/bin/Release in the zip file. To get the tool working you can just open up a command prompt, navigate to the directory where you put the exe, and type CommandLineText2Speech.exe. It will output this:
To list installed voices:
To convert text to a wav:
CommandLineText2Speech.exe [voice] [rate - default 0 (-10 to 10)] [volume - default 80 (0 to 100)] "[text to convert]" [output file]
In other words you'll probably want to first run:
This will list out what voices you have installed on your computer. You'll need the name of a voice to run the tool. The voices that come with Windows aren't great, AT&T has some that are pretty good. Next to convert text to a wav file do this
CommandLineText2Speech.exe "Microsoft Sam" 0 80 "This is a test" test.wav
Here's what it all means:
"Microsoft Sam" - the voice, this is one that comes with Windows, you have to put it in quotes since there's a space
0 - Normal Speed (can go from -10 to 10)
80 - Normal Volume (can go from 0 to 100)
"This is a test" - The text that will be turned into a wav file
test.wav - what the wav file will be called
Step 2: Ruby Utility to Check Email and Upload Wav to Arduino
The attached Ruby code does the following checks to see if there's new email and if there is it transfers it to the Arduino via the USB to Serial interface built into the Arduino. I've had problems with doing high speed connections over Serial (likely the size of the buffer). The settings for the file are all at the top of the file. This uses my C# program to create a wav file. I should probably convert this all to one language, I'm a big fan of Ruby, but it didn't look like it could create the wav from text very easily so I wrote the little C# app.
You'll also need the ruby serial gem, I've included that as well. To install it (after you've installed Ruby) type "gem install win32-serial-0.5.1-x86-mswin32-60.gem" in the command prompt of the directory where you download the gem to. That's all you should need for this program to work.
Step 3: Arduino Code
Here's an example of reading in the data via serial, copying it to the SD card, then playing the wave. This is part of my instructable here https://www.instructables.com/id/Sound-Switcher/ (notice it's in the Arudino contest, if you like it vote for it!). I'll add another example in the next day or so that's trimmed down. Look at the check_serial function for writing to the SD card. I'm using the WaveRP library found here to do it http://code.google.com/p/waverp/
Step 4: Run It All
Ok, now you have all the parts. To get this working correctly you need to
1. Install Wave Shield on Arduino
2. Connect Arduino to Computer (or use XBee) -- I'm assuming you already have the firmware installed
3. Run the Ruby checkEmail.rb script
4. Enjoy your Arduino reading your email.