Is that the latest version microbit?
Power User @ghica is a Microbit expert, would be good to have her opinion. At one time, App Inventor had a nice set of functions specifically for microbit but I think they have fallen behind the development of the hardware somewhat.
Is that the latest version microbit?
I understand that send and receive does not work simultaneously.
I am using this app as a bluetooth remote to control 4 push button switches connected to a microcontroller. Android app will send simple codes as (Numeric 1, Numeric 2, Numeric 3 and Numeric 4) via bluetooth to a bluetooth Module named HC-05 connected to Microcontroller. When Microcontroller receives numeric 1 via bluetooth module connected to it, if soft presses the PushButton and so on up to Push button 4.
Once the soft press is done, Microcntroller sends feedback from HC05 bluetooth module as Alphabet A (for pushbitton 1, and B,C or D up to Push button 4. This feedback is captured back in android app for confirmation.
So, the app should first,
- Search for Bluetooth devices.
- Select the Bluetooth Module HC05 from list of available bluetooth connections nearby
- Then send characters either '1', '2', '3', or '4' based on user input.
- This character is received by HC05 bluetooth module connected to microcontroller.
- App should receive back confirmation as 'A', 'B', 'C', or 'D' and change the label text to Push Button Pressed (1,2,3, or 4)
OK, HC-05 uses Classic Bluetooth, so stick with that.
It will be the Address listed and unlike some examples on the forum, do not modify that - App Inventor deals with it automatically.
This is the danger - you need to prevent the User from sending the next value until the receipt of confirmation of the first value has arrived - So on send, disable all send buttons, On receipt, enable all send buttons.
If you are the only ever User, that's perfectly fine - but others would find it confusing. What if I needed to send 3 again and my button now says 'C'?
Not a term I am familiar with, but I assume that a relay or similar will be triggered programmatically.
Yes its a kind of relay triggering programatically.
Chris, i have developed the sketch and program 2 years ago. It used to work fine, until i had to modify a bit.
I have rebuilt the same sketch and understood that i am getting bluetooth permission error on android 12, but works fine with the android 10.
How do i solve the permission error on Classic Bluetooth client.
Have you tried:
Hopefully the microbit version is latest. I got it from Dubai yesterday only. The model version is V2.21 of microbit.
Error 980: The permission BLUETOOTH has been denied.
So - you do need to switch Bluetooth on in the Phone's settings first, before running the App, or in-app:
.... then request Permission.
It has been a while since I made it, but nothing much has changed in the AppInventor support for BLE as far as I know, except this permission stuff. The version of the micro:bit does not matter. You can even connect to a V1 micro:bit, although it will run out of memory much faster.
What I saw in you .aia is that you actually never connect to the micro:bit, so no wonder.
Try my tutorial here: App Inventor, Micro:bit and UART
It does exactly what you need, except that you may need to add permissions.
Something else to note: in makecode, go to settings->project settings and set: No Pairing Required.
That will save you a lot of headache.
Concerning the .hex app, I am not so sure it will work properly. You have to be very careful, or else it will run out of memory. Look at mine. It works.
I made some apps to control a robot car, but as said it is rather limited, momory is never enough.
Also it is a real pity that the BLE extensions were never properly updated, but if you use the really old one for the microbit (UART only) it will work.
Let us know how you go.
Hi Chris, I followed your instructions. But still the error persists.
I do not know what mistake am I making.
No Block asking for permission?
Side note - having the scanned addresses go straight into the List component could omit devices that have not been discovered yet. It's usually a good idea to use a Clock timer.
Thanks @Ghica I will try your apps tomorrow morning.
Hopefully your apps will help me to send message from microbit to mit app (mobile) and display it in a label.
It seems like it does not support Android 12, as blocks for BLUETOOTH_CONNECT and BLUETOOTH SCAN are missing.
I added the blocks for the same in the mit app.
But getting errors:
Refer to the updated mit app:
BTReadWrite.aia (296.0 KB)
Help to resolve these issues for BT connectivity.
Android mobile version 12
Thanks in advance.
And again and again and again ...
Use the current version of the BLE extension!
Sorry I missed out on updating BLE extension.
Thanks for the response.
I will keep this in mind... ( )
Sorry, I may be stupid, I intended to update my tutorial this morning, but where is the updated extension??