arduinobluetoothbluetooth-lowenergyhm-10

BLE: HM10 indicate no read property when characteristic has read property


I am attempting to use HM10 as central to read data from a sensor. The HM10 has been flashed with the latest firmware V710 to use the self learn functionality.

Here is the list of messages I am sending and receiving from the HM10

HM10 message list

First I configure the HM10 as central and turn on some notifications. Then I connect to the MAC address of the sensor. I use the AT+FINDSERVICES? command to get the list of services, then find all the characteristics in the range of that uuid. The characteristics I am interested in is 0021.

But here is when the problems start. If I try to read that characteristic I get OK+DATA-ER, which the datasheet the characteristic does not have a read property. Same thing with notify.

HM10 datasheet regarding the AT+READDATA command

But from the AT+CHAR command we can see handle 0021 has both read and notify. I have also tired reading from 001E handle and I get the same error. I am able to read data like the device name from another handle so I am able to get some data off the sensor.

I am wondering if the OK+DATA-ER response can mean something else? Or if the characteristic handle isn't correct somehow. If that were the case how would I find the correct handle?

I have tried connecting to the sensor on my iphone using the LightBlue app and I am able to both read and subscribe to the notification. I have also tried cloning the sensor as a virtual device on LightBlue and I am able to read and subscribe from the HM10 to the phone. So the issue seem to be between the HM10 and the sensor specifically and not with either device individually.

LightBlue UUID

LightBlue read data


Solution

  • I figured it out. Turned out to be a security issue. The sensor would allow connection but no data would be accessible unless the connection was encrypted.

    The BLE sensor required pairing when it first connect to a phone and does not subsequently so I missed that fact when I was trying to connect to it via the HM-10.

    I don't believe the HM-10 supports pairing connection. I tried setting AT+TYPE to other than 0 but it would no longer connect to the sensor. I would get OK+CO11A but it wouldn't finish connecting.

    I switched to an ESP32 board and used

    BLEDevice::setEncryptionLevel(ESP_BLE_SEC_ENCRYPT);
    

    This allowed me to read and subscribe to the characteristic.