Arduino – Emic 2 text-to-speech module triggered from Winsen mq-4 gas sensor



Here is the Emic 2 text-to-speech module, along with the Winsen mq-4 gas sensor! In this example, the gas sensor triggers the Emic 2 to create a voice alert that butane, propane, methane or other natural gas byproducts are in the air. The sensor also detects difluoroethane – compressed air, and also other combustible gases.

Here is the Winsen sensor data:

Here is the Emic 2 data:

mq-4 gas sensor

mq-4 gas sensor

The gas sensor detects the gas via the Arduino, then triggers the Emic 2 to issue a voice alert when the gas ppm value crosses a designated threshold.

The Emic 2 module also has many customization parameters for the voice styles.

The text to speech module will inspire some great ideas for projects, I think! So will the gas sensor. A combination of the various gas sensors would make for a perfect home safety device.

mq-4 pin connections

mq-4 pin connections

Pin Connections for the mq-4 gas sensor. (use these mq-4 pin connections, not the ones from the schematic below. The ground connections are correct here)

I found that a small alligator clip across the 5v pins works great to quickly connect all three.



Arduino code:

//mq-4 gas sensor,emic2 text to speech module-arduino

int sensorValue;
// include the SoftwareSerial library to talk to the Emic2


#define rxPin 2 // Serial input (connects to Emic 2 SOUT)
#define txPin 4 // Serial output (connects to Emic 2 SIN)
#define ledPin 13 // Most Arduino boards have an on-board LED on this pin
const int threshold = 220; //level at which mq-4 sensor issues alert

// set up a new serial port
SoftwareSerial emicSerial = SoftwareSerial(rxPin, txPin);
void setup()
Serial.begin(9600); // sets the serial port to 9600

// define pin modes
pinMode(ledPin, OUTPUT);
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);

// set the data rate for the SoftwareSerial port

digitalWrite(ledPin, LOW); // turn LED off

When the Emic 2 powers on, it takes about 3 seconds for it to successfully
intialize. It then sends a ":" character to indicate it's ready to accept
commands. If the Emic 2 is already initialized, a CR will also cause it
to send a ":"
emicSerial.print('\n'); // Send a CR in case the system is already up
while ( != ':'); // 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

void loop()
sensorValue = analogRead(0); // read analog input pin 0

if (sensorValue > threshold) {
emicSerial.print(">>>>:-)3Gas detected! >>>>:-)0Gas detected. <<<<<<<<:-)7Propane or Methayne or Beeeeeutayne detected."); // Text-to-speech phonetics
digitalWrite(ledPin, HIGH); // Turn on LED while Emic is outputting audio
while ( != ':'); // Wait here until the Emic 2 responds with a ":" indicating it's ready to accept the next command
digitalWrite(ledPin, LOW);

//emicSerial.print(sensorValue); // say the sensor level
//digitalWrite(ledPin, HIGH); // Turn on LED while Emic is outputting audio
//while ( != ':'); // Wait here until the Emic 2 responds with a ":" indicating it's ready to accept the next command
//digitalWrite(ledPin, LOW);


Serial.println(sensorValue, DEC); // prints the value read
delay(2000); // wait 100ms for next reading

You may also like...

2 Responses

  1. Natalie McCormick Fullmer says:

    A very useful tool for those of us who live in the “petroleum belt”. My husband purchased a very expensive air monitoring system for Fort Laramie National Historic Site (2/10ths of a mile from a rail/petroleum loading facility that burns toxic waste), and has been disappointed. It seems to never function properly, and requires a tech from very far away to come and constantly fix its “isms”. Will you be marketing these? If so, national parks might be a good venue for you.

Leave a Reply

Your email address will not be published.