Voice Recognition Module V3 and SIM808 not working together

So we’re doing this project where if the user is detected to be intoxicated, it will send an SMS message to his/her friend. We used the voice recognition module as a biomteric.

The problem is our voice recognition module and SMS module don’t seem to work together but when tested individually, it works just fine.

Here is the code:

#include “SIM900.h”
#include “VoiceRecognitionV3.h”
#include <SoftwareSerial.h>
#include “sms.h”

VR myVR(4, 5);

SMSGSM sms;

uint8_t records[7];
uint8_t buf[64];

int numdata;
boolean startSMS = false;

int ledPin = 13;
int motorPin = 9;
int MQpin = A0;

#define helloRec (0)

void setup() {

myVR.begin(9600);

Serial.begin(115200);

pinMode(ledPin, OUTPUT);
pinMode(motorPin, OUTPUT);

if (myVR.clear() == 0){
Serial.println(“Recognizer Cleared”);
}
else {
Serial.println(“Recognizer Not Found”);
while(1);
}

if (myVR.load((uint8_t)helloRec) >= 0){
Serial.println(“helloRec loaded”);
}

if (gsm.begin(2400)){
Serial.println(“status=SMS Module Ready”);
startSMS = true;
}

else {
Serial.println(“status=SMS Module Idle”);
}

}

void loop() {

int ret;
ret = myVR.recognize(buf, 50);
Serial.println(ret);

int MQvalue1 = analogRead(MQpin);

Serial.print(MQvalue1);
Serial.print(" | ");

delay(1000);

int MQvalue2 = analogRead(MQpin);

Serial.println(MQvalue2);

int MQdiff = MQvalue1 - MQvalue2;
Serial.println(MQdiff);

if (ret > 0) {
Serial.println(“ret ok”);
switch(buf[1]){
case helloRec:
Serial.println(“voice detected”);
if (MQdiff > 2 || MQdiff < -2) {
digitalWrite(ledPin, LOW);
Serial.println(“you are drunk!”);
if (startSMS){
sms.SendSMS(“9355377297”, “I can’t drive right now. I need to be picked up. Thanks!”);
Serial.println(“SMS Sent”);
}
break;
}
else {
digitalWrite(ledPin, HIGH);
Serial.println(“you are not drunk”);
break;
}
default:
Serial.println(“Record function undefined”);
break;
}
}
delay(1000);
}

The part that doesn’t work is the ret value. Its value is always -1 so it doesn’t activate the if statement (if ret > 0). But when tested on its own i.e. without the SMS module, the ret value goes up to 9.

What seems to be the problem here? Thanks in advance :slight_smile: