1

For my head mouse project which is based on the voice recognition module V3.1 for left click, double click, right-click operations, I am facing a problem. I am using 433Mhz Radio Frequency one-way Transceiver for sending data. When I use the InvenSense MPU 6050 accelerometer and gyroscope IMU sensor for mouse cursor movement and the voice recognition module together on only one Arduino board, the mouse cursor moves smoothly and the voice commands work smoothly. But when I use the 433Mhz RF one-way transmitter for one Arduino board to calculate the mouse movement and get the voice command to send it in a wireless manner and receive the values and voice commands using the receiver module of the rf433 Mhz, the mouse cursor starts to lag. It doesn't move smoothly. So, then I got the idea that since the serial monitor was showing only 5 object instances/sec being sent, maybe the RF 433 Mhz is causing data to clog on the user's end. So, I decided to switch to the nRF24L01 wireless transceiver for the wireless medium. But after connecting it, my Arduino Leonardo and Arduino Micro both fail on the transmitter end by powering off in a second of powering on. I can't find a solution to this problem. Please help. Both of the circuits before and after switching to nRF is given below with the code.

Transmitter circuit nRF24L01 version

Transmitter_nRF.ino

#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
//change the CE and CSN acording to conn. change struct contents data type to byte and test if not working
  /*433 MHz RF Module Transmitter Demonstration 1
  RF-Xmit-Demo-1.ino
  Demonstrates 433 MHz RF Transmitter Module
  Use with Receiver Demonstration 1
 
  DroneBot Workshop 2018
  https://dronebotworkshop.com
*/

// Include dependant SPI Library
#include <SPI.h>
#include <SoftwareSerial.h>
#include "VoiceRecognitionV3.h"
#include <Mouse.h>
#include <Wire.h>
#include <I2Cdev.h>
#include <MPU6050.h>


VR myVR(8,9);    // 9:RX 8:TX

uint8_t records[7]; // save record
uint8_t buf[64];

MPU6050 mpu;
int16_t ax, ay, az, gx, gy, gz, oax, oay, oaz, ogx, ogy, ogz;
int16_t vx, vy;

const uint64_t pipeOut = 0xE8E8F0F0E1LL;
RF24 radio(6, 7); // CE: 9/6, CSN: 10/7
//
#define leftRecord    (0)
#define rightRecord   (1)
#define doubleRecord  (2)


/**
  @brief   Print signature, if the character is invisible,
           print hexible value instead.
  @param   buf     --> command length
           len     --> number of parameters
*/
void printSignature(uint8_t *buf, int len)
{
  int i;
  for(i=0; i<len; i++){
    if(buf[i]>0x19 && buf[i]<0x7F){
      Serial.write(buf[i]);
    }
    else{
      Serial.print("[");
      Serial.print(buf[i], HEX);
      Serial.print("]aurav");
    }
  }
}

/**
  @brief   Print signature, if the character is invisible,
           print hexible value instead.
  @param   buf  -->  VR module return value when voice is recognized.
             buf[0]  -->  Group mode(FF: None Group, 0x8n: User, 0x0n:System
             buf[1]  -->  number of record which is recognized.
             buf[2]  -->  Recognizer index(position) value of the recognized record.
             buf[3]  -->  Signature length
             buf[4]~buf[n] --> Signature
*/
void printVR(uint8_t *buf)
{
  Serial.println("VR Index\tGroup\tRecordNum\tSignature");
  Serial.print(buf[2], DEC);
  Serial.print("\t\t");

  if(buf[0] == 0xFF){
    Serial.print("NONE");
  }
  else if(buf[0]&0x80){
    Serial.print("UG ");
    Serial.print(buf[0]&(~0x80), DEC);
  }
  else{
    Serial.print("SG ");
    Serial.print(buf[0], DEC);
  }
  Serial.print("\t");

  Serial.print(buf[1], DEC);
  Serial.print("\t\t");
  if(buf[3]>0){
    printSignature(buf+4, buf[3]);
  }
  else{
    Serial.print("NONE");
  }
  Serial.println("\r\n");
}

struct dataStruct{
  int16_t moveX;  //change to byte data type if not working
  int16_t moveY;
  int flag;
  }myData;
 
//struct dataStruct{
//  byte moveX,moveY,flag;;  //change to byte data type if not working
//  }myData;

int flag = 15;
 
void setup()
{


   /** initialize */
 
  Wire.begin();
  mpu.initialize();
  if (!mpu.testConnection()) {
    while (1);
    }
   
  myVR.begin(9600);
  Serial.begin(115200);
  Serial.println("Elechouse Voice Recognition V3 Module\r\nControl LED sample");
 
   
  if(myVR.clear() == 0){
    Serial.println("Recognizer cleared.");
  }else{
    Serial.println("Not find VoiceRecognitionModule.");
    Serial.println("Please check connection and restart Arduino.");
    while(1);
  }
 
  if(myVR.load((uint8_t)leftRecord) >= 0){
    Serial.println("leftRecord loaded");
  }
 
  if(myVR.load((uint8_t)rightRecord) >= 0){
    Serial.println("rightRecord loaded");
  }

  if(myVR.load((uint8_t)doubleRecord) >= 0){
    Serial.println("doubleRecord loaded");
  }
 
 
  radio.begin();
  radio.setAutoAck(false);
  radio.setDataRate(RF24_250KBPS);
  radio.openWritingPipe(pipeOut);
 
   
}
 
void loop()
{
  delay(1000);
  int ret;

  ret = myVR.recognize(buf, 50);
    const char *msg = "Welcome to the Workshop!";

  if(ret>0){
 
  switch(buf[1]){
   
    case leftRecord:
    flag = 0;
    break;
   
    case rightRecord:
    flag = 1;
    break;

    case doubleRecord:
    flag = 2;
    break;
           
    default:
    flag=3;
    Serial.println("Record function undefined");
    break;
    }
    /** voice recognized */
    printVR(buf);
  }
 
  mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
   
  oax = ax+72;
  oay = ay-382;
  oaz = az-505;
  ogx = gx+99;
  ogy = gy-29;
  ogz = gz-50;

  vx = gx/200; 
  vy = -gz/200;
  myData.moveX = vx;
  myData.moveY = vy;
  myData.flag = flag;
 
//  memcpy(tx_buf, &myData, sizeof(myData));
//  byte bufSize = sizeof(myData);
  Serial.println("movX\tmovY\tflag\toax\toay\toaz\togx\togy\togz\tvx\tvy:");
  Serial.print(myData.moveX, HEX);
  Serial.print("\t");
  Serial.print(myData.moveY, HEX);
  Serial.print("\t");
  Serial.print(myData.flag, HEX);
  Serial.print("\t");
  Serial.print(oax, DEC);
  Serial.print("\t");
  Serial.print(oay, DEC);
  Serial.print("\t");
  Serial.print(oaz, DEC);
  Serial.print("\t");
  Serial.print(ogx, DEC);
  Serial.print("\t");
  Serial.print(ogy, DEC);
  Serial.print("\t");
  Serial.print(ogz, DEC);
  Serial.print("\t");
  Serial.print(vx, HEX);
  Serial.print("\t");
  Serial.println(vy, HEX);

  radio.write(&myData, sizeof(dataStruct));

    flag = 15;
    delay(1);
   
}

Receiver_nRF.ino

#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
//change the CE and CSN acording to conn. change struct contents data type to byte and test if not working
  /*433 MHz RF Module Transmitter Demonstration 1
  RF-Xmit-Demo-1.ino
  Demonstrates 433 MHz RF Transmitter Module
  Use with Receiver Demonstration 1
 
  DroneBot Workshop 2018
  https://dronebotworkshop.com
*/

// Include dependant SPI Library
#include <SPI.h>
#include <SoftwareSerial.h>
#include "VoiceRecognitionV3.h"
#include <Mouse.h>
#include <Wire.h>
#include <I2Cdev.h>
#include <MPU6050.h>


VR myVR(8,9);    // 9:RX 8:TX

uint8_t records[7]; // save record
uint8_t buf[64];

MPU6050 mpu;
int16_t ax, ay, az, gx, gy, gz, oax, oay, oaz, ogx, ogy, ogz;
int16_t vx, vy;

const uint64_t pipeOut = 0xE8E8F0F0E1LL;
RF24 radio(6, 7); // CE: 9/6, CSN: 10/7
//
#define leftRecord    (0)
#define rightRecord   (1)
#define doubleRecord  (2)


/**
  @brief   Print signature, if the character is invisible,
           print hexible value instead.
  @param   buf     --> command length
           len     --> number of parameters
*/
void printSignature(uint8_t *buf, int len)
{
  int i;
  for(i=0; i<len; i++){
    if(buf[i]>0x19 && buf[i]<0x7F){
      Serial.write(buf[i]);
    }
    else{
      Serial.print("[");
      Serial.print(buf[i], HEX);
      Serial.print("]aurav");
    }
  }
}

/**
  @brief   Print signature, if the character is invisible,
           print hexible value instead.
  @param   buf  -->  VR module return value when voice is recognized.
             buf[0]  -->  Group mode(FF: None Group, 0x8n: User, 0x0n:System
             buf[1]  -->  number of record which is recognized.
             buf[2]  -->  Recognizer index(position) value of the recognized record.
             buf[3]  -->  Signature length
             buf[4]~buf[n] --> Signature
*/
void printVR(uint8_t *buf)
{
  Serial.println("VR Index\tGroup\tRecordNum\tSignature");
  Serial.print(buf[2], DEC);
  Serial.print("\t\t");

  if(buf[0] == 0xFF){
    Serial.print("NONE");
  }
  else if(buf[0]&0x80){
    Serial.print("UG ");
    Serial.print(buf[0]&(~0x80), DEC);
  }
  else{
    Serial.print("SG ");
    Serial.print(buf[0], DEC);
  }
  Serial.print("\t");

  Serial.print(buf[1], DEC);
  Serial.print("\t\t");
  if(buf[3]>0){
    printSignature(buf+4, buf[3]);
  }
  else{
    Serial.print("NONE");
  }
  Serial.println("\r\n");
}

struct dataStruct{
  int16_t moveX;  //change to byte data type if not working
  int16_t moveY;
  int flag;
  }myData;
 
//struct dataStruct{
//  byte moveX,moveY,flag;;  //change to byte data type if not working
//  }myData;

int flag = 15;
 
void setup()
{


   /** initialize */
 
  Wire.begin();
  mpu.initialize();
  if (!mpu.testConnection()) {
    while (1);
    }
   
  myVR.begin(9600);
  Serial.begin(115200);
  Serial.println("Elechouse Voice Recognition V3 Module\r\nControl LED sample");
 
   
  if(myVR.clear() == 0){
    Serial.println("Recognizer cleared.");
  }else{
    Serial.println("Not find VoiceRecognitionModule.");
    Serial.println("Please check connection and restart Arduino.");
    while(1);
  }
 
  if(myVR.load((uint8_t)leftRecord) >= 0){
    Serial.println("leftRecord loaded");
  }
 
  if(myVR.load((uint8_t)rightRecord) >= 0){
    Serial.println("rightRecord loaded");
  }

  if(myVR.load((uint8_t)doubleRecord) >= 0){
    Serial.println("doubleRecord loaded");
  }
 
 
  radio.begin();
  radio.setAutoAck(false);
  radio.setDataRate(RF24_250KBPS);
  radio.openWritingPipe(pipeOut);
 
   
}
 
void loop()
{
  delay(1000);
  int ret;

  ret = myVR.recognize(buf, 50);
    const char *msg = "Welcome to the Workshop!";

  if(ret>0){
 
  switch(buf[1]){
   
    case leftRecord:
    flag = 0;
    break;
   
    case rightRecord:
    flag = 1;
    break;

    case doubleRecord:
    flag = 2;
    break;
           
    default:
    flag=3;
    Serial.println("Record function undefined");
    break;
    }
    /** voice recognized */
    printVR(buf);
  }
 
  mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
   
  oax = ax+72;
  oay = ay-382;
  oaz = az-505;
  ogx = gx+99;
  ogy = gy-29;
  ogz = gz-50;

  vx = gx/200; 
  vy = -gz/200;
  myData.moveX = vx;
  myData.moveY = vy;
  myData.flag = flag;
 
//  memcpy(tx_buf, &myData, sizeof(myData));
//  byte bufSize = sizeof(myData);
  Serial.println("movX\tmovY\tflag\toax\toay\toaz\togx\togy\togz\tvx\tvy:");
  Serial.print(myData.moveX, HEX);
  Serial.print("\t");
  Serial.print(myData.moveY, HEX);
  Serial.print("\t");
  Serial.print(myData.flag, HEX);
  Serial.print("\t");
  Serial.print(oax, DEC);
  Serial.print("\t");
  Serial.print(oay, DEC);
  Serial.print("\t");
  Serial.print(oaz, DEC);
  Serial.print("\t");
  Serial.print(ogx, DEC);
  Serial.print("\t");
  Serial.print(ogy, DEC);
  Serial.print("\t");
  Serial.print(ogz, DEC);
  Serial.print("\t");
  Serial.print(vx, HEX);
  Serial.print("\t");
  Serial.println(vy, HEX);

  radio.write(&myData, sizeof(dataStruct));

    flag = 15;
    delay(1);
   
}

Transmitter and Reciever Circuit in RF433Mhz module version which caused cursor lag Transmitter and Reciever Circuit in RF433Mhz module version which caused cursor lag receiver rf433mhz version

  • What exactly do you mean by "powering off"? If they are really going of, you most likely overloaded your power source or created a short somewhere – chrisl Jul 26 at 17:51
  • you said that you need help with power overload .... you did not describe any definite overload in your post ... you may have been fighting this too long and confusion is setting in ... you also said that you use the 433 Mhz transmitter to calculate the mouse movement .... then you said that you do not use a 433 Mhz transmitter ... maybe you need to take a break and reexamine your project and re-describe the problem – jsotola Jul 26 at 18:23
  • In order to figure out if you have a power overload you need to add up the total peak current draw of all the subsystems and make sure that is below the total current provided by your power supply. You don't show any information about the power supply(s) you are using. Are you trying to power everything with USB power to the Arduino, or with the built-in voltage regulator on the Arduino? – Duncan C Jul 26 at 19:36
  • @jsotola I changed the wireless module. Before it was the RF433 Mhz module. When I was using it to send and receive data, the mouse cursor lagged because of the inferior data rate. When I changed my decision and dumped the RF433Mhz module and used the nRF24L01+ module for the wireless connection, the Arduino board powered up and then it shut down. The same happened when I just used the MPU6050 and the nRF24L01+ with the Arduino. What could be the reason? – Nahian Rifaat Jul 27 at 14:08
  • @DuncanC I have my Arduinos on the breadboard connected by a USB cable to the laptop. – Nahian Rifaat Jul 27 at 14:08
0

Read the specs on your different components. Add up the peak current requirements for everything. Ideally, multiply by 1.2 to allow some (20%) wiggle room. Make sure your power supply provides that much current. If you're using USB, your total power available is 500 mA. That is almost certainly the problem. Your devices are drawing a total of more than 500 mA, and you are triggering an overload shutdown.

If your system draws more than your power source can provide, get a higher current power supply and use that. (A high current regulated 5V supply. Use that to provide 5V rather than trying to power everthing from the Arduino's 5V supply)

Edit:

If you want help figuring this out, include info on the total current requirements for the different parts of your project.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.