This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Sending data received with BLE scanner to esp32 with uart

Hi everyone. I want to take advertising data with ble scanner and transmit to esp32 via uart. But I don't know how to do this. Is there an example for this? I need your help on this.

Parents
  • Hello sasci,

    Have I understood you correctly that you intend to use a nRF52840 SoC as a scanner device that forwards the advertising reports it finds through to a esp32 module through an UART connection? If so, do you intend this to scan for all devices, or only looking for a specific device?

    If looking for a specific device's advertising you may start out with the BLE APP UART central example, and then use the BLE_GAP_EVT_ADV_REPORT from the filter match to be output on the UART.
    You can re-use the section from the BLE_NUS_C_EVT_NUS_TX_EVT event to print the data to UART.
    You will also need to set connect_if_match to false, if you intend not to connect to a device that matches your scanner filters.

    Best regards,
    Karl

  • Hello Karl,

    Thank you for your advice. I want to write a code that sends battery advertisement of many bluetooth devices to esp and want it to establish esp communication with uart. Which SDK should I choose for the examples you mention?

Reply Children
  • sasci said:
    Thank you for your advice.

    No problem at all, I am happy to help!

    sasci said:
    I want to write a code that sends battery advertisement of many bluetooth devices to esp and want it to establish esp communication with uart. Which SDK should I choose for the examples you mention?

    We generally recommend that new developments make use of the new nRF Connect SDK, but the application you describe sound very similar to the existing BLE NUS central application in the nRF5 SDK. This application scans for specific devices (filters on advertised UUID's) and has UART already in use.
    You will need to remove the UUID filter, and have the advertising reports output on the UART as described in my previous comment.

    Best regards,
    Karl

  • Hi Karl,

    I have a problem. I worked hard on this subject but every time i got error on app_uart_put(). I can't send data with app_uart_put() but when I use printf() I can read data from esp32. Which is correct for uart? And why?

  • What error do you get when you try to use app_uart_put?
    printf prints on UART if RETARGET_ENABLED is defined to 1 in the sdk_config.h.

    Best regards,
    Karl

  • When I use app_uart_put(), don't read received data. But I can read that on J-link RTT.

  • sasci said:
    When I use app_uart_put(), don't read received data.

    Specifically which error does the function return?
    Please make sure to have DEBUG defined in your preprocessor defines like shown in the included image:

    This will make your logger output a detailed error message whenever a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK.

    sasci said:
    But I can read that on J-link RTT.

    If you have configured the logger to use the RTT backend you will see the NRF_LOG_* statements printed to RTT. The RTT terminal does not output UART messages.


    Best regards,
    Karl

Related