BLE scan function not working

Hi,

I have been working on an app for a school project and I need to connect my app to an Arduino board via Bluetooth. However, the BLE scan function returns “undefined” as an output no matter what I do. I am using Thunkable Live on an Android phone. I have also allowed all permissions and switched on Bluetooth on my phone, but it is still not working. My code is below.


I hope you can give me some tips on what I have done wrong or what I should do to solve this problem. Thanks!

@rariac, can you add a location sensor to your project and try again please?

Thanks

hi @rariac,

try adding a list viewer and settimg text items of list viewer rather than a single label. looks like you are trying to set text of a label to a list of mac addresses and I’m not sure you can do it that way.

1 Like

My project actually does have a location sensor in it. I’m sorry I didn’t mention it because I thought they were unrelated haha. What should I do now?

Hi! So I tried using a list viewer instead of a label and now there is not output at all not even the “undefined”. Also, just in case something else is interfering with it, the code for my entire page is below.


I actually got this code from another thunkable community post which I can’t find right now but if you need to see it I can try and dig it up. The device name part is blank right now because I’m only testing out the scanning function. Thanks!

hi @rariac,

I just duplicated these simple blocks and it works for me. Are you getting a mac list if you swap Device Names with Device Ids?

I’m starting to wonder if you have a hardware issue. Can you install BLE scanner or a similar app and check for signals on that as well.

1 Like

hi @eddie.rebehy!

I don’t know what a mac list is, but after switching the blocks around I’m still not getting any output.

I can’t download anything at the moment but I will update you about the BLE scanner once I get wifi.

hi @rariac

I’ll let you do your own research on this but In simple terms, mac address is a unique number that is used to identify the ble device. scanning for names may show blank lines if a device is advertising without a name but it will always have a mac address and hence you can see if a device is being scanned or not even if no name exists. Get things working with macs (ID) before you worry about names.

the ble scanner apps will allow you to scan, connect, read and write to a device independant to Thunkable so you can rule out code errors or bugs before debugging.

good luck.

So i was trying to do the same thing with the BLE component.
These are the blocks that i am using


The error messages i get are as follows,

BleError: BluetoothLE is powered off

i turn on bluetooth

BleError: Location Services are disabled

i turn on gps
The message stays put on the screen for 3~4 clicks of the scan button and then changes to

BleError: Cannot start scanning operation

After this i have tried the basics
(reinstalling the app, turning bluetooth off and on again, clearing paired devices, downloading it as an app and then trying the steps)
The only suspicion I have is that the live demo app does not ask for bluetooth permissions (if there are any). I have looked into it but they do not contain bluetooth permissions.
Please do give a lead on how to solve the same problem, or if there is a workaround for the same