BLE data from another esp32 - OMG Gateways / Bluetooth gateways

I hope you can assist me in resolving an issue I’m facing regarding sending temperature data from an ESP32 to OpenMQTTGateway (OMG). I have attempted to achieve this using the NimBLE library but have encountered some problems.

Specifically, my mobile device can successfully detect the temperature data sent by the ESP32. However, OMG seems unable to locate the device, resulting in the inability to receive the data correctly. This has left me puzzled, and I am unsure of the root cause of the problem.

I have reviewed my ESP32 code and ensured that it is properly configured to communicate with OMG using the NimBLE library. I have also confirmed that the MQTT configuration is correct, but it appears that the issue persists.

I am hoping you can provide some guidance to help me identify the source of the problem and how to resolve it. Perhaps there are specific settings or steps I may have overlooked, or there are common issues and solutions that I am not aware of.

If possible, please provide more detailed information or suggestions to aid me in pinpointing the root cause and enabling the ESP32 to successfully transmit temperature data to OMG.

Thank you very much for your assistance and guidance. I look forward to your response in order to address this issue.

here is my code

#include <NimBLEDevice.h>
#include <NimBLEServer.h>
#include <NimBLEUtils.h>
#include <NimBLE2904.h>

BLEServer* pServer = NULL;
BLEService* pService = NULL;
BLECharacteristic* pCharacteristic = NULL;

float simulatedTemperature = 25.0; 

void setup() {
  NimBLEDevice::init("ESP32 Temperature Sensor");
  NimBLEAdvertising* pAdvertising = NimBLEDevice::getAdvertising();

  pServer = NimBLEDevice::createServer();
  pService = pServer->createService("1809"); // Environmental Sensing Service
  pCharacteristic = pService->createCharacteristic(
    "2A1C", // Temperature Measurement characteristic
    NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::NOTIFY
  );

  pCharacteristic->addDescriptor(new NimBLE2904());

  pService->start();

  pAdvertising->start();
}

void loop() {
 
  simulatedTemperature += 0.1;
  if (simulatedTemperature > 50.0) {
    simulatedTemperature = 25.0;
  }


  pCharacteristic->setValue(String(simulatedTemperature, 1)); 
  pCharacteristic->notify();

  delay(5000); 
}

Hi @taiwansensor.com

OpenMQTTGateway uses the Theengs Decoder library to recognise and decode freely broadcast advertising data, so it will only recognise and decode sensors, i.e. manufacturerdata and/or servicedata, which have been defined in existing decoders.

While we are planning to include some of the more common standard Bluetooth SIG service/characteristics, for your above mentioned Health Thermometer Service/Temperature Measurement there is no existing decoder available, so it won;'t get recognised by OpenMQTTGateway.

What you could do is create your own decoder to include in a fork of the Theengs Decoder library, Instructions on how to create decoders are available at

Alternatively you could also emulate one of the existing temperature devices decoder’s advertising message to already have it recognised and decoded.

Could you also post an example of how your ESP32 advertising data is being received by OpenMQTTGateway, but undecoded, by monitoring the OMG MQTT messages?

For that you need to set Advertisement and Advanced data to true.

Let us know how you get on.