Communicate two microcontrollers via BLE

Hello,

I'm using a nRF52 DK to test BLE communication with another microcontroller. What I need to test is the nRF52 pairing with another brand microcontroller, send a data stream and close the connection.

Could you please tell me which example from the Bluetooth samples list I can use for starting?

Thanks for your attention.

Regards,

  • Hello ,

    Can I use the NUS to send data to an ESP32 module? I've been trying for a while but the Tx function always fails.

  • Unknown said:
    Can I use the NUS to send data to an ESP32 module?

    If the ESP32 has a properly configured NUS client, then yes. 

    Unknown said:
    I've been trying for a while but the Tx function always fails.
    1. What exactly have you done? 

    2. What did you expect to observe?

    3. What did you observe?

    As far as I can tell this project is your first BLE project, where all properties of the BLE protocol is completely new to you. I think you should set a lower goal than communicating with an ESP32 for your first project, because an insufficient understanding of core BLE concepts creates problems for you at every step. I suggest that you complete our Bluetooth Low Energy Fundamentals course before continuing any further development.

  • Hello,

    I have followed the course before answering. Below my answers:

    1. What exactly have you done? I configured the NUS service on the 'central' example and added a call to the 'bt_nus_client_send' function to permanently send data after the device has been connected to the ESP32. I have also modified the NUS 128-bit UUID to the UUID already set in the ESP32 device (0000-FFFF-0000-1000-8000-00805f9b34fb)

    2. What did you expect to observe? The data received by the ESP32.

    3. What did you observe? I see that the nRF52 can connect to the ESP32 device. Nevertheless, the 'bt_nus_client_send' returns an error value (-128)

    What I'm trying to do is to make the nRF52 work as a central while the ESP32 works as a peripheral using a 128-bit UUID (0000-FFFF-0000-1000-8000-00805f9b34fb). Once both devices are connected I want to send data from the nRF52 to the ESP32. I have tested the NUS example with two nRF52 boards and it works correctly, so I think there is something I'm missing in order to send the data to the ESP32.

  • -128 = ENOTCONN  "Socket is not connected". 

    From subsys/bluetooth/services/nus_client.c:86:

     

    int bt_nus_client_send(struct bt_nus_client *nus_c, const uint8_t *data,
    		       uint16_t len)
    {
    	int err;
    
    	if (!nus_c->conn) {
    		return -ENOTCONN;
    	}
        
        ...
    }

    The bt_nus_client struct provided to bt_nus_client_send does not contain a pointer to a valid connection object. 

    -Edit: 

    Have you implemented the NUS GATT server on the ESP32?

  • I have not implemented NUS GATT server on the ESP32. The ESP32 already has a 128-bit UUID (0000-FFFF-0000-1000-8000-00805f9b34fb) which allows sending/receiving data strings. This works with a mobile application and what I'm trying to do is to make work the nRF52 the same way the mobile application works on the smartphone.

Related