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);
}