Why is my Arduino RC car's HC05 frequently getting disconnected after unplugging my USB cable from Arduino. Please help me out!

Hi everyone, I'm Kaivalya Kulkarni. I'm an Indian. This is my first query on Arduino forum.
So please please help me out :innocent: :slightly_smiling_face:
I want to make a rc car wth arduino but when i connect my usb cable to my arduino and give an external power supply of 6V to my L293D motor driver shield and a 9v power supply to arduino all is working fine. My rc car is working it gets success. But when I disconnect my usb cable and give forward or backward signal to my arduino my Hc05 gets disconnected from mobile but it sometimes work when i give left or right signal.

This is my code

#include <SoftwareSerial.h>
#include <AFMotor.h>

AF_DCMotor motor1(1);
AF_DCMotor motor2(2);

SoftwareSerial mySerial(A0, A1);

void setup()
{
mySerial.begin(9600);
Serial.begin(9600);
motor1.setSpeed(255);
motor2.setSpeed(255);
motor1.run(RELEASE);
motor2.run(RELEASE);
}

void loop()
{
if(mySerial.available() == 1)
{
char val = mySerial.read();
Serial.print("Message From Techno Kaivalya :");
Serial.println(val);
if(val == 'F')
{
motor1.run(FORWARD);
motor2.run(FORWARD);
}

 if(val == 'B')
{
 motor1.run(BACKWARD);
 motor2.run(BACKWARD);
}

 if(val == 'L')
{
motor1.run(FORWARD);
motor2.run(RELEASE);

}

if(val == 'R')
{
motor1.run(RELEASE);
motor2.run(FORWARD);
}

 if(val == 'S')
{
motor1.run(RELEASE);
motor2.run(RELEASE);
}

}
}

This is my circuit connection :point_down: :point_down:

Arduino connected to Motor driver shield L293D
Motor left connected to Motor driver shield L293D's M1
Motor right connected to Motor driver shield L293D's M2
HC05 5v to Motor driver shield L293D's 5v
Hc05 GND to Motor driver shield L293D's GND
Hc05 rx to Arduino A0
Hc05 tx to Arduino A1.

Information about my controller app


When we doesn't press anything on app, it frequently sends the signal as 'S' so that the robo should stop

This is all information about my Robo. What's Wrong? please help me out :innocent: :innocent:

Hello.This summer I made this project with Same shield. İs yorum arduino stops working arter unplugging USB cable?

Hello

Edit your first post to put your code inside code tags ( select all your code and click on the </> icon )

  • I'm not sur if this will help, but this line doesn't seem correct :
    if(mySerial.available() == 1)
    if there is more than one character in the input buffer, your code will not run. Replace with
    if(mySerial.available())

  • It is recommended to use a 5V to 3.3V level shifter on the RX pin of the HC-05

  • And make sure it is not your controller app that is causing the problem

Please do not use the 5V output of the L293 module to supply the HC05! Connect the VCC from the HC05 to the 5V output from the Arduino! Your problem arises from the fact that 6v are very scarce on the L293 module for the voltage regulator on the module. As soon as the drive motor starts, it needs a lot of current for a short time, which causes the 6V to drop and the voltage regulator can no longer keep the 5V stable. this causes a reset of the HC05 module, which then of course loses the connection.

Can you please take another photo, but hold your smartphone so that, firstly, the picture is in landscape format, and secondly, more from above, and thirdly, you can see how the HC-05 is connected? Because on your current photo you can only see that you are using a motor shield, but there is hardly anything else to be seen. I still believe that your code is OK, because it works with the USB plugged in, and that there is some problem with the power supply, otherwise the HC-05 would not disconnect when the motors started up. But for precise help, I need more information. I would also like to see your power supplies, please also as pictures of the real structure, and if you can, I would also like to see a circuit diagram that also shows which components are connected where, and how and where the power supplies, and also which power supplies you are using then I will see how I can help you.

Hey Deltaflyer, I want to thank you because you are helping me so much.
This is the pic of full robo

                                                   HC05 Connections

The orange wire is vcc, red is ground and the grey and black wires are rx and tx respectively.

                                                    Power supplies

Now the power supplies. Im using two 9v battery and one 6v battery holder. I am using this much power supply because all the batteries im using are halfly exhausted. One 9v battery for arduino and i combined the battery holder's wires and another 9v battery's wires to power motor driver. The battery holder is placed below the motor driver and arduino. :innocent: :slightly_smiling_face: