Go Down

Topic: hc05 bluetooth module disconnecting from device when sending data, plz help  (Read 313 times) previous topic - next topic

Freakup

hi
im trying to make a bluetooth car with arduino uno
everything is working good except.. the bluetooth disconnects from my phone everytime i send a command

the bluetooth is wired like this:

              -> state === x
 Level:3.3V   <- RXD   === (RX <- 0)
              -> TXD   === (TX <- 1)
              <- GND   === (GND)
Power.3.6v--6v <- VCC   === (5V)
              <- EN    === x

i tried 4 "1,5 AA" batteries, it didnt work even the 9v didnt work
when i tried 2 "1,5 AA" batteries the bluetooth didnt turn on

i dont think there is anything wrong with the wires cuz i checked everything for like a thousand time
i started doing the car 3 weeks ago and im still trying to make it work





the arduino code:


Quote

//Arduino Bluetooth Controlled Car//
// Before uploading the code you have to install the necessary library//
//AFMotor Library https://learn.adafruit.com/adafruit-motor-shield/library-install //

#include <AFMotor.h>

//initial motors pin
//AF_DCMotor motor1(1, MOTOR12_1KHZ);
//AF_DCMotor motor2(2, MOTOR12_1KHZ);
AF_DCMotor motor3(3, MOTOR34_1KHZ);
AF_DCMotor motor4(4, MOTOR34_1KHZ);







char command;

void setup()
{       
 Serial.begin(9600);  //Set the baud rate to your Bluetooth module.
 Serial.println("Start");
}

void loop(){
 if(Serial.available() > 0){
   command = Serial.read();
   //Change pin mode only if new command is different from previous.   
   //Serial.println(command);
   switch(command){
   case 'F': 
     forward();
     break;
   case 'B': 
      back();
     break;
   case 'L': 
     left();
     break;
   case 'R':
     right();
     break;
   }
 }
}

void forward()
{
 //motor1.setSpeed(255); //Define maximum velocity
 //motor1.run(FORWARD); //rotate the motor clockwise
 //motor2.setSpeed(255); //Define maximum velocity
// motor2.run(FORWARD); //rotate the motor clockwise
 motor3.setSpeed(255);//Define maximum velocity
 motor3.run(FORWARD); //rotate the motor clockwise
 motor4.setSpeed(255);//Define maximum velocity
 motor4.run(FORWARD); //rotate the motor clockwise
}

void back()
{
 //motor1.setSpeed(255); //Define maximum velocity
// motor1.run(BACKWARD); //rotate the motor anti-clockwise
 //motor2.setSpeed(255); //Define maximum velocity
 //motor2.run(BACKWARD); //rotate the motor anti-clockwise
 motor3.setSpeed(255); //Define maximum velocity
 motor3.run(BACKWARD); //rotate the motor anti-clockwise
 motor4.setSpeed(255); //Define maximum velocity
 motor4.run(BACKWARD); //rotate the motor anti-clockwise
}

void left()
{
// motor1.setSpeed(255); //Define maximum velocity
 //motor1.run(BACKWARD); //rotate the motor anti-clockwise
 //motor2.setSpeed(255); //Define maximum velocity
 //motor2.run(BACKWARD); //rotate the motor anti-clockwise
 motor3.setSpeed(255); //Define maximum velocity
 motor3.run(FORWARD);  //rotate the motor clockwise
 motor4.setSpeed(255); //Define maximum velocity
 motor4.run(BACKWARD);  //rotate the motor clockwise
}

void right()
{
 //motor1.setSpeed(255); //Define maximum velocity
// motor1.run(FORWARD); //rotate the motor clockwise
// motor2.setSpeed(255); //Define maximum velocity
 //motor2.run(FORWARD); //rotate the motor clockwise
 motor3.setSpeed(255); //Define maximum velocity
 motor3.run(BACKWARD); //rotate the motor anti-clockwise
 motor4.setSpeed(255); //Define maximum velocity
 motor4.run(FORWARD); //rotate the motor anti-clockwise
}

void Stop()
{
 //motor1.setSpeed(0); //Define minimum velocity
 //motor1.run(RELEASE); //stop the motor when release the button
 //motor2.setSpeed(0); //Define minimum velocity
 //motor2.run(RELEASE); //rotate the motor clockwise
 motor3.setSpeed(0); //Define minimum velocity
 motor3.run(RELEASE); //stop the motor when release the button
 motor4.setSpeed(0); //Define minimum velocity
 motor4.run(RELEASE); //stop the motor when release the button
}

thats all plz help its been long time and im still trying
ty for reading

groundFungus

What Arduino do you have?

Your description of the wiring is not understandable.

It should be connect as follows to a 5V Arduino (Uno, Nano, Mega):
BT enable not connected
BT Vcc to 5V
BT ground to ground
BT TX to Arduino RX
BT RX to Arduino TX via a voltage divider (drops Arduino 5V to 3.3V for the Bluetooth module)
BT state not connected

Here is a page with very good information on using the HC05 modules.

I would use a software serial port for the Bluetooth module so that the hardware serial port is free for program upload, monitoring and debugging.

Read the how to use this forum-please read sticky to see how to properly post code and some advice on how to ask an effective question.  Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.

Go Up