Many thanks for the help, I attach aia to the message.
The hex function does not require a connection, connect to any available device. And included bluetooth input pin io pinBLE_microbit.aia (759.6 KB)
Hi Klim,
Thanks. It is hard for me to try your app without a .hex file for the micro:bit.
Anyway, looking at your .aia I found that you are using outdated versions of the BLE and the micro:bit extensions. It may help to replace them with newer ones at http://iot.appinventor.mit.edu/
Cheers, Ghica.
Thanks for the answer! Maybe someone could lay out a chat code for connecting a microbit to a smartphone? And I’ll add Dalia!
Look here: http://iot.appinventor.mit.edu/assets/howtos/MIT_App_Inventor_Basic_Connection.pdf
Make a .hex file like this:
And, to prevent a lot of headaches, go to the settings and set no pairing required.
Cheers.
Thank you so much! But I need code written in Mit APP.
Guys help, please discard the working version of the code that connect the microbit to the smartphone.
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?