Simple HC-06 bluetooth and PC (Windows)

I develop a software in VBA (excel) to comunicate by serial port. When I use the Arduino conected by USB cable this work perfectly.
But when I try comunicate by usb-bluetooth, no work...

I connected just like in the attached figure.

And I using this ActiveX control, NETCommOCX (link to more informations http://home.comcast.net/~hardandsoftware/NETCommOCX.htm and http://mexcel.wordpress.com/2010/12/31/encendiendo-un-led-con-arduino-y-excel/)

Resuming, I use "Me.NETComm1.PortOpen = True" to open a connection with portCOM. This "Me.NETComm1.Output = Me.Range("A14").FormulaR1C1" to send information, and "Me.Range("A15").FormulaR1C1= Me.NETComm1.InputData" to receive from Arduino.

For a USB cable in my COM3 work, but in the COM5 ( door indicate by Windows to HC-06) when I send the connection comand the red LED in module stop blink and nothing happens.

Please I ned help to finish this to monday, when I have a school presentation.

AlamBaier:
When I use the Arduino conected by USB cable this work perfectly.
But when I try comunicate by usb-bluetooth, no work…

The first line suggests there is nothing wrong with the code, even though we can’t see any…

The second suggests that you are using a bluetooth USB dongle. There could be problems there that have nothing to do with Arduino, and need to be checked by other means.

Before you do that, you imply that you are using the same computer to communicate by both USB cable and by bluetooth. If you are using hardware serial, you cannot do this simultaneously, so make sure the cable is disconnected. With a bit of luck, that is your only problem.

Hi Nick_Pyner

Nick_Pyner:
The first line suggests there is nothing wrong with the code, even though we can’t see any…

I have no difficulty in showing the code. placed at the end of dest post

Nick_Pyner:
he second suggests that you are using a bluetooth USB dongle.

Exactly. I have no other source of power, so I’m plugging in a laptop by USB. And usin the bluetooth USB dongle in my desktop. When I open the comunication the red led in HC-06 module stop blink.

I can not use the HC-06 while the USB (just like power supply)?

Arduino Code
const int ledVerde = 6;
int Ler;
void setup() {

  • Serial.begin(9600);*
  • pinMode(ledVerde,OUTPUT);*
    }
    *void loop() { *
  • Ler = Serial.read();*
  • if (Ler == 48) { //By ANSC table*
  • digitalWrite(ledVerde,LOW);*
  • }*
  • else if (Ler == 49) {*
  • digitalWrite(ledVerde,HIGH);*
  • }*
  • Serial.print(Ler);*
  • delay(500);*
    }

Excel Code (in VBA module)
Dim intEnvia As Integer
Dim intRecebe As Integer
'0 (nada)
'1 (movimenta)
Private Sub cmdFechaPorta_Click()
Dim Menssagem As VbMsgBoxResult

  • Menssagem = MsgBox(“Tem certeza que deseja encerrar a conexão?”, vbYesNo, “Fecha porta COM”)*
  • If Menssagem = vbYes Then*
  • intEnvia = 0*
  • Me.Range(“A14”).FormulaR1C1 = 0*
  • Range(“C10:E11”).Interior.Color = 65535*
  • While intRecebe <> 50*
  • Range(“C10:E11”).Interior.Color = 65535*
  • Range(“C10:E11”).FormulaR1C1 = “Aguarde”*
  • NETComm1_OnComm*
  • Wend*
  • Me.NETComm1.PortOpen = False*
  • intEnvia = 0*
  • Me.Range(“A14”).FormulaR1C1 = 0*
  • Range(“C10:E11”).FormulaR1C1 = “Parado!”*
  • Me.Range(“B3”).FormulaR1C1 = “fechado”*
  • Range(“C10:E11”).Interior.Color = 255*
  • End If*
    End Sub
    Private Sub cmdInicio_Click()
  • If Me.NETComm1.PortOpen = True Then*
  • Me.Range(“B3”).FormulaR1C1 = “aberto”*
  • Else*
  • Me.NETComm1.CommPort = Range(“B2”).FormulaR1C1*
  • Me.NETComm1.PortOpen = True*
  • intEnvia = 1*
  • Me.Range(“A14”).FormulaR1C1 = 1*
  • Range(“C10:E11”).Interior.Color = 5296274*
  • Range(“C10:E11”).FormulaR1C1 = “Operando”*
  • Me.Range(“B3”).FormulaR1C1 = “aberto”*
  • End If*
    End Sub
    Private Sub cmdPara_Click()
  • If intEnvia = 1 Then*
  • intEnvia = 0*
  • Me.Range(“A14”).FormulaR1C1 = 0*
  • Range(“C10:E11”).Interior.Color = 255*
  • cmdPara.Caption = “Andar Robô”*
  • Range(“C10:E11”).FormulaR1C1 = “Parado”*
  • ElseIf intEnvia = 2 Then*
  • intEnvia = 1*
  • Me.Range(“A14”).FormulaR1C1 = 1*
  • Range(“C10:E11”).Interior.Color = 5296274*
  • cmdPara.Caption = “Para Robô”*
  • Range(“C10:E11”).FormulaR1C1 = “Operando”*
  • End If*
    End Sub
    Private Sub NETComm1_OnComm()
    On Error GoTo ERRO
  • Me.NETComm1.Output = Me.Range(“A14”).FormulaR1C1*
  • intRecebe = Me.NETComm1.InputData*
  • Me.Range(“A15”).FormulaR1C1 = intRecebe*
    ERRO:
    End Sub

AlamBaier:
Exactly. I have no other source of power, so I'm plugging in a laptop by USB. And usin the bluetooth USB dongle in my desktop. When I open the comunication the red led in HC-06 module stop blink.

OK, that sounds a lot better - the POWER comes from the LAPtop via the cable, but the COMMUNICATION is with the DESKtop via bluetooth. That should be fine, and you can even have the same comms on the laptop.

Clearly, if the LED stops blinking, the connection is established, but that is ONLY between desktop and bluetooth, and is no guarantee that Bluetooth and Arduino are properly connected and communicating, check the wiring. If that is kosher, I suspect all your problems are at the PC end. I only say this because I have never succeeded in getting my desktop buetooth dongle to work with HC-06, and I'm not inclined to blame Bluetooth.

I hope your laptop has Bluetooth built-in because the obvious next step is to use that for comms and the desktop for power.

Failing that, you are starting to run out of options. I suggest you get down to basics in order to just prove the communications, without bothering with LEDs and Excel.

You might find the following background notes useful

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

although I'm afraid there isn't much new in there for you.