# Unable to connect to Device

**URL:** <https://community.thunkable.com/t/unable-to-connect-to-device/3820102>\
**Category:** BLE / BlueTooth\
**Tags:** beginner, bluetooth, help\
**Created:** [May 11, 2025, 8:24pm UTC](https://community.thunkable.com/t/unable-to-connect-to-device/3820102 "2025-05-11T20:24:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hellos5lu97](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@hellos5lu97](https://community.thunkable.com/u/hellos5lu97)\
**Post date:** [May 11, 2025, 8:24pm UTC](https://community.thunkable.com/t/unable-to-connect-to-device/3820102/1 "2025-05-11T20:24:12Z")

</div>

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?

 ![IMG_7605](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/b/cbacb57ef41727e1bcebec10ceeb6b1be1d93ed3.jpeg)

 ![Screenshot 2025-05-11 at 9.22.31 pm](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/7/d7fd02912b21336265647afbe2488cc963c87607.png)

---

<div class="post-metadata">

**Author:** ![krish05](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/krish05/32/200523_2.png) [@krish05](https://community.thunkable.com/u/krish05)\
**Post date:** [May 12, 2025, 9:17pm UTC](https://community.thunkable.com/t/unable-to-connect-to-device/3820102/2 "2025-05-12T21:17:27Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![hellos5lu97](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@hellos5lu97](https://community.thunkable.com/u/hellos5lu97)\
**Post date:** [May 12, 2025, 10:15pm UTC](https://community.thunkable.com/t/unable-to-connect-to-device/3820102/3 "2025-05-12T22:15:25Z")

</div>

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.
