How to get the name of Bluetooth Device which is connected?

Hi,
I have created Arduino project and able to transmit data through HC05 Bluetooth Module.

in MIT App Inventor, I have created a android App to receive the data using tutorials.
I am able to receive the data over Bluetooth connection.

My query is how to display a name of the Bluetooth device which I am connecting using my Mobile phone?
on the Android app which is created using MIT App Inventor, I want to show the display name of the device which is connected and sending the data to mobile phone.

I tried options in List picker and Bluetooth client but not found anything related.
Please suggest suitable commands to do same.

Hi
Well, the Bluetooth Device does not necessarily have a “name” as such but to connect to it, you selected from a list of available devices, correct? That selection (List Item) can be displayed in a Label, but most common is to use a List Picker Component for the List and when the selection is made by the User, the List Picker button is set with the device “name”:

Dear ChrisWard,
Thank you for your reply.
I will check the blocks shared by you.

  • I have programmed HC-05 Bluetooth module and given it name: say “Sensor 1”
  • which I will like to display once connected

below are the existing blocks I have used

OK, if you have imposed a name, that could show up as part of the device Address, which BT lists. Experiment!

Hi,

I tried as mentioned in your block - listpicker - selection.
It gives me value true or false



Hi,
I want to set label 6 - text as Name of the Device which is selected.
Which is the suitable block to be added in code?

Sorry, see my code above, correct yours as per mine, then let us know what you get.

Hi,
I have updated the code as mentioned in your message.
I got the value “true” instead of device name.

Should I use tinydb to store and get the device value?

unfortunately you did not provide a screenshot of your updated relevant blocks, so noone can know, what exactly you are talking about...

to get the name of the conected bluetooth device, use the split block from the text drawer, split Listpicker.Selection at space, then use the select list item block to select the second item

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

As the OP noted ListPicker.Selection appears to return a Boolean value of wheher a selection has been registered and not an address SPACE Name. I am in the same boat; looking for a method to get the Bluetooth name so I can display it on the app.

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select “Download Blocks as Image”. You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

Was this SOLVED? I am also looking for something similar.
I want to display my list of paired devices without the addresses, just the names.
Then be able to select and connect to the Bluetooth device without ever showing the addresses.
I tried the earlier suggestion of using the “split” block, but I couldn’t get it to work.

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

I think i understand what you are trying to achieve and i might have the solution you’re seeking. Hopefully its helpful.

1 Like

hi got you there...had same issues for my project but got an idea.....all you need to do is add an label after your listpicker in the designer area...and get into blocks and an logic if statement to the (listpicker after picking) block in IF add an call bluetooth client connect address block and add a text box to it ...and fill the text box with the address of the bluetooth module...in THEN....add an set lable text block and then add an text box to it the text box should have the name of your blutooth module,,,, repeat the same thing for all the blutooth devices that needs to be shown on your display......so the logic is like this....after connecting to a bluetooth devices ,......the if block checks for the address....if the address matches the predetermined txt it change the labe text to the said one...

or one more way is to program your ardiuno in way that as soon as it connects to your phone....the ardiuno should send a message ( the name you want on the display) using serial.print function ...and you can add a receive data from bluetooth client and have a if statement and an label ...by this your mobile will display the message of the serial.print function....