Arduino Uno and Emic 2 TTS

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
edster484
 
Posts: 2
Joined: Sun Jun 30, 2013 11:06 pm

Arduino Uno and Emic 2 TTS

Post by edster484 »

Hello All,
I have recently discovered the world of Arduino and I have to thank Adafruit for giving me the
courage to attempt some of these projects. I have recently purchased a Emic 2 TTS module and a UNO with
the intention of making a clock/temperature station. The idea was to have the Emic TTS read out
the time and temperature at any given moment, by push button or, on the hour automatically.
I am asking what are the code instructions for me to "grab" the temperature reading, humidity and/or current
time so it can be converted to speech. I have successfully combined two sketches so far for the DHTxx sensor
and Emic Demo sketch and run the clock module as well but separately. The plan is to eventually make this project into a home security system/information center that will
audibly relay information about the sensors. But right now a need some help with the Emic TTS commands to get it
to speak out readings. I tried to post the code from the arduino ide but when I do it adds alot of extranious information to it, am I missing something? :?
Thanks

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Arduino Uno and Emic 2 TTS

Post by adafruit_support_rick »

edster484 wrote:I tried to post the code from the arduino ide but when I do it adds alot of extranious information
Not sure what you mean by "extraneous information"? You should be able to select the code in the IDE editor, copy, and paste it here.
Click the 'Code' button here, and then paste the code betwee nthe tags.

edster484
 
Posts: 2
Joined: Sun Jun 30, 2013 11:06 pm

Re: Arduino Uno and Emic 2 TTS

Post by edster484 »

Ok, this is the code I have been working with. If i can get some help with the commands I should be able to incorporate voice output into a
larger sketch I have. From what little I know, the Emic is a serial device so there is no need for a library is there?

Code: Select all

[quote]




[color=#7E7E7E]/*[/color]
[color=#7E7E7E]  [/color]
[color=#7E7E7E]  Emic 2 Text-to-Speech Module: Basic Demonstration       [/color]
[color=#7E7E7E]                                                         [/color]
[color=#7E7E7E]  Author: Joe Grand [www.grandideastudio.com]             [/color]
[color=#7E7E7E]  Contact: [email protected]                            [/color]
[color=#7E7E7E]  [/color]
[color=#7E7E7E]  Program Description:[/color]
[color=#7E7E7E]  [/color]
[color=#7E7E7E]  This program provides a simple demonstration of the Emic 2 Text-to-Speech[/color]
[color=#7E7E7E]  Module. Please refer to the product manual for full details of system [/color]
[color=#7E7E7E]  functionality and capabilities.[/color]

[color=#7E7E7E]  Revisions:[/color]
[color=#7E7E7E]  [/color]
[color=#7E7E7E]  1.0 (February 13, 2012): Initial release[/color]
[color=#7E7E7E]  [/color]
[color=#7E7E7E]*/[/color]

[color=#7E7E7E]// include the SoftwareSerial library so we can use it to talk to the Emic 2[/color]
#include <SoftwareSerial.h>
#include [color=#006699]"DHT.h"[/color]
#define DHTPIN 4     [color=#7E7E7E]// what pin we're connected to[/color]

#define rxPin 2    [color=#7E7E7E]// Serial input (connects to Emic 2 SOUT)[/color]
#define txPin 3    [color=#7E7E7E]// Serial output (connects to Emic 2 SIN)[/color]
#define ledPin 13  [color=#7E7E7E]// Most Arduino boards have an on-board LED on this pin[/color]
#define DHTTYPE DHT22   [color=#7E7E7E]// DHT 22  (AM2302)[/color]

DHT dht(DHTPIN, DHTTYPE);

[color=#7E7E7E]// set up a new serial port[/color]
SoftwareSerial emicSerial =  SoftwareSerial(rxPin, txPin);

[color=#CC6600]void[/color] [color=#CC6600][b]setup[/b][/color]()  [color=#7E7E7E]// Set up code called once on start-up[/color]
{
 [color=#CC6600][b]Serial[/b][/color].[color=#CC6600]begin[/color](9600); 
  [color=#CC6600][b]Serial[/b][/color].[color=#CC6600]println[/color]([color=#006699]"DHT21 test!"[/color]);
 
  dht.[color=#CC6600]begin[/color]();
  
  [color=#7E7E7E]// define pin modes[/color]
  [color=#CC6600]pinMode[/color](ledPin, [color=#006699]OUTPUT[/color]);
  [color=#CC6600]pinMode[/color](rxPin, [color=#006699]INPUT[/color]);
  [color=#CC6600]pinMode[/color](txPin, [color=#006699]OUTPUT[/color]);
  
  [color=#7E7E7E]// set the data rate for the SoftwareSerial port[/color]
  emicSerial.[color=#CC6600]begin[/color](9600);

  [color=#CC6600]digitalWrite[/color](ledPin, [color=#006699]LOW[/color]);  [color=#7E7E7E]// turn LED off[/color]
  
  [color=#7E7E7E]/*[/color]
[color=#7E7E7E]    When the Emic 2 powers on, it takes about 3 seconds for it to successfully[/color]
[color=#7E7E7E]    intialize. It then sends a ":" character to indicate it's ready to accept[/color]
[color=#7E7E7E]    commands. If the Emic 2 is already initialized, a CR will also cause it[/color]
[color=#7E7E7E]    to send a ":"[/color]
[color=#7E7E7E]  */[/color]
  emicSerial.[color=#CC6600]print[/color]([color=#006699]'\n'[/color]);             [color=#7E7E7E]// Send a CR in case the system is up[/color]
  [color=#CC6600]while[/color] (emicSerial.[color=#CC6600]read[/color]() != [color=#006699]':'[/color]);   [color=#7E7E7E]// Wait for ':' character[/color]
  [color=#CC6600]delay[/color](10);                          [color=#7E7E7E]// Short delay[/color]
  emicSerial.[color=#CC6600]flush[/color]();                 [color=#7E7E7E]// Flush the receive buffer  [/color]
   
  [color=#7E7E7E]// Set volume to 12[/color]
  emicSerial.[color=#CC6600]print[/color]([color=#006699]"V1\n"[/color]);
  [color=#CC6600]while[/color] (emicSerial.[color=#CC6600]read[/color]() != [color=#006699]':'[/color]);   [color=#7E7E7E]// wait for ':' character[/color]

  [color=#7E7E7E]// Speak some text[/color]
  emicSerial.[color=#CC6600]print[/color]([color=#006699]'S'[/color]);
  emicSerial.[color=#CC6600]print[/color]([color=#006699]"Hello. . This "[/color]);
  emicSerial.[color=#CC6600]print[/color]([color=#006699]"is the EMIC 2, text to speech module. I am easy to use, "[/color]);
  emicSerial.[color=#CC6600]print[/color]([color=#006699]"just send me a text string and i will speak it for you."[/color]);
  
  emicSerial.[color=#CC6600]print[/color]([color=#006699]'\n'[/color]);
  [color=#CC6600]while[/color] (emicSerial.[color=#CC6600]read[/color]() != [color=#006699]':'[/color]);   [color=#7E7E7E]// Wait for ":" character[/color]
}

[color=#CC6600]void[/color] [color=#CC6600][b]loop[/b][/color]()  [color=#7E7E7E]// Main code, to run repeatedly[/color]
{
   [color=#7E7E7E]// Reading temperature or humidity takes about 250 milliseconds![/color]
  [color=#7E7E7E]// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)[/color]
  [color=#CC6600]float[/color] h = dht.readHumidity();
  [color=#CC6600]float[/color] t = dht.[color=#CC6600]readTemperature[/color]();

  [color=#7E7E7E]// check if returns are valid, if they are NaN (not a number) then something went wrong![/color]
  [color=#CC6600]if[/color] (isnan(t) || isnan(h)) {
    [color=#CC6600][b]Serial[/b][/color].[color=#CC6600]println[/color]([color=#006699]"Failed to read from DHT"[/color]);
  } [color=#CC6600]else[/color] {
    [color=#CC6600][b]Serial[/b][/color].[color=#CC6600]print[/color]([color=#006699]"Humidity: "[/color]); 
    [color=#CC6600][b]Serial[/b][/color].[color=#CC6600]print[/color](h);
    [color=#CC6600][b]Serial[/b][/color].[color=#CC6600]print[/color]([color=#006699]" %\t"[/color]);
    [color=#CC6600][b]Serial[/b][/color].[color=#CC6600]print[/color]([color=#006699]"Temperature: "[/color]); 
    [color=#CC6600][b]Serial[/b][/color].[color=#CC6600]print[/color](t);
    [color=#CC6600][b]Serial[/b][/color].[color=#CC6600]println[/color]([color=#006699]" *C"[/color]);
  }
  [color=#CC6600]delay[/color](5000);
}

[/quote]

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Arduino Uno and Emic 2 TTS

Post by adafruit_support_rick »

Wow - I see what you mean by "extraneous information" I have no idea whatsoever how you are getting all that. Are you pasting into something else first, and then transferring it from there to here?

Anyway, the Emic Product Document sheet (linked on the "Downloads" tab of our product page) tells you everything you need to know about the command set, and provides examples.

http://www.parallax.com/Portals/0/Downl ... h-v1.1.pdf

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

Return to “Arduino”