Get an EMIC TODAY!

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
fmbfla
 
Posts: 110
Joined: Fri Jun 08, 2012 6:48 pm

Get an EMIC TODAY!

Post by fmbfla »

I recently received my Emic from AdA a few weeks ago and I have been having a blast with it.
I have some code for anyone to use, it uses a TMP36 but I have used it with my DHT and it is way coool.
The code Attached is for the TMP and has bogus humidity sensor readings but if you are this far then you can easily make the the lines for the DHT and or a BMP or all the above.
My Wunderground set up is werking great so I don't have the sensors available to play with :-(.

Code: Select all

/*

 Emic 2 Text-to-Speech Module: Basic Demonstration 
 This is a basic test of the EMIC 2 Module in use with voice changing capabilities and Software based time an temperature readings
Follow the instructions for each device prior to loading this sketch PLEASE!
I Will Not Be Responsible for Purple Smoke :-)
 
              http://www.adafruit.com/products/924  Emic 2 Text-to-Speech

              http://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit

              http://learn.adafruit.com/tmp36-temperature-sensor

 
 Author: Joe Grand [www.grandideastudio.com]             
 Contact: [email protected]                            
 
 Program Description:
 
 This program provides a simple demonstration of the Emic 2 Text-to-Speech
 Module. Please refer to the product manual for full details of system 
 functionality and capabilities.
 
 Revisions:
 
 1.0 (February 13, 2012): Initial release
 example voice "emicSerial.print("N1\n");"//Voice
 0: Perfect Paul (Paulo) 
 1: Huge Harry (Francisco) 
 2: Beautiful Betty 
 3: Uppity Ursula 
 4: Doctor Dennis (Enrique) 
 5: Kit the Kid 
 6: Frail Frank 
 7: Rough Rita 
 8: Whispering Wendy (Beatriz)
 */
// include the SoftwareSerial library so we can use it to talk to the Emic 2 module
#include <SoftwareSerial.h>
#define rxPin 2    // Serial input (connects to Emic 2 SOUT)
#define txPin 4    // Serial output (connects to Emic 2 SIN)//pin 3 conflicts with CC3000 WiFI else use pin 2
SoftwareSerial emicSerial =  SoftwareSerial(rxPin, txPin);
#include <Wire.h>
#include "RTClib.h"
#define aref_voltage 3.3         // we tie 3.3V to ARef and measure it with a multimeter!
int tempPin = 0;        //the analog pin the TMP36's Vout (sense) pin is connected to
//the resolution is 10 mV / degree centigrade with a
//500 mV offset to allow for negative temperatures
int tempReading;        // the analog reading from the TMP36 sensor
char* Month[] = {
  "null", "January,", "Febuary,", "March,", "April,", "May,", "June,", "July,", "August,", "September,", "October", "November,", "December,"};
// Sunday is 0 from the now.dayOfWeek() call of the RTC
char* weekDays[] = {
  "Sunday,", "Monday,", "Tuesday,", "Wednesday,", "Thursday,", "Friday,", "Saturday,"};
char* Day[] = {
  "null", "First", "Second", "Third","Forth", "Fifth", "Sixth", "Seventh","Eighth", "Nineth", "Tenth", "Eleventh", "Twelfth","Thirteenth","Fourteenth","fifthteenth","Sixteenth","Seventeenth","EightTeenth","Nine Teenth","Twenty eth","Twenty first","Twenty Second","Twenty third","Twenty Forth","Twenty Fifth","Twenty Sixth","Twenty Seventh","Twenty Eighth","Twenty Ninth"," Thirty eth","Thirty First"}; 
unsigned int Sample = 0;          // Sample number

RTC_Millis rtc;

void setup()  // Set up code called once on start-up
{

  analogReference(EXTERNAL);
  rtc.begin(DateTime(__DATE__, __TIME__));
  // define pin modes
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  Serial.begin(9600);
  // set the data rate for the SoftwareSerial port
  emicSerial.begin(9600);
}

void loop()  // Main code, to run repeatedly
{
  
  tempReading = analogRead(tempPin);  
  float voltage = tempReading * aref_voltage;
  voltage /= 1024.0; 
  float temperatureC = (voltage - 0.5) * 100 ;  //converting from 10 mv per degree wit 500 mV offset
  int temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;// made it an int so that it wouldnt speak the last to decs
  Sample++;
  Serial.println(Sample);
  DateTime now = rtc.now();

  Serial.println ("Time");
    emicSerial.print('\n');//tell emic your done sending text
  while (emicSerial.read() != ':');   // When the Emic 2 has initialized and is ready, it will send a single ':' character, so wait here until we receive it
  delay(10);                          // Short delay
  emicSerial.flush();                 // Flush the receive buffer
  
  emicSerial.print("V18\n");// Speaking Volume (0 - 18) 18 = highest
  emicSerial.print("W175\n"); //Speed 0 - 200 = fastest
  emicSerial.print("N0\n");//Voice 0 - 8
  emicSerial.print('S'); //tell emic your ready to send text
  emicSerial.print(" And Todays date is.");
  emicSerial.print(now.dayOfWeek()[weekDays]);
  emicSerial.print(now.month()[Month]);
  emicSerial.print(now.day()[Day]);
  emicSerial.print(" And The Current Time is.");
  if(now.hour() < 10){            // Zero padding if value less than 10 ie."09" instead of "9"
    emicSerial.print((now.hour() > 12) ? now.hour() - 12 : ((now.hour() == 0) ? 12 : now.hour()), DEC); // Conversion to AM/PM 
  }
  else{
    emicSerial.print((now.hour() > 12) ? now.hour() - 12 : ((now.hour() == 0) ? 12 : now.hour()), DEC); // Conversion to AM/PM
  }
  emicSerial.print(" ");//space to break up the time
  if(now.minute() < 10){          // if minute sare less than 10
    emicSerial.print("oh,"); // Put an "oh " here so the emic say's. like we would say "three-oh-five PM" like we would say "three-oh-five PM".
    emicSerial.print(now.minute());
  }
  else{
    emicSerial.print(now.minute()); //emic will say the minutes as the are read
  }
  if(now.hour() < 12){           // Adding the AM/PM sufffix 
    emicSerial.println(" AM. And-now. Betty with the Weather. "); // ie; if less than 12, say AM
    emicSerial.print('\n');//tell emic your done sending text
    while (emicSerial.read() != ':');  
    delay(100);                          
    emicSerial.flush();
  }
  else{
    emicSerial.println(" PM. And-now. Betty with the Weather. ");//If more than 12, then say PM
    emicSerial.print('\n');//tell emic your done sending text
    while (emicSerial.read() != ':');  
    delay(100);                          
    emicSerial.flush();
    Serial.println ("Weather");
    
  }
  emicSerial.print('\n');//tell emic your done sending text
  while (emicSerial.read() != ':');  
  delay(10);                          
  emicSerial.flush();
  emicSerial.print("W150\n"); //Speed 0 - 200 = fastest
  emicSerial.print("N2\n");//Voice 0 - 8
  emicSerial.print('S'); //tell emic your ready to send text
  //test readings 
  emicSerial.print("Thank-you Paul. The Current Temprature is,");
  emicSerial.print(temperatureF); 
  emicSerial.print("Degrees Fair-in-Height. With A Rell-Ah-tiv Humiduh-Tee, at 31.5 %.  And we will be back in five minutes");
  Serial.println ("END");
  Serial.println(now.minute());
 //this is where you PAUSE
 //delay between brodcasts
emicSerial.print('\n');//tell emic your done sending text
  if  (emicSerial.read() != ':'){  
  delay(90000L*3.25);// time between loops
  //delay(5000);
}

}






Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”