EasyVR not working

Using EasyVR Commander, I have added commands, trained and tested them with no problems. I can speak into the mic and all commands are recognized. Moving on to the next step, I am now trying to do some basic testing using Arduino. I am using the following code

// compiles clean //
/*
Code to use the EasyVR shield to control a 230v light.

To use this code, download the EasyVR library first.
http://www.veear.eu/downloads/

This code is based on an example-code made by Veear and is used in the Mikelab series on YouTube

*/


#if defined(ARDUINO) && ARDUINO >= 100
  #include "Arduino.h"
  #include "SoftwareSerial.h"
  SoftwareSerial port(12,13);
#else // Arduino 0022 - use modified NewSoftSerial
  #include "WProgram.h"
  #include "NewSoftSerial.h"
  NewSoftSerial port(12,13);
#endif

#include "EasyVR.h"

#define SND_BEEP  0


EasyVR easyvr(port);
EasyVRBridge bridge;
uint32_t mask = 0;
int8_t group = 0;
uint8_t train = 0;
char name[32];
boolean onestat = true;
boolean twostat = true;
boolean threestat = true;
boolean fivestat = true;
boolean sixstat = true;




void setup()
{

pinMode(6,OUTPUT);
  digitalWrite(6,LOW);
  
  // bridge mode?
  if (bridge.check())
  {
    cli();
    bridge.loop(0, 1, 12, 13);
  }

  Serial.begin(9600);
  port.begin(9600);
  
  if (!easyvr.detect())
  {
    Serial.println("EasyVR not detected!");
    for (;;);
  }
  
  easyvr.setPinOutput(EasyVR::IO1, LOW);
  Serial.println("EasyVR detected!");
  easyvr.setTimeout(5);
  easyvr.setLanguage(EasyVR::ITALIAN);
  
  int16_t count = 0;
  
  
  if (easyvr.getGroupMask(mask)) // get trained user names and passwords
  Serial.print("mask= ");
  Serial.println(mask,BIN);
  {
	for (group = 0; group <= EasyVR::PASSWORD; ++group)
    {
      if (group == EasyVR::TRIGGER)
        Serial.print("Trigger: ");
      else if (group == EasyVR::PASSWORD)
        Serial.print("Password: ");
      else
      {
        Serial.print("Group ");
       Serial.print(group);
        Serial.print(": ");
      }
      count = easyvr.getCommandCount(group);
      Serial.println(count);
      for (int8_t idx = 0; idx < count; ++idx)
      {
        if (easyvr.dumpCommand(group, idx, name, train))
        {
          Serial.print(idx);
          Serial.print(" = ");
          Serial.print(name);
          Serial.print(", Trained ");
          Serial.print(train, DEC);
          if (!easyvr.isConflict())
            Serial.println(" Times, OK");
          else
          {
            int8_t confl = easyvr.getWord();
            if (confl >= 0);

            else
            {
              confl = easyvr.getCommand();

            }
            Serial.println(confl);
          }
        }
      }
    }
  }
}

void loop()
{

  begin:
  int idx_cmd;	
 
  
  easyvr.setPinOutput(EasyVR::IO1, HIGH); // LED on (listening)
  
  Serial.println("Say a command in group two");  
  easyvr.recognizeCommand(2); // recognise command in group 2 
  while (!easyvr.hasFinished());
  
  easyvr.setPinOutput(EasyVR::IO1, LOW); // LED off
 delay(3000);
  idx_cmd = easyvr.getCommand(); 

  if (idx_cmd >= 0) 
  {    
    Serial.print("Name: ");    
    if (easyvr.dumpCommand(1, idx_cmd, name, train))
    {
      Serial.println(name);
     Serial.println(idx_cmd);
    }  
    else
      Serial.println();    
      
    if (idx_cmd == 2){
     if(onestat == 0){
  
    onestat = 1;
    Serial.println("Lights turned on!"); 
     easyvr.playSound(SND_BEEP  , EasyVR::VOL_FULL);
    goto begin;
    
     }
      else{
      
       onestat = 0;
       Serial.println("Lights turned off!");
        
       easyvr.playSound(SND_BEEP  , EasyVR::VOL_FULL);


       goto begin;
      }
    }
           
    
  
  else
  {
    if (easyvr.isTimeout()) 
        Serial.println("Timed out... try again!");
      
    int16_t err = easyvr.getError();
    if (err >= 0)
    {
     Serial.print("Error ");
      Serial.println(err, HEX);          
    }
  }
}
}

When running this I get the following on the monitor

  • EasyVR detected, version 2

    Sound table: n/a

    Custom Grammars: n/a

    Group 2 has 7 command(s)

    0 = OK, Trained 2 times, OK

    1 = WAKEUP, Trained 2 times, OK

    2 = BEGIN, Trained 2 times, OK

    3 = SMILE, Trained 2 times, OK

    4 = BE_HAPPY, Trained 2 times, OK

    5 = STOP, Trained 2 times, OK

    6 = SHOW, Trained 2 times, OK

    Say a command in Group 0

    Timed out, try again…

    Say a command in Group 0

    Timed out, try again…

    Say a command in Group 0

    Timed out, try again…

    Say a command in Group 0

    Timed out, try again…



  • I’m using exactly the same setup with the shield and microphone as I used with the commander and I cannot get easyVR to recognize anything. Have tried many times.

    Need help to move forward.

    Where is the jumper set? Should be in SW. Did you generate your code from Commander?

    Jumper is set to SW. I followed a tutorial I found and it didn’t call for generating code from commander. Whenever I bring up the EasyVR with Commander, the commands I previously made and trained are still there. Do I still need to gnerate code?

    Yes, every change made to the commands you need to generate a new code. Then upload that code to the Arduino.

    Thanks, it’s working perfectly now. I hadn’t taken a good look at what code was generated. Now it’s very clear.

    Codlink thanks again it’s working very well. Perhaps you would help me with one more thing. I have tried to make simple changes so that I can use the commands in the 3 wordsets. I cannot seem to find the right way though.

    I haven’t had to create new wordsets in my projects. I have only changed the default set. I would think it should be possible in Commander, though… Keep trying and I will do some experimenting but it may take me a couple of days…

    No, I’m not talking about making new wordsets, I would like to use the default ones already on the board. There are wordsets 1,2,3. You can see them from Comander.

    Codlink, the code I have included is from Comander after I setup group 2. I have added code in an attempt to use wordset3.

    I suspect I’m missing something in addressing a wordset or in trying to retrieve the index. If you could give me a pointer on this, I will be falling across the finish line.