Having issue in App Inventor + Micro:Bit Basic Bluetooth Connection Setup

384 views
Skip to first unread message
Assigned to ewpa...@gmail.com by ghica.va...@gmail.com

Shruti Sawant

unread,
Aug 17, 2019, 7:32:45 AM8/17/19
to MIT App Inventor Forum
Hello,
 
I have tried building an MIT App for Basic Bluetooth Connection Setup, connecting Micro:Bit Bluetooth to Mobile Bluetooth  but   I am having an issue in connecting. when Scan button is click it is suppose to get the MAC address from the other devices. It's not getting.  when connect button is click it show's an "error 9007: you cannot  connect to a device when the device list is empty. Try scanning again." How to resolve  the issue??.

I have attached the block & code file.

Also I would like to know how  to connect Micro:Bit Bluetooth to the Mobile device Bluetooth, as i have try since i cann't  found the new search for devices name on mobile when microbit bluetooth is turn ON by Pressing Button A and B then pressing reset button on Microbit.

Thank's

Regard's

Shruti

ble.docx

Chris Ward

unread,
Aug 17, 2019, 9:27:28 AM8/17/19
to MIT App Inventor Forum
Hello Shruti

In the future, please do not enclose your information in a .docx file - just place the images directly in your Post.

There is a lot missing from your Blocks before scanning can start, plus no safeguarding.

1) Ensure that the phone has Bluetooth switched on, and ensure the micro bit is on too.
We can use Classic Bluetooth to switch the phone's Bluetooth on, via Activity Starter.

2) For Android API level > 22, the phone must have Location switched on. Currently, we need to Use Taifun's 'Taifun Tools' extension if we have to verify API level:

If your App is only for your own use on your own phone, this verification step is unnecessary because you can code to suit your phone only. You can find out what level your phone is from the chart on my website here:

3) Trap errors with the Screen . Error Occurred Block:

Now, even as the User of your own App, you are tapping buttons that should not be tapped because the process isn't ready - you shouldn't be able to tap a "connect" button until a device has been selected.  If you think about it, a connect button is not required - you can start the connection when the User selects a device from the device list.

I can't give you example code for Location without knowing if the App is for your phone only or will be used on other phones too, because it involves security permissions and how to handle them each time the App is launched. So let me know here! However, for your experiment in getting the phone and device connected, you can switch on Bluetooth and if necessary, Location.

Using code to ensure the phone's Bluetooth is switched on:

BLE_Micro Bit.png





















 

Chris Ward

unread,
Aug 17, 2019, 9:42:43 AM8/17/19
to MIT App Inventor Forum
Hi again

Have you seen the App Inventor Micro bit extension? I do not know if it is 100% compatible with the latest App Inventor version, but it could be useful:

Ghica

unread,
Aug 17, 2019, 11:22:17 AM8/17/19
to MIT App Inventor Forum
You do not Nede the micro:bit extension to connect.
However: you must pair the micro:bit first to your phone, which means jumping through some hoops,
Or,
You can load a hex file in your micro:bit that has the Bluetooth extension loaded (top right settings wheel, load extension) and of course the Bluetooth service started on start (see code.microbit.org) and which has the project settings set to no pairing required (top right settings wheel and click project settings)
Then ,when scanning, you should see your micro:bit listed.
Cheers, Ghica

Ghica

unread,
Aug 17, 2019, 11:38:03 AM8/17/19
to MIT App Inventor Forum
I need to add: to use the micro:bit extension, you need to load the BLE extension first. Of both there are several versions, where some combinations work and some do not. But you will find out when you want to actually do something with the micro:bit. See also it.appinventor.mit.edu
Cheers, Ghica

Ghica

unread,
Aug 17, 2019, 3:07:48 PM8/17/19
to MIT App Inventor Forum
Sorry, typing on an iPad...
http://iot.appinventor.mit.edu/#/
Cheers, Ghica

Shruti Sawant

unread,
Aug 19, 2019, 3:10:24 AM8/19/19
to MIT App Inventor Forum
Hi 
hello, thank's  for  your  response. Henceforth the  information will be posted in images. The mobile location is turn on,   the android version of phone is 9.0 Pie and the app will be used for other phones too. I will try this code and check and   get back to you.

Shruti Sawant

unread,
Aug 19, 2019, 3:11:31 AM8/19/19
to MIT App Inventor Forum
Hi 
I have already gone through this extension and try building the app.

Thank's

Shruti

Shruti Sawant

unread,
Aug 19, 2019, 3:12:39 AM8/19/19
to MIT App Inventor Forum
Hi
The hex file was loaded in micro:bit, with Bluetooth extension but project settings was not change to  "no pairing required".
i will try working on this.

Thank you

Shruti Sawant

unread,
Aug 19, 2019, 3:13:31 AM8/19/19
to MIT App Inventor Forum
hi
Both the extension where add in mit app inventor.

Thank's 

Shruti

Shruti Sawant

unread,
Aug 19, 2019, 4:09:47 AM8/19/19
to MIT App Inventor Forum
In this code,  Bluetooth Client block for Connectivity to be drag and drop or the  Bluetooth Extension to be add??. 

BLE_Micro Bit.png

Chris Ward

unread,
Aug 19, 2019, 7:54:48 AM8/19/19
to MIT App Inventor Forum
Hi Shruti

Yes, the Classic Bluetooth Blocks are a part of App Inventor, not an extension, and you are looking in the right place.

So, with mobile Location turned on, and mobile Bluetooth turned on, were you able to connect to the micro bit?

Ghica

unread,
Aug 19, 2019, 9:52:52 AM8/19/19
to MIT App Inventor Forum
The micro:bit uses Bluetooth Low Energy (BLE), you cannot connect to it using th classic Bluetooth component.
Using an Activity Starter is not a good idea either.
I will post a better reply later.
Cheers, Ghica

Chris Ward

unread,
Aug 19, 2019, 11:10:06 AM8/19/19
to MIT App Inventor Forum
@Ghica

The Classic Bluetooth code is only there to switch the phone's Bluetooth on, via Activity Starter. This is a very popular method.......

Ghica

unread,
Aug 19, 2019, 11:15:28 AM8/19/19
to MIT App Inventor Forum
Hi Shruti,
Use the attached PDF to prepare your micro:bit. Note that you should set the no-sharing option before you load the hex file to your micro:bit.

Then, download the App Inventor BLE extension from here: http://iot.appinventor.mit.edu/assets/resources/edu.mit.appinventor.ble-20181124.aix
Do the instructions in the other attached PDF, but using the extension you just downloaded.
When you have done this, you should be able to connect to your micro:bit.

It depends what you want to do in your app with your micro:bit. If you give us more information, we can point you in the right direction.
You could, for example try the LED toutorial.

It seems that at this moment the links to the tutorials are broken, but the descriptions you can find here: http://iot.appinventor.mit.edu/#/microbit/microbitintro
Cheers, Ghica

MicrobitPrepare.pdf
MIT_App_Inventor_Basic_Connection.pdf

Ghica

unread,
Aug 19, 2019, 11:18:03 AM8/19/19
to MIT App Inventor Forum
@Chris,
I have yet to find a phone where this was necessary...
And it is very confusing, for Shruti, unless we find out that his Bluetooth is indeed off.
Cheers, Ghica.

Shruti Sawant

unread,
Aug 21, 2019, 6:03:09 AM8/21/19
to MIT App Inventor Forum
Hello,
 I am not able to connect the micro:bit bluetooth to mobile. With the Classic Bluetooth Blocks  it is just asking to turn ON bluetooth YES/NO.
further to  get the  device name in Scan button when click it is suppose to get the Micro:bit  bluetooth name that i am not getting. In the Scan button, BluetoothLE1 is call  so i need to add the bluetooth  extension. i have add that extension.

The Program code is written "on start" bluetooth service & set to "no pairing required" and then  download.
how to  go on further?



m.PNGa1.PNG




Thank's

Regard
Shruti

Shruti Sawant

unread,
Aug 21, 2019, 6:12:41 AM8/21/19
to MIT App Inventor Forum
Hello,

With the reference to your send PDF document i have built the MIT APP, but the problem what i am facing is when the SCAN button is click i am not getting the MIcro:Bit  bluetooth device name. it just ask the  where to turn ON bluetooth of mobile YES/NO.  I also try to perform the  pairing the normal Bluetooth pairing process, instead of using the Samsung App i.e pair using Android 's  own setting . Still i am not able the pair  the device.

how do i resolve this issue.

Chris Ward

unread,
Aug 21, 2019, 7:05:49 AM8/21/19
to MIT App Inventor Forum
Hi Shruti

Does your Samsung list the Micro:Bit as an available device (i.e., it can see it?)

Chris Ward

unread,
Aug 21, 2019, 7:10:03 AM8/21/19
to MIT App Inventor Forum
...I'm assuming that the Phone is not far away from the Micro:Bit, no more than 100 metres and no obstacles like thick walls made of cast iron :)

Chris Ward

unread,
Aug 21, 2019, 11:21:55 AM8/21/19
to mitappinv...@googlegroups.com
Hi again Shruti

Can you test the MIT LED Micro:Bit example Project? See attached. Build it into an APK and install it on your Phone.
MicrobitLED.aia

Ghica

unread,
Aug 21, 2019, 3:33:01 PM8/21/19
to MIT App Inventor Forum
Dear Shruti,
Did you see my pdf that described building the micro:bit project?
Do exactly what is described there, or it will NOT work. For example, you must not only start the led service, but also start the Bluetooth service itself. Also, you should react to the connect and disconnect events, as described in the same pdf.
You can then use the .aia that Chris posted. However, it is better to use the companion instead of building an .apk
If you do however, then, before you first open it, open the app settings and set location to on.
But, if you want to understand what is going on, so that you can proceed making your own app, then do also what is described in the other pdf I posted.

Shruti Sawant

unread,
Aug 22, 2019, 3:29:27 AM8/22/19
to MIT App Inventor Forum
Hello,

Screenshot_20190822_124044.jpg

For Bluetooth pairing, Using the Android App, developed by Samsung I am able to pair the MIcro:Bit.

IMG_20190822_124229.jpg


This is what is display when bluetooth is connected.


Thank's

 Shruti


Shruti Sawant

unread,
Aug 22, 2019, 3:30:17 AM8/22/19
to MIT App Inventor Forum
Phone is just next to Micro:bit.

Shruti Sawant

unread,
Aug 22, 2019, 3:31:50 AM8/22/19
to MIT App Inventor Forum
Ok i will try it and get back to you

Thank's 
Shruti

Shruti Sawant

unread,
Aug 22, 2019, 3:38:35 AM8/22/19
to MIT App Inventor Forum
Hello,
 I have refer your document PDF's and try building the APP. Also followed the step of Example of LED using event "ON START" , BLUETOOTH CONNECT and BLUETOOTH DISCONNECT.
The problem is when SCAN button is click on MIT APP, it is asking premisson to turn ON the bluetooth of phone but it is unable to get the micro:bit device name.


Thank's 

Shruti


Chris Ward

unread,
Aug 22, 2019, 7:06:30 AM8/22/19
to MIT App Inventor Forum
Hi Shruti

1) Can you show us the script for your Micro:Bit (before it is compiled to HEX)? 
2) What is your goal - when we get the Bluetooth problems sorted out, what do you want the App to do on the Micro:Bit? 

Ghica

unread,
Aug 22, 2019, 7:30:40 AM8/22/19
to MIT App Inventor Forum
Hi Shruti,
Even better, post your .hex file. You will find it in your download folder when you pressed save. 
(@Chris: you will see the source (blocks) when you drop the hex file on a makecode.microbit.org screen. The hex file is the source code. It is only compiled when you drag the hex file to the micro:bit attached to your PC via USB).

Shruti, Did you have Bluetooth turned on on your phone? It is better to do that before in the settings app of your phone.
Did you also turn on the micro:bit? If you used my pdf example, you should see an "A" on it. Then, if you press Scan, you should see a list of Bluetooth devices, of which one should be your micro:bit, probably you see somewhere the name PAPAG in the list?
What is the App Inventor app on your phone that you are using?
To confuse you further, it is fine to use the Samsung app, to pair your micro:bit, but before you can connect using App Inventor you still need the right hex file loaded on your micro:bit and of course the right App Inventor app on your phone.

And Shruti, please, tell us what you want to do with the micro:bit, please!
Cheers, Ghica.
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Shruti Sawant

unread,
Aug 26, 2019, 3:40:29 AM8/26/19
to mitappinv...@googlegroups.com
Hello,
My goal is to built the APP, using MIT APP Inventor. From the APP  I must able to control the Micro:Bit LED. That is to turn ON/OFF the LED. The  LED will be connected to edge connector to one of the PORT of the  Micro:Bit .
The Hex  file & Apk file is  attached, please do check and let me know where I am going wrong.The Bluetooth  is turned ON on the mobile phone. Micro:Bit Bluetooth is turn ON in setting "no pairing required" .
If scan button is pressed, nothing happens since Bluetooth is turn On in setting before opening the APP on phone.

Thank's 
Regard's
Shruti

microbitled (3).aia
Message has been deleted
Message has been deleted

Shruti Sawant

unread,
Aug 26, 2019, 3:43:04 AM8/26/19
to MIT App Inventor Forum
hex   file
microbit-BLUETOOTH-TEST.hex
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Shruti Sawant

unread,
Aug 26, 2019, 4:00:15 AM8/26/19
to MIT App Inventor Forum
Why i am getting thiis error while uploading   the apk /aia file.
error.PNG
Message has been deleted
Message has been deleted

Ghica

unread,
Aug 26, 2019, 5:51:27 AM8/26/19
to MIT App Inventor Forum
Hi Shruti,
Your hex file looks fine to me. I will try it tonight.
As for uploading apk's or aia's: Do NOT upload an apk, it is against forum policy and we will remove it.
You probably had a problem uploading the aia because it contains an extension. The trick is to EDIT an EXISTING post in this thread and then upload it.
Please try that and let us know.
Cheers, Ghica.
Message has been deleted
Message has been deleted
Message has been deleted

Shruti Sawant

unread,
Aug 27, 2019, 4:05:10 AM8/27/19
to MIT App Inventor Forum
hello
I am not able to attach the apk file.

Chris Ward

unread,
Aug 27, 2019, 7:04:30 AM8/27/19
to MIT App Inventor Forum
Hi Shruti

Just as well, because you must not :)

You can attach your Project File (.aia), by editing your Post and then adding(attaching) the File.

EditPost.png




Shruti Sawant

unread,
Aug 27, 2019, 7:23:08 AM8/27/19
to MIT App Inventor Forum


edit.PNG

This what i am getting the options. There is no edit option .


Regard's

Shruti

Chris Ward

unread,
Aug 27, 2019, 7:27:58 AM8/27/19
to MIT App Inventor Forum
Hi Shruti

It has to be an existing Post, not a new one.

Shruti Sawant

unread,
Aug 27, 2019, 7:34:34 AM8/27/19
to MIT App Inventor Forum
ok, I got it.
I have attached the file.please do check.


Thank's
Shruti

Chris Ward

unread,
Aug 27, 2019, 7:47:25 AM8/27/19
to MIT App Inventor Forum
Hi Shruti

Better to wait for Ghica as she is already looking into it with your Micro:Bit Hex File. Should be easy.........

@ Ghica - Shruti's Project File is attached to her 26 August Post.

Ghica

unread,
Aug 27, 2019, 11:35:41 AM8/27/19
to mitappinv...@googlegroups.com
Hi Shruti,
Not so easy. Your aia did not work because you were using old extensions.
I removed them, imported newer ones and I rebuilt your project.
This one, which I will post in a minute, works - up to a point. You can connect, write the smiley, but not the LED text. There are bugs in the micro:bit extension. I hope MIT will look at the problems soon, but do not keep your fingers crossed.
To note: If you want to attach a LED to the micro:bit via one of the io-pins, you must also load the io-pin micro:bit extension (it is listed as Microbit_ioPin_Simple.
Let us know how you go.
Cheers, Ghica.
microbitled_4.aia

Shruti Sawant

unread,
Aug 28, 2019, 3:17:57 AM8/28/19
to MIT App Inventor Forum
Hello,

I have gone through the App. I am able to get the Micro:Bit device name, connect & disconnect the app, write the smiley.
http://iot.appinventor.mit.edu/assets/com.bbc.micro:bit.profile.aix     is this the new extension  to be added.
And why notifier is added.
where i will get "Display hidden component's in viewer".
Regarding  bugs in the micro:bit extension, as  an when it get's resolved will i  get an update.
As connecting LED to the micro:bit via one of the io-pins,i will  work on it & get back to you.

Thank you Cheers, Ghica for you kind help.

Regard's
Shruti



Ghica

unread,
Aug 28, 2019, 7:23:25 AM8/28/19
to MIT App Inventor Forum
Shruti,
No, that is actually the old extension. I will try to ask Evan what the status of the micro:bit extensions is.
What I meant, is that you have to add this to your design:


Snap1.png



Then you should be able to address the io pins to address the LED that you may have attached to it.
Cheers, Ghica

Shruti Sawant

unread,
Aug 29, 2019, 5:32:32 AM8/29/19
to MIT App Inventor Forum
OK

Shruti Sawant

unread,
Oct 5, 2019, 3:33:59 AM10/5/19
to MIT App Inventor Forum
Hello

Turning On/Off external LED is working using MIT app with Micro:Bit.
I have used the io pins extension  to address the LED.

Thank you
Regard's
Shruti
Reply all
Reply to author
Forward
0 new messages