Clear Filters
Clear Filters

How do I ensure reliable Bluetooth connections using Arduino Hardware tools?

1 view (last 30 days)
I must be missing something as I'm adding HC-06 bluetooth connection to an Arduino Uno based robot. There are frequent intermittent connection failures with code that works well via USB to fail from what appears to be lost connections. I'm working with many students and need for reliable BT connections is important for robot navigation.
Current strategy:
  1. One file creates the arduino connection using an existing bluetooth connection - COM = 'KARBT'; myKAR = arduino(COM), after previously running via USB - COM = 'COM3'; myKAR = arduino(COM,'Uno','BaudRate',115200,'Libraries',{'Ultrasonic','Servo'}; - This is followed by code that configures pin assignments. See attached.
  2. The second file completes testing of the connected hardware. All pins are being used. Servo and Tone reserves pins D3 and D9. Included items: button input, LED output, Tone output, voltage input (battery, temp & light), SSR control, servo control, ultrasonic sensor, Motor driver x2.
The HC-06 devices are set to baud: 115200 with individual NAME and PINs assigned via AT commands. (This needs a better tutorial for the less familar).
Typical error: Error using NewArduinoConnection (line 11) Unable to connect to the Arduino board wirelessly. Call arduinosetup to configure the Arduino board.
Unpair and re-pair: same result
Power down/Power up BT: Shows as connected briefly, then same result.
====Other troubleshooting
Check bluetoothlist and setup for loop-back test: shows as ready to connect - apply hc06 = bluetooth("KARBT", 1) in command window. SUCCESS!
Test loop-back - clc; write(hc06, 1:10); numbers = read(hc06, 10), write(hc06, "helloworld"); text = read(hc06, 10, "string"), SUCCESS!
Also shows as connected in BT devices
====Same device back on Arduino after clear
>> myKAR = arduino('KARBT') - Unable to connect to the Arduino board wirelessly. Call arduinosetup to configure the Arduino board.
????
I need clarification on how to effectively create the connection Bluetooth using MATLAB Support Package for Arduino Hardware - I've read everything available and worked to make sure the HC-06 devices are configured and named for use @ 115200 Baud.
Ideas?

Answers (1)

Vidip
Vidip on 22 Jan 2024
I understand that you are facing intermittent connection failures with HC-06 Bluetooth modules when interfacing with an Arduino, to solve this issue you can follow certain steps –
If the Test connection fails while you are setting up Arduino hardware to use Bluetooth connection in the arduinosetup interface, try the following steps:
For further information, refer to the documentation links below:

Categories

Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!