Welcome! Log In Create A New Profile

Advanced

Adding bluetooth (HC05) to Ramps 1.4 headache

Posted by Ohmarinus 
Adding bluetooth (HC05) to Ramps 1.4 headache
May 08, 2019 02:51PM
Hi y'all, I've been trying to get this bluetooth part to work with my Ramps but to no avail..

I have correctly build the wiring setup mentioned on this wiki page:
[reprap.org]

I measured the voltages across each of the four connectors and everything was fine, 5v and 3.3v after adding the resistors etc.

Then I did the configuration of the device and this is where I halted. Each time I use the arduino programs that are provided on the wiki, I can't connect to the module at any baud rate.

I also tried the troubleshooting tips that were provided but nothing helped. I have ran about 20 different tests on two modules and nothing worked. I also tried switching the Rx and Tx cables to see if they maybe mislabeled them on the modules but nothing helped.

The modules are probably not compatible with Ramps, I am able to see the bluetooth modules on my laptop's bluetooth monitor but can't connect because the modules aren't configured yet so the modules do work. They also blink a red light when I turn on the Ramps that they are connected to. I have correctly set the pins and connected the bluetooth module to the corresponding pins. I triple checked with the silkscreen examples of Ramps that have the pinouts labeled.

Maybe somehow someone else had gotten these to work. What was the trick?


http://www.marinusdebeer.nl/
Re: Adding bluetooth (HC05) to Ramps 1.4 headache
May 08, 2019 09:28PM
The bluetooth module when being used is plugged into rx0/tx0 on the ramps (it just bypasses the usb/serial chip)

BUT

the configuration program expects the bluetooth module on the arduino rx2/tx2
On ramps this is Digital pin 17 (RX2) on aux4 and Digital pin 16 (TX2) on aux4

The setup program prompts for user input over usb so you need the serial monitor open at 57600 baud

Edited 1 time(s). Last edit at 05/08/2019 09:53PM by Dust.
Re: Adding bluetooth (HC05) to Ramps 1.4 headache
May 09, 2019 02:22AM
Quote
Dust
The bluetooth module when being used is plugged into rx0/tx0 on the ramps (it just bypasses the usb/serial chip)

BUT

the configuration program expects the bluetooth module on the arduino rx2/tx2
On ramps this is Digital pin 17 (RX2) on aux4 and Digital pin 16 (TX2) on aux4

The setup program prompts for user input over usb so you need the serial monitor open at 57600 baud

Trust me, that's exactly what I did winking smiley


http://www.marinusdebeer.nl/
Re: Adding bluetooth (HC05) to Ramps 1.4 headache
May 09, 2019 04:05AM
I've done it before, but a long time ago... it is a very common arduino thing to do..

Did you get as far as the serial monitor saying "Device speed detected" ?

Are you trying to pair it with another HC05 module or something else like a pc?

Where does it fail... wont link, wont talk serial, wont power on?

Got something like a ftdi to serial converter?
If you have wire that to the HC05 and plug it into your pc (you will need the resistor voltage divider) and open up a terminal program (eg putty) with baud rate at 9600
If you tried changing the baud rate you might have to try a few baud rates to work out what it is now talking.

Send the device a "AT" does it reply?

Once you have it talking reset it and set a new baud rate
ie
AT+ORGL
AT+UART=115200
AT+RESET


Most useful AT commands are

AT : Ceck the connection.
AT+NAME : See default name
AT+ADDR : see default address
AT+VERSION : See version
AT+UART : See baudrate
AT+ROLE: See role of bt module(1=master/0=slave)
AT+RESET : Reset and exit AT mode
AT+ORGL : Restore factory settings
AT+PSWD: see default password
Re: Adding bluetooth (HC05) to Ramps 1.4 headache
May 09, 2019 04:34AM
Quote
Dust
I've done it before, but a long time ago... it is a very common arduino thing to do..

Did you get as far as the serial monitor saying "Device speed detected" ?

Are you trying to pair it with another HC05 module or something else like a pc?

Where does it fail... wont link, wont talk serial, wont power on?

Got something like a ftdi to serial converter?
If you have wire that to the HC05 and plug it into your pc (you will need the resistor voltage divider) and open up a terminal program (eg putty) with baud rate at 9600
If you tried changing the baud rate you might have to try a few baud rates to work out what it is now talking.

Send the device a "AT" does it reply?

Once you have it talking reset it and set a new baud rate
ie
AT+ORGL
AT+UART=115200
AT+RESET


Most useful AT commands are

AT : Ceck the connection.
AT+NAME : See default name
AT+ADDR : see default address
AT+VERSION : See version
AT+UART : See baudrate
AT+ROLE: See role of bt module(1=master/0=slave)
AT+RESET : Reset and exit AT mode
AT+ORGL : Restore factory settings
AT+PSWD: see default password

I will try it with putty, because when I use the script provided in the wiki, I get no response through the serial monitor (when it goes through all the baud rates to try and connect, it never connects).
Later today I might be able to do a recording if that is useful.

Edited 1 time(s). Last edit at 05/09/2019 04:35AM by Ohmarinus.


http://www.marinusdebeer.nl/
Re: Adding bluetooth (HC05) to Ramps 1.4 headache
May 09, 2019 08:34AM
Ok had a play and also could not get it to work... at first

Till I found a post that said than some models require you to "hold down the button on the front while starting it up and it will enter 38400N81 command mode and the light will slow-blink."

This started command mode talking at 38400 right away.

You also require both LF and CR on arduino monitor if talking directly to HC05 via a ftdi chip.

Edited 1 time(s). Last edit at 05/09/2019 08:36AM by Dust.
Re: Adding bluetooth (HC05) to Ramps 1.4 headache
May 10, 2019 03:13PM
Okay so I've tried the one with the button press at startup, in 'Both NL & CR' mode (LF is now called NL) but nothing.. Still the same, the script stays at detecting and it doesn't connect. Both BT modules.

I've tried it with the pullup activated and without, with and without button pressed at startup, tried it in every possible combination but still no luck. I'm not schooled enough to manually do this so really the only way I know is to do it through the explanation from the wiki, I'm not easily intimidated but it seems like this just isn't going to work.

This is the setup:


I'm using short leads as it was mentioned that long leads can also lead to a failed connect.


http://www.marinusdebeer.nl/
Re: Adding bluetooth (HC05) to Ramps 1.4 headache
May 11, 2019 06:07AM
Your circuit looks good

had more of a play

the code provided is badly flawed!
It send data to the module at the wrong baud rate, then looks for a reply. It doesnt get one. that is ok.
then it tries the correct baud rate, but the module input buffer is already full of crap data from before, so it errors (ideally the module needs reset every try...)

but since that not is possible...

I have changed their code.. replace the function void bauddetect( long x) with the code below.
I've left some debugging in stuff in [ ] brackets... doesn't hurt and shows there is signs of life.
You do still need to power up the module in slow blink mode
NB setting the baud rate will not change the rate detected, this is the data rate for the BT link not the command rate.

void bauddetect( long x){//this solved baudrate
Serial.print("baudrate:");
Serial.print(x);
int byte1;
int detect=0;//used to know if detected
long time_keeper;//get start millseconds
Serial2.begin(x);//starts at baudrate
delay(600);//stabilizer

time_keeper=millis();
//sink up serial
Serial2.print('\n');//initialization command
Serial2.println('\n');//initialization command
//discard and garbage characters
while(millis()-time_keeper<2000){
  //while within 
   if (Serial2.available() > 0) { 
    byte1= Serial2.read();
   };// conditions met for char sent
 }//while loop

//real test
time_keeper=millis();
Serial2.println("AT");//initialization command
while(millis()-time_keeper<2000){
  //while within 
   if (Serial2.available() > 0) { 
    byte1= Serial2.read();
    Serial.print("[0x");
    Serial.print(byte1,HEX);
    Serial.print(",");
    Serial.print(byte1);
    Serial.print("]");
    if (byte1==79 | byte1==75){
      Serial.print(".");
      detect++; //if o or k is sent then increment
      byte1=0; //clear
    }
  
   };// conditions met for char sent
 }//while loop
 Serial2.flush();
 Serial2.end();//stops serial at baud rate
 delay(200);//stabilizer
 if (detect < 2) {x=0; Serial.println("_no");}//clears if result is not a valid responce from bt host
 else{ Serial.println("_yes");// if baud then 
 final_baud=x;//store baud rate for use.
 }
}

output will look like
detecting device....
baudrate:1200_no
baudrate:2400_no
baudrate:4800_no
baudrate:9600_no
baudrate:19200_no
baudrate:38400[0x4F,79].[0x4B,75].[0xD,13][0xA,10]_yes
baudrate:57600_no
baudrate:115200_no
baudrate:230400

Edited 2 time(s). Last edit at 05/11/2019 06:29AM by Dust.
Re: Adding bluetooth (HC05) to Ramps 1.4 headache
May 11, 2019 11:51AM
Quote
Dust
Your circuit looks good

had more of a play

the code provided is badly flawed!
It send data to the module at the wrong baud rate, then looks for a reply. It doesnt get one. that is ok.
then it tries the correct baud rate, but the module input buffer is already full of crap data from before, so it errors (ideally the module needs reset every try...)

but since that not is possible...

I have changed their code.. replace the function void bauddetect( long x) with the code below.
I've left some debugging in stuff in [ ] brackets... doesn't hurt and shows there is signs of life.
You do still need to power up the module in slow blink mode
NB setting the baud rate will not change the rate detected, this is the data rate for the BT link not the command rate.

void bauddetect( long x){//this solved baudrate
Serial.print("baudrate:");
Serial.print(x);
int byte1;
int detect=0;//used to know if detected
long time_keeper;//get start millseconds
Serial2.begin(x);//starts at baudrate
delay(600);//stabilizer

time_keeper=millis();
//sink up serial
Serial2.print('\n');//initialization command
Serial2.println('\n');//initialization command
//discard and garbage characters
while(millis()-time_keeper<2000){
  //while within 
   if (Serial2.available() > 0) { 
    byte1= Serial2.read();
   };// conditions met for char sent
 }//while loop

//real test
time_keeper=millis();
Serial2.println("AT");//initialization command
while(millis()-time_keeper<2000){
  //while within 
   if (Serial2.available() > 0) { 
    byte1= Serial2.read();
    Serial.print("[0x");
    Serial.print(byte1,HEX);
    Serial.print(",");
    Serial.print(byte1);
    Serial.print("]");
    if (byte1==79 | byte1==75){
      Serial.print(".");
      detect++; //if o or k is sent then increment
      byte1=0; //clear
    }
  
   };// conditions met for char sent
 }//while loop
 Serial2.flush();
 Serial2.end();//stops serial at baud rate
 delay(200);//stabilizer
 if (detect < 2) {x=0; Serial.println("_no");}//clears if result is not a valid responce from bt host
 else{ Serial.println("_yes");// if baud then 
 final_baud=x;//store baud rate for use.
 }
}

output will look like
detecting device....
baudrate:1200_no
baudrate:2400_no
baudrate:4800_no
baudrate:9600_no
baudrate:19200_no
baudrate:38400[0x4F,79].[0x4B,75].[0xD,13][0xA,10]_yes
baudrate:57600_no
baudrate:115200_no
baudrate:230400

Wow, this works really well now! Thanks a lot for your help. I shouldn't have trusted the script blindly..

Somehow editing the name etc doesn't save it on the device, but I will have to see if there are maybe more errors in the script.

Yes, tried both versions of the script on the wiki but none of them will store the settings that I give it, no name, no pin nor baudrate. I guess I'll have to go in deeper and try to do it with manual codes, but I already found out I cannot use these codes within the script provided.

Device info:
baudrate:38400
BT Module:

password:
idname:
-------Commands:--------------
1........setbaudrate
2.....renamedeviceid
3.........Change pin
- choose above options 1,2,3 -

Edited 2 time(s). Last edit at 05/11/2019 12:11PM by Ohmarinus.


http://www.marinusdebeer.nl/
Re: Adding bluetooth (HC05) to Ramps 1.4 headache
May 11, 2019 12:42PM
It seems like the author favored pretty graphics over functionally...

setting a new baud rate for data looks like it might work, but setting a name and pin... more broken code...
Re: Adding bluetooth (HC05) to Ramps 1.4 headache
May 11, 2019 02:31PM
Quote
Dust
It seems like the author favored pretty graphics over functionally...

setting a new baud rate for data looks like it might work, but setting a name and pin... more broken code...

It's really strange as he even has a video on youtube showing what he's doing.


http://www.marinusdebeer.nl/
Sorry, only registered users may post in this forum.

Click here to login