hc05 bluetooth settings

Post Reply
WoutvdBerg
Posts: 9
Joined: Sun Nov 09, 2014 1:26 pm

hc05 bluetooth settings

Post by WoutvdBerg »

Hello everyone, I have some questions about setting up a hc05 bluetooth module.
I don't have a ftdi usb serial converter to setup the bluetooth module. Then I found this: http://blog.oscarliang.net/multiwii-blu ... baud-rate/
I have a multiwii pro ( the red board) and everything in the arduino program is setup perfect for the multiwii but I wanted to configure the bluetooth module by connecting it to the multiwii serial port.
I watched the instructions on the site given above but first the port numbers aren't the same, so the code is not working for multiwii board I guess? Also where do I have to place the code in order to make it work. In one of the multiwii files or something else? I understand how the AT commands work but I can't seem to get it working. I hope someone understands and knows what to do. And simply buying a ftdi board takes or 6 weeks to arrive or I have to pay 30€ for a thing that costs only a few bucks.

Thanks

kalle123
Posts: 106
Joined: Sun Oct 09, 2011 10:07 am

Re: hc05 bluetooth settings

Post by kalle123 »

WoutvdBerg wrote:And simply buying a ftdi board takes or 6 weeks to arrive or I have to pay 30€ for a thing that costs only a few bucks.


You are at the moment in the antarctic?

In http://blog.oscarliang.net/multiwii-blu ... baud-rate/ there is a arduino uno used to do that.
I personally doubt, that this is possible with your multiwii pro.

Look for a usb uart, or CP2102 uart, arduino uno, micro or nano. Maybe one of those is more easily available.

brewski
Posts: 483
Joined: Tue Apr 29, 2014 12:04 am
Location: Cleveland Qld Australia

Re: hc05 bluetooth settings

Post by brewski »

WoutvdBerg wrote:Hello everyone, I have some questions about setting up a hc05 bluetooth module.
I don't have a ftdi usb serial converter to setup the bluetooth module. Then I found this: http://blog.oscarliang.net/multiwii-blu ... baud-rate/
I have a multiwii pro ( the red board) and everything in the arduino program is setup perfect for the multiwii but I wanted to configure the bluetooth module by connecting it to the multiwii serial port.
I watched the instructions on the site given above but first the port numbers aren't the same, so the code is not working for multiwii board I guess? Also where do I have to place the code in order to make it work. In one of the multiwii files or something else? I understand how the AT commands work but I can't seem to get it working. I hope someone understands and knows what to do. And simply buying a ftdi board takes or 6 weeks to arrive or I have to pay 30€ for a thing that costs only a few bucks.

Thanks

Which port does program use? You should be a able to find same port num er on your board. If not try all zerial ports in tur

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: hc05 bluetooth settings

Post by Hamburger »

Yes you can configure your bt.module by running a special sketch/program on your mwii board.
I and others have posted such earlier in this forum.

WoutvdBerg
Posts: 9
Joined: Sun Nov 09, 2014 1:26 pm

Re: hc05 bluetooth settings

Post by WoutvdBerg »

Hamburger wrote:Yes you can configure your bt.module by running a special sketch/program on your mwii board.
I and others have posted such earlier in this forum.

Thanks hamburger for the reply. I tried searching your post for the sketch and instructions how to do it. Even tried the searching engine but this is so big I can't find the right topic.
Can you please give me a link?

User avatar
Hamburger
Posts: 2578
Joined: Tue Mar 01, 2011 2:14 pm
Location: air
Contact:

Re: hc05 bluetooth settings

Post by Hamburger »

ok, I do the search for you - BT is the key
viewtopic.php?f=6&t=373&hilit=bluetooth

WoutvdBerg
Posts: 9
Joined: Sun Nov 09, 2014 1:26 pm

Re: hc05 bluetooth settings

Post by WoutvdBerg »

Hamburger, thanks for the link but I'm still not getting it. Your post is about like 5 different types of bluetooth modules. I have a hc05 wich is preset at 9600 baudrate. I don't have any ftdi/arduino uno/cable or anything that can do the job easy but I only have a multiwii pro w/ mtk gps from hobbyking. When I connect this to my pc it shows at device manager that it has a usb to uart cp210x on board that makes the multiwii talk to the pc.
But now my question is how can I configure this with my multiwii. I saw some sketches but they are for arduino uno boards. The pins on the multiwii aren't the same as the arduino uno so I think the sketch will not work. I don't even know where to put that sketch or just make a new sketch and upload it to the multiwii. but I'm afraid that my multiwii gets broken by doing that. So can you please give me the instructions to do it because I can't make anything from the notes of your topic.
Thanks

WoutvdBerg
Posts: 9
Joined: Sun Nov 09, 2014 1:26 pm

Re: hc05 bluetooth settings

Post by WoutvdBerg »

Hello everyone, seem to get the module in AT mode now and connected to the pc with sketch on it. Only thing is the sketch is working for arduino uno but I tried searching everywhere on the internet but I can never find the pin layout WITH NUMBERS to use in the sketch.
Numbers needed: serial0 TX AND RX pin number
For this line in the sketch: SoftwareSerial BTSerial(10, 11); // RX | TX

10 and 11 are the arduino uno' numbers

Wout van den Berg

kalle123
Posts: 106
Joined: Sun Oct 09, 2011 10:07 am

Re: hc05 bluetooth settings

Post by kalle123 »

It would be easier, if you post the whole script here, not only a line ...

The schematic of the mentioned uno board is here http://arduino.cc/en/uploads/Main/Ardui ... ematic.pdf

But your fc board uses a MEGA2560, so you should refer to that schematic http://arduino.cc/en/uploads/Main/ardui ... R3-sch.pdf

and look for the equivalent positions on your fc board http://static.rcgroups.net/forums/attac ... ctions.jpg

brewski
Posts: 483
Joined: Tue Apr 29, 2014 12:04 am
Location: Cleveland Qld Australia

Re: hc05 bluetooth settings

Post by brewski »

This is crazy!
For <$5 on EvilBay you can buy a FTDI interface board that will usually come with USB cable to connect to your PC or tablet. You can use this FTDI board to not only program your BT board, but also Ublox GPS modules & 3DR radios. If you are serious about your involvement in this hobby you need one of these. I have two

kalle123
Posts: 106
Joined: Sun Oct 09, 2011 10:07 am

Re: hc05 bluetooth settings

Post by kalle123 »

brewski wrote:This is crazy!
For <$5 on EvilBay you can buy a FTDI interface board that will usually come with USB cable to connect to your PC or tablet. You can use this FTDI board to not only program your BT board, but also Ublox GPS modules & 3DR radios. If you are serious about your involvement in this hobby you need one of these. I have two


brewski, had this point earlier, but he really might be in the antarctic ;)

It does not have to be a FTDI, but a CP2102 for 2$ will do.

Looking around here,I have half a dozen lying around here. For flashing ublox, JETI and Multiplex RX and sensors, arduino pro minis ....

Fast and cheap here in Germany. For example http://www.amazon.de/USB-TTL-Konverter- ... EAR26C9TFQ

br

PS. but I think, he is going to do it the hard way ...

WoutvdBerg
Posts: 9
Joined: Sun Nov 09, 2014 1:26 pm

Re: hc05 bluetooth settings

Post by WoutvdBerg »

Hello, my ftdi is coming but is taking too long because I need the bluetooth working earlier because of school project deadline date.
I managed to get the sketch working.
sketch:

Code: Select all

#include <SoftwareSerial.h>

SoftwareSerial BTSerial(19, 18); // RX | TX

void setup()
{
  Serial.begin(9600);
  Serial.println("Enter AT commands:");
  BTSerial.begin(38400);  // HC-05 default speed in AT command more
}

void loop()
{

  // Keep reading from HC-05 and send to Arduino Serial Monitor
  if (BTSerial.available())
    Serial.write(BTSerial.read());

  // Keep reading from Arduino Serial Monitor and send to HC-05
  if (Serial.available())
    BTSerial.write(Serial.read());
}



The only thing is that I searched the serial 1 port on the pin layout of the arduino mega 2560. It says port 19 RX and 18 TX. It isn't working.
When I go to serial monitor with right com it says at 9600 baud: Enter AT commands:

And at 38400 some x's and o's with a line right trough it. But every baud rate doesn't respond to AT

Are the ports wrong, is the sketch wrong?
Thanks,
wout van den Berg

kalle123
Posts: 106
Joined: Sun Oct 09, 2011 10:07 am

Re: hc05 bluetooth settings

Post by kalle123 »

Hi wout van den Berg.

I think, I know, what is the mistake.

I am posting here a picture of some of my parts here.

In the original sketch for UNO they are using pin 10 and 11.

SoftwareSerial BTSerial(10, 11); // RX | TX

That ARE NOT THE TX/RX PINS on the uno board. 0 and 1 are the TX/RX pins on that board.

Take a close look. ;)

In that sketch pin 10 and 11 are used. AND THAT ARE DIGITAL PIN with PWM.

So changing to

SoftwareSerial BTSerial(19, 18); // RX | TX


is a mistake. What you have to use are DITITAL pin with PWM on your FC.

br and good luck.
Attachments
DSCF3642.JPG

kalle123
Posts: 106
Joined: Sun Oct 09, 2011 10:07 am

Re: hc05 bluetooth settings

Post by kalle123 »

Doing a guess.

I think, that are your pins ....

Keep 10 and 11. You might have to change RX <> TX.

Sketch works fine on my UNO and MEGA.

Could try it with a BT module here, but all are on 115200 :)
Attachments
6.jpg

kalle123
Posts: 106
Joined: Sun Oct 09, 2011 10:07 am

Re: hc05 bluetooth settings

Post by kalle123 »


WoutvdBerg
Posts: 9
Joined: Sun Nov 09, 2014 1:26 pm

Re: hc05 bluetooth settings

Post by WoutvdBerg »

Hello Kalle123,
thanks for your reply. I searched for the digital pwm tx0, rx0, rx1 and tx2. All don't work. Tried everything: switching cables. changing sketch ports, changing baud rate between 9600 and 38400. Text with enter at commands comes at 9600 baud.
the thinks that is strange is everytime the text in the serial monitor when I select 38400 baud. picture below.
Attachments
serialmonitor.png
(2.33 KiB) Not downloaded yet

kalle123
Posts: 106
Joined: Sun Oct 09, 2011 10:07 am

Re: hc05 bluetooth settings

Post by kalle123 »

Forget the pins labeled on the board with TX/RX 0 1 2 3!

Go slowly through the pictures, I posted.

Pins 10/11 are used here, NOT the pins 0/1 TX and RX!

And as you are using a MEGA FC, you have to use the right pins

http://arduino.cc/en/Reference/softwareSerial

Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).

So pin 10 and 11 on the MEGA should be OK. I DON'T have your flight controller, but my guess, the green marked pins in my previous post D10 and D11 could be those arduino pins.

FORGET TX/RX marked pins on your FC and on the arduino boards. THAT ARE NOT THE PINS, you have to connect your BT module to.
Attachments
DSCF3642.JPG

kalle123
Posts: 106
Joined: Sun Oct 09, 2011 10:07 am

Re: hc05 bluetooth settings

Post by kalle123 »

Works here.

What I did. Changed the baud rate of one of my modules to 9600. With FTDI module ;)

Used the sketch you see in picture. Both baud rates 9600!! Serial + BTSerial!!

Send AT -> 1.OK
Send AT -> 2.OK (Stupid, no space, no new line) :roll:
Send AT+PIN0000 -> 3.OKsetPIN
Send AT+VERSION -> 4.OKlinvorV1.5
and finally
Send AT -> 5.OK

That is all I can do. I do not have your red board.

br KH

PS. You are not in the antarctic. You started this on Sunday. It does not matter whether your are in Belgium or The Netherlands.
Order out for a FTDI or a cheaper CP2102 on Monday and it is in the post box end of the week!
Attachments
8.jpg

WoutvdBerg
Posts: 9
Joined: Sun Nov 09, 2014 1:26 pm

Re: hc05 bluetooth settings

Post by WoutvdBerg »

Thanks for the replies. I'm going to try them all.
I never said I'm from the antartic. But I ordered so many times cables, little parts from china and with standard shipping it takes 6 weeks before I have it in my house. Yes I can pay 40 dollar for a DHL shipment in 1 week but that is too much money for such little piece.

WoutvdBerg
Posts: 9
Joined: Sun Nov 09, 2014 1:26 pm

Re: hc05 bluetooth settings

Post by WoutvdBerg »

Will this one work for the hc05 bluetooth module: PL2303 USB to UART TTL cable. I can borrow this one from a friend until my ftdi gets delivered.

kalle123
Posts: 106
Joined: Sun Oct 09, 2011 10:07 am

Re: hc05 bluetooth settings

Post by kalle123 »

WoutvdBerg wrote:Will this one work for the hc05 bluetooth module: PL2303 USB to UART TTL cable. I can borrow this one from a friend until my ftdi gets delivered.


I only have 2102 adapters here.

This one says, 2303 is OK. http://www.instructables.com/id/AT-comm ... e/?lang=de
(Might also take a look here http://blog.zakkemble.co.uk/getting-blu ... ach-other/ )
br

WoutvdBerg
Posts: 9
Joined: Sun Nov 09, 2014 1:26 pm

Re: hc05 bluetooth settings

Post by WoutvdBerg »

The 2303 cable worked. Everything is setup and working. Thanks everyone for helping!!!

Post Reply