Pages: [1]   Go Down
Author Topic: First Bluetooth project, but I need a bit of help to get going  (Read 1354 times)
0 Members and 1 Guest are viewing this topic.
Ottawa, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 20
32 year veteran of Ottawa high tech community
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I need some help. I bought the BTBee Pro and Motomama boards for a project I am working on. Ultimately, I want to use a Windows handheld terminal (like the kind you see used in stores and warehouses) to communicate with Arduino Uno, using the Motomama to run a motor and the BTBee Pro as the Bluetooth link. I'm not sure where to start. I have the parts connected and powered up and have some questions.

1. In my Arduino sketch, do I need to run certain commands to set up  BTBee Pro and the Bluetooth connection?

2. Do I assume that the BTBee Pro is the serial connection and therefore simply use my serial routines as if I was connected to a PC?

3. I read something about replacing rxtxserial.dll. Is this necessary to getting it all to work?

So far, I can use my Windows hand held terminal to see the BTBee but even after pairing with the default code 1234, I cannot connect to it. I will write an application in C# for the Windows terminal to tell Arduino to control the motor.

Please help with suggestions and code if you can. I'd really appreciate it.

Scott
Logged

Dee Why NSW
Offline Offline
Edison Member
*
Karma: 47
Posts: 2200
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm speculating a little bit here but I see that the BTBee is just another HC-05 but in a fancy package. So, rather than be stuck in the dark.....

1. In my Arduino sketch, do I need to run certain commands to set up  BTBee Pro and the Bluetooth connection?

No

Quote
2. Do I assume that the BTBee Pro is the serial connection and therefore simply use my serial routines as if I was connected to a PC?

Yes

Quote
3. I read something about replacing rxtxserial.dll. Is this necessary to getting it all to work?

I have no idea, but I can't see why you need it to prove the bluetooth works.

Quote
So far, I can use my Windows hand held terminal to see the BTBee but even after pairing with the default code 1234, I cannot connect to it. I will write an application in C# for the Windows terminal to tell Arduino to control the motor.

The pairing only proves the bluetooth has power and is not a dud. It only needs power to pair it. I don't think it needs to be even connected to the Arduino. I don't know what you are actually using to see the BTBee but at least you can see it.  I assume you are not connected by USB cable. I suggest you forget about the motor stuff for the moment, get a standard Windows terminal programme like RealTerm, and use that for the connection.  Ensure the baud rates match.

This should be all the code you need

Code:
void setup()
{
    Serial.begin(9600);
    Serial.println("OK then, you first, say something.....");
    Serial.println("Go on, type something in the space above and hit Send, or just hit the Enter key");
}
 
void loop()
{
  while(Serial.available()==0)
  {}
  delay(500);
  Serial.println("I heard you say:      ");
  while(Serial.available()>0)
  {
    Serial.write(Serial.read());// note it is Serial.WRITE
  }
  Serial.println("");
}

« Last Edit: September 27, 2013, 10:04:32 am by Nick_Pyner » Logged

Ottawa, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 20
32 year veteran of Ottawa high tech community
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the reply Nick. I will plug in a BT dongle into my PC and use your sample to see if I can get the basic communication going.
Logged

Dee Why NSW
Offline Offline
Edison Member
*
Karma: 47
Posts: 2200
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK. You might well find that getting the bluetooth dongle running is the hardest part of the exercise. Using the Toshiba bluetooth stack might help. A better alternative might be to beg, borrow or steal a laptop with bluetooth up and running.

Note that, while you cannot use the simple serial stuff via bluetooth with the USB cable connected to the same computer at the same time, you can run serial monitor on a PC and bluetooth on a laptop simultaneously, which does wonders for your confidence.
 
Logged

Ottawa, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 20
32 year veteran of Ottawa high tech community
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have run a number of tests and still have some trouble using the BTBee. Let me explain.

Test 1.  I wrote a sketch that listens to the serial port and moves a motor to position A if the letter "a" is received and to position B if a "b" is received. When I connect to the PC normally using a USB cable and use the serial monitor, this works fine. This tells me that my Arduino code can process simple commands.

Test 2. I have a Windows CE6 handheld computer with a simple communications program on it. I can pair it to a Windows XP computer that has a Bluetooth dongle in it and send properly formatted data to a terminal program running on the PC. This means that my handheld computer can output the "a" and "b" just fine.

Test 3. I plug in the BTBee Pro module into MotoMama, use the handheld terminal to pair to it and then run my simple communications program on the terminal. I try to send "a" and "b" to see what will happen. This is where it has a problem. The BTBee Pro is somehow corrupting my data and not passing the "a" and "b" through properly to the Arduino code. I converted the data sent by the terminal into 8 bit binary data and found that even though I send different characters, I only see one of three binary patterns. The BTBee Pro is not working right.

I looked through the datasheet for the BTBee Pro and I am not sure if there is a series of commands that I should send it. I have to believe that someone out there is using the BTBee Pro with the MotoMama, and if so, I'd love to see how they made it work properly.
Logged

Dee Why NSW
Offline Offline
Edison Member
*
Karma: 47
Posts: 2200
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK. I'm afraid I'm not familiar with the BTBee and cannot comment further. You certainly seem to have gone about the tests properly and keep the USB cable out of the game. I would have thought that, if test 1 works and your bluetooth is using the standard D0,D1, your code is fine.
Logged

Ottawa, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 20
32 year veteran of Ottawa high tech community
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Today I discovered that there is a circuit error on the Motomama board in that the XBee socket is getting 5V instead of 3.3V. This means that I have been trying to run the HC-05 circuit on 5V. I can still connect to it, but the data is always garbage.  Do you think 5V damaged the HC-05 beyond repair? To recover, I ordered some bare HC-05 modules and I will connect them manually to the Arduino, using its 3.3V supply. I will make sure to voltage divide for the Rx pin.
Logged

Dee Why NSW
Offline Offline
Edison Member
*
Karma: 47
Posts: 2200
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Today I discovered that there is a circuit error on the Motomama board in that the XBee socket is getting 5V instead of 3.3V. This means that I have been trying to run the HC-05 circuit on 5V. I can still connect to it, but the data is always garbage.  Do you think 5V damaged the HC-05 beyond repair?

I don't know anything about the BTBee but, if you fed 5v to a pin clearly marked 3v3, then it probably wasn't such a good idea, and may be confirmed by the lack of flashing lights.

Quote
To recover, I ordered some bare HC-05 modules and I will connect them manually to the Arduino, using its 3.3V supply. I will make sure to voltage divide for the Rx pin.

Now is a good time to check the nomenclature. If, by "bare" HC-05 you really mean bare HC-05, this is a big mistake. Trust me, I've done it - twice.

The HC-05 normally comes as a module which comprises a sandwich of two boards. The most common of these is known as JY-MCU. This backboard is used for the HC-06 as well as the HC-05 and does all that is required to run off 5v. If this is the module you have actually bought, you have made the best move but you will be wasting your time buggerising about with voltage dividers.

If not, the best thing you can do is still forget about the dividers and get some bare JY-MCU backboards off eBay. I suspect these are specially priced for people who should have bought the proper module in the first place, but still cheap enough.  I am not aware of any proto shield with contact spacing kosher for the HC-05.  
« Last Edit: October 07, 2013, 05:59:20 pm by Nick_Pyner » Logged

Ottawa, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 20
32 year veteran of Ottawa high tech community
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Nick,

Yes, I did buy the basic HC-05 modules (5 for $11 off eBay). I bought them just to experiment with. Of course, they have no LEDs and you need to create a simple resistor divider to use it properly, but you can get away with the default settings and prove that it all works. I soldered Tx, Rx, VCC and GND leads and connected them to Arduino. I had to make one resistor divider for Rx. The main thing is is that I got it to work. This method is too fragile for my needs, so I will look at either the JY-MCU boards you talk about ($7.90 at dx.com with free shipping) or simpler BTBee from iteadstudio. I ordered two of them already. They would be a cleaner implementation because the Motomama motor driver board has an XBEE socket on it. Attached is a picture of the UNO with the HC-05 hanging off it with a 5V relay board attached to the analog pins. I was controlling the relays from my Android phone yesterday.



* Bluetooth.JPG (90.05 KB, 640x480 - viewed 67 times.)
Logged

Dee Why NSW
Offline Offline
Edison Member
*
Karma: 47
Posts: 2200
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


. Attached is a picture of the UNO with the HC-05 hanging off it with a 5V relay board attached to the analog pins. I was controlling the relays from my Android phone yesterday.


Hi

That looks like quite a triumph in itself. I took the easy way out and bought the boards. They cost $3.14 each.

 Soldering them up was not as hard as I thought. I sharpened the bit on the iron but I'm not sure it was necessary. Note that HC-05 and HC-06 have different connections for the LED. I soldered mine the wrong way but I have not bothered to fix it.
« Last Edit: October 16, 2013, 09:42:48 am by Nick_Pyner » Logged

Pages: [1]   Go Up
Jump to: