LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bluetooth woes...

Solved!
Go to solution

I am using a Classic Bluetooth module like this linked to a Arduino to send back some characters when the connected host sends a request like <send> . 

 

The snippet below works fine with standalone modules like HC05 . But does not even link with the SMT versions. Do the SMT versions need additional level translators or something like that ? I am powering them with 3.3V. 

Bluetooth_with_Arduino.png

 

Example 

 

Example of Standalone module :HC05 Standalone.PNG

 

 

 

 

 

 

 

 

Example of SMT boardHC05 SMT board.PNG

 

 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 14
(3,819 Views)
Solution
Accepted by topic author MogaRaghu

Wow you certainly have over complicated the use of an HC-05. I have found no need for the low level BT stuff when using those modules.

 

Once you pair the HC-05 with your computer it installs a virtual serial port and becomes "transparent", using VISA you communicate to the device with the HC-05 just like any other device connected to a serial port.

 

Anyway to answer your question, no as long as you are using 3.3v logic. As the "stand alone" versions are just the SMT board mounted on a carrier that has a voltage regulator and level shifting on it to work directly with 5V Arduinos.

 

BTW: YES Everything your read on the Internet about needing level shifting when using the stand alone with a 5v Arduino IS WRONG! That goes to show just how far and fast bad information can spread on the internet.

========================
=== Engineer Ambiguously ===
========================
Message 2 of 14
(3,759 Views)

Wow... that was good. Never thought in those lines !! Yes that must be a easy way. 

So I must check the Device Manager to see which port is assigned to that HC05 and use that as any regular serial port.

Just a thing.. once allotted i do suppose Windows does not change the COM port assignment. It should not but one never knows !!

 

Any sample VI in LV 12 or LV15 would hep get started on this fast. 

Thanks .

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 3 of 14
(3,745 Views)

I have found modern versions of Windows (7+) remember the device ID (or whatever) and assign the same serial port every time. 

 

That is why you will often see a com port marked as "in use" even though it is not actually present in the system.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 14
(3,739 Views)

@RTSLVU wrote:

I have found modern versions of Windows (7+) remember the device ID (or whatever) and assign the same serial port every time. 

 

That is why you will often see a com port marked as "in use" even though it is not actually present in the system.


Yes i did notice it. After i connect a HC05 it leaves a COM port selected. 

SO if we are going to use the BT functionality as a simple serial one, when exactly does one use the BT palatte functions ??

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 5 of 14
(3,701 Views)

@MogaRaghu wrote:

SO if we are going to use the BT functionality as a simple serial one, when exactly does one use the BT palatte functions ??


So far, I have only used it to do a scan for devices.  Anything deeper has lead me down a deep, dark hole.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 14
(3,691 Views)

@MogaRaghu wrote:

@RTSLVU

Yes i did notice it. After i connect a HC05 it leaves a COM port selected. 

SO if we are going to use the BT functionality as a simple serial one, when exactly does one use the BT palatte functions ??


I guess so if you really wanted to do it yourself you could, or to make a program "seamless" as it would do it's own pairing and BT setup. That way you would not have to pair it in Windows before you launched your program.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 14
(3,682 Views)
Solution
Accepted by topic author MogaRaghu

Ok following the suggestion given by RTSLVU I have created a simple VI that converts the BT into a simple Serial COM.

SimpleSerialWrite_Read_LV15.png

Matters are so simple. Of course certain behaviour of the Serial functions is now different :

In a normal hardware serial, if the connected device is removed or powered down, the VI will call a error. But with the assigned Serial COM for a BT device, I see that this does not happen . I think Windows retains the assigned BT irrespective of the actual BT link and so this VI hums about happily without crying foul.  Is this a boon or bane ? It may depend on your needs. For me its a boon as the BT device is a battery powered one and so goes to sleep when not needed. But when alive the VI is ready !!

 

So if need to check the presence of the BT device, I may have to make it send a " Ï am OK"  message and I use that to signal link Status 

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 8 of 14
(3,664 Views)

Do not use the Bytes At Port.  Your data should end with the Termination Character, so use that.  Just tell the VISA Read to read more bytes than you ever expect back.  It will stop reading when that Termination Character is read or a timeout occurs.  Along with this, you can get rid if that wait.  I would probably lower your timeout to something more like 1 or 2 seconds.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 14
(3,655 Views)

Based on the suggestions given I have modified the VI and it now works without using the BT functions and just linking to the enumerated Serial Port created by Windows when pairing with the external BT module. ( The BT module HC05 is interfaced with a MCU that is programmed to send back a Numeral string in response to a request <send>

 

In this I have two issues :

1. The communication happens only when the HC05 is first powered up and then this VI is started.  I can see why … the initialization of the relevant Serial Port is over by the time  and when there is no response to the <send> command this VI reports an error.  Question is how to retain the VISA reference once it is started ? 

 

2. I tried to use the "Is Port Connected " property to identify the link failure and initiate another instance of Initialization of the Serial Port but it does not work … so how to really find out if the Serial Communication fails ? 

 

BT_Serial.png

Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 10 of 14
(3,578 Views)