arduinobluetooth-lowenergyhm-10

How do I set services and characteristics for HM-10 BLE on Arduino Uno?


I have an Arduino Uno connected to an HM-10 BLE device. I want to be able to communicate with this through a Xamarin forms application. Unfortunately, I realized that in order to do so, it is necessary to define available services and supporting characteristics on the Arduino for the BLE module, before I can start using it.

I have looked into a few libraries, i.e. CurieBLE, which seems like the most prominent option, but it doesn't support the good old Arduino Uno.

Are there actually any libraries for this purpose online that I have not come across yet, and if not, how do I go about defining services and characteristics myself?


Solution

  • that's not how it works. The HM10 has the characteristics and services that you need build in and communicates with your Arduino trough the RX and TX pins.
    You need the softserial library to create an extra serial connection.

    Also consider that most HM10 devices are only 3.3 volt compatible and need a level shifter to work with your Arduino! On the other hand I connect the RX to TX and TX to RX without level shifter without a problem, but thats your risk.

    Connect your TX and RX pins of your softserial port to the TX and RX pins on your HM10 device. Create a sketch for your Arduino that can read and write to your softserial connection and you are done.

    Setup your Xamarin application as BLE-client.
    On the Xamarin forms application your application has to find the device,
    connect to the device by getting the services,
    select the service you need(for my HM10 it is 0000ffe0-0000-1000-8000-00805f9b34fb),
    get the characteristics of the selected services, select the characteristic you need(for my HM10 it is 0000ffe1-0000-1000-8000-00805f9b34fb),
    write the ClientCharacteristicConfigurationDescriptor to the characteristic to be able to receive notifications.

    If you send a message from your Arduino(CHAR or BYTE-array wit a maximum of 20 bytes), your application can receive it in notifications. If you write a message from your application you can read it in Arduino.

    To understand the work flow of the Xamarin application have a look at my example on Github:https://github.com/GrooverFromHolland/SimpleBleExample_by_Devicename
    It is not a Xamarin example but a Universal Windows BleExample, only to show what is needed to setup a connection.

    If you have a problem with the example, create an issue on my Github page.
    For other questions use the comments here.