BLE_bluetooth Can't recieve data from arduino (esp32)


I’m trying to recieve some response from arduino to thunkable. When I try to send to arduino ther’s no problem, recieving seems not to fire any erros but no response is shown.


I have arduino code:

    Based on Neil Kolban example for IDF:
    Ported to Arduino ESP32 by Evandro Copercini

#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
const byte ledG = 33;

// See the following for generating UUIDs:

#define SERVICE_UUID        "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"

class MyCallbacks: public BLECharacteristicCallbacks {
    void onWrite(BLECharacteristic *pCharacteristic) {
      std::string value = pCharacteristic->getValue();

      if (value == "0") {
        digitalWrite(ledG, HIGH);
      } else {
        digitalWrite(ledG, LOW);

   void onRead(BLECharacteristic *pCharacteristic) {
      int MyResponse;
      if (digitalRead(ledG) == LOW){
        MyResponse = 1;
      } else { 
        MyResponse = 0;


    /*void onRead(BLECharacteristic *pCharacteristic) {
      struct timeval tv;
      gettimeofday(&tv, nullptr);
      std::ostringstream os;
      os << "Time: " << tv.tv_sec;

void setup() {

  Serial.println("1- Download and install an BLE scanner app in your phone");
  Serial.println("2- Scan for BLE devices in the app");
  Serial.println("3- Connect to MyESP32");
  Serial.println("4- Go to CUSTOM CHARACTERISTIC in CUSTOM SERVICE and write something");
  Serial.println("5- See the magic =)");

  pinMode(ledG, OUTPUT);

  BLEServer *pServer = BLEDevice::createServer();

  BLEService *pService = pServer->createService(SERVICE_UUID);

  BLECharacteristic *pCharacteristic = pService->createCharacteristic(
                                         BLECharacteristic::PROPERTY_READ |

  pCharacteristic->setCallbacks(new MyCallbacks());

  pCharacteristic->setValue("Hello World");

  BLEAdvertising *pAdvertising = pServer->getAdvertising();

void loop() {
  // put your main code here, to run repeatedly:

Hi @proximilius, hope you are having a great weekend. Our engineers made an update to our platform last night that should have resolved this. Can you please test this again?

Many thanks, now it works.

Maybe the problem was also my “onRead” function inside the arduino script. With the old script my information label on the app refreshed into a blank with no text. After a small change now everything seems to be working.

New arduino snippet (with un changed thunkable blocks):

void onRead(BLECharacteristic *pCharacteristic) {
      int MyResponse;
      if (digitalRead(ledG) == LOW){
      } else { 

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.