05-17-2018 12:00 AM
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.
Example
Example of Standalone module :
Example of SMT board
Solved! Go to Solution.
05-17-2018 09:37 AM - edited 05-17-2018 09:39 AM
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.
05-17-2018 10:45 AM
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 .
05-17-2018 11:05 AM
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.
05-18-2018 02:12 AM
@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 ??
05-18-2018 05:43 AM
@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.
05-18-2018 09:05 AM
@MogaRaghu wrote:
@RTSLVUYes 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.
05-19-2018 12:02 AM - edited 05-19-2018 12:04 AM
Ok following the suggestion given by RTSLVU I have created a simple VI that converts the BT into a simple Serial COM.
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
05-19-2018 08:50 AM
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.
05-26-2018 09:19 PM
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 ?