# Error when trying to send data to Thunkable app through Bluetooth

**URL:** https://community.thunkable.com/t/error-when-trying-to-send-data-to-thunkable-app-through-bluetooth/3113308
**Category:** BLE / BlueTooth
**Created:** [July 25, 2024, 3:19pm UTC](https://community.thunkable.com/t/error-when-trying-to-send-data-to-thunkable-app-through-bluetooth/3113308 "2024-07-25T15:19:07Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![chrismdisalvoohxko](https://avatars.discourse-cdn.com/v4/letter/c/49beb7/32.png) [@chrismdisalvoohxko](https://community.thunkable.com/u/chrismdisalvoohxko)
#### Post date: [July 25, 2024, 3:19pm UTC](https://community.thunkable.com/t/error-when-trying-to-send-data-to-thunkable-app-through-bluetooth/3113308/1 "2024-07-25T15:19:07Z")

</div>

Hello,  
I am trying to send multiple data values to my Thunkable app through Bluetooth. I am using an Arduino MKR WIFI 1010 to send data. I have successfully connected to my app via Bluetooth but whenever I try to send data, I get an error. I will attach below my Thunkable blocks, Arduino code, and picture of my error message. Any help and suggestions are greatly appreciated.

 ![Thunkable Blocks](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/0/6096e6348540952b2730094d124b0aac29f6aea0.png)

```auto
#include <ArduinoBLE.h>

BLEService batteryService("180F"); // Custom service UUID
BLECharacteristic batteryPercentageChar("2A19", BLERead | BLENotify, 20);
BLECharacteristic batteryVoltageChar("2A1C", BLERead | BLENotify, 20);

void setup() {
  Serial.begin(9600);
  while (!Serial);

  if (!BLE.begin()) {
    Serial.println("Starting BLE failed!");
    while (1);
  }

  // Set advertised local name and service UUID
  BLE.setLocalName("BatteryMonitor");
  BLE.setAdvertisedService(batteryService);

  // Add characteristics to the service
  batteryService.addCharacteristic(batteryPercentageChar);
  batteryService.addCharacteristic(batteryVoltageChar);

  // Add the service
  BLE.addService(batteryService);

  // Start advertising
  BLE.advertise();
  Serial.println("Bluetooth device active, waiting for connections...");
}

void loop() {
  BLEDevice central = BLE.central();

  if (central) {
    Serial.print("Connected to central: ");
    Serial.println(central.address());

    while (central.connected()) {
      // Simulate battery percentage and voltage
      int batteryPercentage = 75; // Example percentage
      float batteryVoltage = 3.7; // Example voltage

      // Convert to strings
      String percentageStr = String(batteryPercentage);
      String voltageStr = String(batteryVoltage, 2); // Two decimal places

      // Write data to characteristics
      batteryPercentageChar.setValue(percentageStr.c_str());
      batteryVoltageChar.setValue(voltageStr.c_str());

      delay(1000);
    }

    Serial.print("Disconnected from central: ");
    Serial.println(central.address());
  }
}

```

 ![Thunkable Error](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/6/268806877b7dff259e46c2037859e339e9fb6537.png)

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [July 25, 2024, 8:01pm UTC](https://community.thunkable.com/t/error-when-trying-to-send-data-to-thunkable-app-through-bluetooth/3113308/2 "2024-07-25T20:01:47Z")

</div>

Hi @chrismdisalvoohxko , welcome to Thunkable! 🎉  
Is your hardware using the NOTIFY method?

Another creator had the same issue and was able to resolve it using this method: [iOS Bluetooth App doesn’t receives any data - Questions about Thunkable / BLE / BlueTooth - Community](https://community.thunkable.com/t/ios-bluetooth-app-doesnt-receives-any-data/2419863)

---

<div class="post-metadata">

### Author: ![chrismdisalvoohxko](https://avatars.discourse-cdn.com/v4/letter/c/49beb7/32.png) [@chrismdisalvoohxko](https://community.thunkable.com/u/chrismdisalvoohxko)
#### Post date: [July 26, 2024, 5:57pm UTC](https://community.thunkable.com/t/error-when-trying-to-send-data-to-thunkable-app-through-bluetooth/3113308/3 "2024-07-26T17:57:36Z")

</div>

Hi,  
I figured it out! In order to send the data, I needed to use a 32-bit characteristic UUID instead of a 4-bit characteristic UUID. I was then able to read data via BLE on an Android tablet. I still have not tested this on IOS but will be soon. Here is an updated code for anyone in the future.

```auto
#include <ArduinoBLE.h>

BLEService batteryService("180F"); // Custom service UUID

// Create characteristics using 32-bit UUIDs
BLECharacteristic batteryPercentageChar("00002A19-0000-1000-8000-00805F9B34FB", BLERead | BLENotify, 20);
BLECharacteristic batteryVoltageChar("00002A1C-0000-1000-8000-00805F9B34FB", BLERead | BLENotify, 20);

void setup() {
  Serial.begin(9600);
  while (!Serial);

  if (!BLE.begin()) {
    Serial.println("Starting BLE failed!");
    while (1);
  }

  // Set advertised local name and service UUID
  BLE.setLocalName("BatteryMonitor");
  BLE.setAdvertisedService(batteryService);

  // Add characteristics to the service
  batteryService.addCharacteristic(batteryPercentageChar);
  batteryService.addCharacteristic(batteryVoltageChar);

  // Add the service
  BLE.addService(batteryService);

  // Start advertising
  BLE.advertise();
  Serial.println("Bluetooth device active, waiting for connections...");
}

void loop() {
  BLEDevice central = BLE.central();

  if (central) {
    Serial.print("Connected to central: ");
    Serial.println(central.address());

    while (central.connected()) {
      // Simulate battery percentage and voltage
      int batteryPercentage = 75; // Example percentage
      float batteryVoltage = 3.7; // Example voltage

      // Convert to strings
      String percentageStr = String(batteryPercentage);
      String voltageStr = String(batteryVoltage, 2); // Two decimal places

      // Write data to characteristics
      batteryPercentageChar.writeValue(percentageStr.c_str());
      batteryVoltageChar.writeValue(voltageStr.c_str());

      delay(1000);
    }

    Serial.print("Disconnected from central: ");
    Serial.println(central.address());
  }
}

```

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [July 26, 2024, 6:03pm UTC](https://community.thunkable.com/t/error-when-trying-to-send-data-to-thunkable-app-through-bluetooth/3113308/4 "2024-07-26T18:03:28Z")

</div>

Hi @chrismdisalvoohxko  
Thank you for sharing an update and the code  
Glad that is working now.
