Problem with MOVI shield and bluetooth at the same time

Hello,
I'm making a smart room with relays controlled by your voice with an Audeme MOVI shield. I also want the option to control it by phone with the hc-05 bluetooth module but I can't get the code to work, sometimes only voice controll works and then I change the code a litle then only bluetooth works. Please help me.
(NOTE: I did not completely write this code on my own, some parts i coppied from the internet)
Here is my code: (in this code voice control works but bluetooth doesn't)

#include <MOVIShield.h>
#include <SoftwareSerial.h>
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_PIC32)
#endif

MOVI recognizer(true); // Get a MOVI object, true enables serial monitor interface, rx and tx can be passed as parameters for alternate communication pins on AVR architecture

SoftwareSerial Genotronex(10, 11); // RX, TX
int Relay1=2; //set relays
int Relay2=3;
int Relay3=4;
int Relay4=5;
int BluetoothData; // the data given from Computer

void setup() {

pinMode(Relay1,OUTPUT); // set all relays as an output
pinMode(Relay2,OUTPUT);
pinMode(Relay3,OUTPUT);
pinMode(Relay4,OUTPUT);
digitalWrite(Relay1,1); //set all relays high
digitalWrite(Relay2,1);
digitalWrite(Relay3,1);
digitalWrite(Relay4,1);

Genotronex.begin(9600);

recognizer.init(); // Initialize MOVI (waits for it to boot)
recognizer.setSynthesizer(SYNTH_PICO); //changes voice of the synthesizer
recognizer.callSign("Arduino"); //reacts if you say this word
recognizer.addSentence("Relay one on"); //sentence 1
recognizer.addSentence("Relay one off"); //sentence 2
recognizer.train(); //train

}

void loop() {

signed int res=recognizer.poll(); // Get result from MOVI, 0 denotes nothing happened, negative values denote events
if (res==1) { // Sentence 1.
digitalWrite(Relay2,1); // Turn on relay1
recognizer.say("Relay one is on!"); // Speak a sentence
}
if (res==2) { // Sentence 2
digitalWrite(Relay1,0); // Turn off relay1
recognizer.say("Relay one is off!"); //Speak a sentence
}

if (Genotronex.available()){ //if bluetooth data is available
BluetoothData=Genotronex.read(); //read bluetooth data

if(BluetoothData=='1'){ //if buetooth data is 1, turn relay off
digitalWrite(Relay1,0);

}
if(BluetoothData=='2'){ //if buetooth data is 2, turn relay on
digitalWrite(Relay1,1);

}

if(BluetoothData=='3'){ //if buetooth data is 3, turn relay off
digitalWrite(Relay2,0);

}
if(BluetoothData=='4'){ //if buetooth data is 4, turn relay on
digitalWrite(Relay2,1);

}
if(BluetoothData=='5'){ //if buetooth data is 5, turn relay off
digitalWrite(Relay3,0);

}
if(BluetoothData=='6'){ //if buetooth data is 6, turn relay on
digitalWrite(Relay3,1);

}
if(BluetoothData=='7'){ //if buetooth data is 7, turn relay off
digitalWrite(Relay4,0);

}
if(BluetoothData=='8'){ //if buetooth data is 8, turn relay on
digitalWrite(Relay4,1);

}
}
}

Home_Automation.ino (2.64 KB)

1 Like

I'm making a smart room with relays controlled by your voice with an Audeme MOVI shield.

How does the Arduino communicate with that shield? If it is an SPI shield, you can't use pins 10, 11, 12, or 13 (on a UNO) to communicate with the bluetooth device.

I tried connecting the module to other pins, unfortunately it didn’t work (I use arduino mega)
But I think I know the problem, I use 2 serial monitors one for the MOVI shield and one for the Bluetooth module. I think 2 serial monitors don’t work together/ work at the same time. Do you know how to solve that problem? Thanks!

I use arduino mega

Then why in the hell are you using SoftwareSerial? Did you read the list of pins SoftwareSerial will work on if you just HAVE to use it on a Mega?

I tried every pin that will work with software serial but it still doesn’t work. Also if I open the serial monitor and I send data to the Bluetooth module it doesn’t show the data on the monitor. But I do get data in the serial monitor when I speak to the MOVI shield. Please help me, I’m not that good in coding.

I'm not that good in coding.

Connect the bluetooth device ONLY, to a set of hardware serial pins, other than 0 and 1. Write a sketch that does nothing more than read data from the bluetooth device, using SerialN.available() and SerialN.read() (where N is the number of the RX and TX pins you are using.

It doesn't help to debug hardware in an already complex sketch. Test the hardware in a simple sketch. When you KNOW that the hardware works, you can incorporate the code to deal with it in the more complex sketch. Then, if the hardware doesn't work, there is a pin compatibility or resource issue that we might be able to deal with, or we might not.