Send message from LoPy through BLE

  • Hi everyone!

    I'm trying to connect two LoPy 4 via BLE and then send a simple message. I've already done it using Wi-Fi, but on the tutorial nothing is said about sockets, so there's someone who managed to send messages using BLE and what code can I use?

    Thanks in advance

  • @Eric73

    I updated the firmware to 1.18 too and it works now.

    Thank you very much for your precious help and time!

  • @GMB124 I have just test the code you have linked and on my lopy4 firmware 1.18.x it work well as expected.
    I connect my phone by nrfconnect android application and notification work fine (and i have connection and no unwanted disconnection).
    I don't do anithing more than the code show, nothing connected on lopy4 wifi.
    Have you check your Lopy firmware release ? and do update if needed ?
    in REPL

    import os

  • @Eric73 Thank you very much for your help, now it's clearer to me how the BLE works.

    Connecting and seeing the changes is fine for me. I followed this topic as it does something like what I want ( The problem now is that I don't manage to repeat the experience following the given code (, as the LoPy doesn't seem to accept the connection. As soon as my smartphone running ''BLE scanner for Android'' connects to the LoPy, it is disconnected again. Maybe I have to connect the devices again in a while(True) cycle...

  • @GMB124 I am not a pycom bluetooth expert, but i have worked on BLE with NRF chip.
    It's look like BLE-Notification is what you can use.
    Once connected to a device, BLE-master scan slave for services&characteristic and read if several property is set for every characteristic,(can be read write notify and indication).
    Every time the slave BLE change a characterstic with notify field set, it send an event to the master on the next keep-connected frame sent by low level connection driver. So if you change a characteristique master can be informed without perform a specific read.

    If you want to "send" every 5 second different data without be connected to a master, you have to change your advertising data.

  • @Eric73 Thank you very much for your answer.

    I managed to scan, advertise and pair through BLE, but if I understood correctly there's no way to send a basic message (such 'Hi') every, let's say, 5 seconds? As far as I know, programming a GANTT service (in my case, sending 'Hi') on the Pycom acting as GANTT server should be possible. Otherwise the only thing I can do with the boards is connecting to an existing service as in the example of 'Heart rate' (

  • Hi, BLE dosen't allow this processing. You can have one device listening (master scanning for advertising frame) and the other device with advertiser connectable role.
    Once BLE master is connected to advertiser it can read/write/notify characteristic in advertiser. This allow data exchange (without socket).
    BUT last time i have take a look at pycom BLE documentation it's only allow basic BLE, scanning and advertising.

Log in to reply

Pycom on Twitter