EspruinoHub and BLE

Posted on
  • I would like to transfer data from a raspberrypi TO my Banglejs.
    The data would be a series of probable two digit codes which would describe various status indicators from an app running on the Pi.
    The reason for using the watch is an easy way to receive alerts etc as it will be used outdoors in the countryside connecting to the pi over a local connection.
    I am wondering ( having read the git posting) if mqtt is a method of achieving this and if there are any examples of this being done.
    many thanks for any suggestions.

  • Hi! Yes, you can definitely do that pretty easily with EspruinoHub.

    There's a bit of info on the commands to send here: https://github.com/espruino/EspruinoHub#connections

    You just need your device's MAC address (which you can see on the EspruinoHub status page at pi:1888/status) - for instance in my case it's c6:a8:1a:1f:87:16.

    Then you just send "\x10E.showMessage('Hello')\n" to "/ble/write/c6:a8:1a:1f:87:16/nus/nus_tx" via MQTT.

    For instance sending "\x10E.showMessage('Hello')\n" should write 'hello' on the screen.

    Or you could send "\x10myStatus=1234;\n" or maybe if you define a function in your Bangle.js app called setStatus then you can just call "\x10setStatus(123)\n"

    The \x10 (char code 16) isn't required, but it just stops the Bangle 'echoing' the characters back via Bluetooth which can make it more reliable if you send loads of data.

    Worth noting that it's hard to use the mosquitto_pub command to send newlines/escape codes. You can do:

    mosquitto_pub -t "/ble/write/c6:a8:1a:1f:87:16/nus/nus_tx" -m 'E.showMessage("Hello There")\
    '
    

    The trailing slash on the line is important as that allows you to send a newline inside a string argument, but it's a bit hacky and it'd be better if you can send directly from within your application.

  • Gordan, Thank you for your reply which I shall pursue.
    Could you briefly explain what the EspruinoHub is?
    Wha do I expect when its installed?
    Many thanks.

  • EspruinoHub is a service which runs and which converts Bluetooth LE traffic into MQTT and vice-versa. It'll also log data and allow you to query it - eg to find the temperature for the past week.

    However if you just want to talk to Bangle.js, there's a whole page on the different ways you can do it from different programming languages: https://www.espruino.com/Interfacing#bluetooth-le

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

EspruinoHub and BLE

Posted by Avatar for user118216 @user118216

Actions