Unable to connect to Device

I’ve been trying to get my app to connect a Bluetooth device using Thunkable. It’s a very simple app. All it does is scan for a particular device name and connect to it. However, I can’t seem to get it to connect. I followed all the steps in the tutorial. But I keep getting the following error when it tries to connect using the device name: Device XXXXXXXX was disconnected.

What am I doing wrong?

In a situation like this, you’ll want to declare what happens when an error occurs first. Which means instead of saying if not error, you’d switch your sections in the if block around and put it as:

if error:
  set stored variable Error to join:
    "Error Connecting",
    newline
    ERROR MESSAGE
  navigate to ScrnError
else:
  set stored variable DeviceID to DEVICE ID
  navigate to ScrnSteps

If you’re planning to save this device to the app until deletion, then keep your variables as a stored variable. Otherwise, use an app variable.

I tried changing it around but it still didn’t work. I’m able to connect to a virtual Bluetooth device that I created with LightBlue so I’m beginning to think it might have something to do with the Bluetooth device that we’re using.