I gave you the link to the pdf where this is explained. It is the same for all BLE devices.
I tried to follow the instructions. Nothing works. Maybe someone has a code to connect a microbit to a smartphone?
Doesn't anyone have a piece of code to connect microbit to a smartphone?
It should work with the out-of-the-box Micro:bit code. Once you start changing the code by using MakeCode, then you'll need to potentially reset your Bluetooth connection for it to work. Service and characteristics are cached by Android so that it doesn't have to query them again on future connections, but if you've changed the code on the device naturally it might have different services/characteristics than before. Usually turning the Bluetooth off and back on again is sufficient to achieve this. I would recommend starting with the stock hex code for the micro:bit and our micro:bit tutorial to make sure that all works first and then you can start customizing the micro:bit code from there.
I gave it to you above. You need a hex file on your micro:bit that you can make using MakeCode as described above. Then, on your phone you can create the app as described above also.
Or, if your micro:bit is still unchanged, out of the box, you can use the same app. The tutorial is already given to you twice. see above.
What do you want to do with the micro:bit when you have connected it to the phone?
Hi I have just encountered the same problem as mentioned. Would it be alright for you guys to help me spot the errors in my code as I am quite new to this. Thank you.
Hi sir,
Could you kindly help me to debug my code? Thousand of thanks!
Hi Mystery,
You are writing that you have the same problem. But which problem??
First of all, which BLE extension are you using?
Second, which Micro:bit extension?
Then, did you try to connect without looking at the pins?
First things first, when you are able to connect, you can expand your App Inventor app and your Micro:bit app, but if you do not do that first, you have no clue where the problen could be, and neither do I. Let us know.
Hi thank you so much. All the connection is working, including the bluetooth and the microbit. However this error message popped out. My BLE was also the latest
Hi Mystery,
How do you know that the versions you are using are the latest?
Show version numbers and links were you got them from.
Then, your micro:bit code, could you try to make it work without the bluetooth connection?
And, you get your error message because you should start the io pin service at start, and only once, not everytime you are trying to read the pin. Also there is no merit in reading the pin three times, that will only be confusing.
So, step 1: make the micro:bit code work, stand alone
Step2: make the connection with Bluetooth work,
Step3, make them work together.
I'm having the same problem.
On Sunday I compiled the apk and made a checkpoint of my code.
Yesterday I made a small change by adding the LocationSensor to do some tests and this error appeared. I removed the LocationSensor, but the error persists.
The apk I generated on Sunday works, but if I try to create a new one with the current code (which is the same as on Sunday) or even the checkpoint code, the error persists.
I am using the BluetoothLE extension 20200828 and an ESP32.
Projeto_Cerebro_Educacional_REV04.aia (449.5 KB)
Normally this happens if you've changed the functionality of the corresponding BLE device in some way. One of the ways that the LE part of BLE works is by having the central device cache all of the services it saw when it first connected so they don't have to be re-read every time (the expectation being that most devices are production/commercial devices and thus won't be end-user configurable). Because of this, when App Inventor tries to connect to an expected service, such as the micro:bit's button service, but it wasn't originally enabled on the micro:bit, the Android device will report it as missing even if you've subsequently turned it on. There are a few different techniques that work for reseting it. The first is if you use an app like nRFConnect or similar you can usually force a refresh of all devices. The second that I usually use is to turn off and on the Bluetooth functionality. This tends to clear the cache of what the phone knows about and next time you connect it will requery the BLE device. Sometimes you may also need to unpair and then re-pair the device.
It seems I encountered a similar situation. I followed this document. http://iot.appinventor.mit.edu/assets/howtos/MIT_App_Inventor_Microbit_LED.pdf
- I paired my Andriod phone with my microbits successfully.
- I'm able to connect my Andriod phone to my microbits via bluetooth successfully through the app that created according to the above PDF document.
- When I follow the instruction to write text to LED in the above PDF document and tried to send some text to my microbits, I got this message.
Service e95dd91d-251d-470a-a062-fa1922dfa9a8, characteristic e95d93ee-251d-470a-a062-fa1922dfa9a8 are not published by the connected device.
Note: You will not see another error reported for 5 seconds.
And my microbits show nothing on LED.
Please help. Thanks everyone.
What do you have on your micro:bit?
And which micro:bits do you have, v1 or V2?
I have V1 microbits.
This is my aia file. I'm not sure what I do wrong. Thank you.
BasicIoTSetup.aia (250.9 KB)
Hi,
Somehow getting the micro:bit extensions right is a forever struggle it seems.
I know someone is working on it at MIT.
In any case, the BLE extension you are using is old, download a new one from here:
http://iot.appinventor.mit.edu/#/bluetoothle/bluetoothleintro
You can just upgrade your ble extension by loading it. Unfortunately that does not work for the newer micro:bit extension you could use: http://iot.appinventor.mit.edu/#/microbit/microbitintro
So, if you want that one, you should rebuild your project from scratch.
Sorry, I do not have one for you ready.
On your micro:bit you could use some MakeCode .hex file, for example this one:
microbit-simpleLed.hex (1.5 MB)
If the LED service still does not work, you could try to use the right UUID's directly.
@Ghica Thank you so much for your advice and resources! I will try to solve my problem accordingly given that I'm quite new to both Appinventor and microbits. Thanks again.
Regards,
Jib
Now it's working.
I can click SmileyButton and microbits show smiley.
But for the block WriteLEDButton.Click, it still show blank LED. I will try further. Thank you.
Hola, he tenido el mismo problema o creo que el mismo, y por lo menos el mío lo solucioné seleccionando en componentes las extenciones, la microbit_led y la Microbit_io_pin y en propiedades le asigné el BluetoothDevice que por defecto está en ninguno, y listo con eso me funcionó, adjunto impágenes
thanks a lot, you saved my life, at least until now