This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to get thingy data on nRF52840?

Hi.

I want to get thingy's sensor data on nRF52840.

I found that 'ble_app_multi_link_multi_role' example, but there are only get button and led state.

By using that project, i wrote sd_ble_gattc_char_value_by_uuid_read funtion to get data. But i get NRF_ERROR_BUSY and NRF_ERROR_INVALID_PARAM errors.

Could you help me to get thingy's sensor data? Thank you for reading.

    ble_thingy_tes_c_evt_t ble_thingy_tes_c_evt;
    uint32_t err_code;

    ble_gattc_handle_range_t   t_range;
    t_range.start_handle=0x0001;
    t_range.end_handle=0xffff;

    ble_uuid_t t_uuid;
    t_uuid.type = THINGY_TES_UUID_SERVICE;
    t_uuid.uuid = THINGY_TES_UUID_TEMPERATURE_CHAR;
    
    ble_thingy_tes_c_evt.conn_handle                  =   p_ble_thingy_tes_c->conn_handle;
    err_code   =   sd_ble_gattc_char_value_by_uuid_read(p_ble_thingy_tes_c->conn_handle , &t_uuid, &t_range);

Parents
  • Sorry for the delayed response. We are working an example where the Thingy:52 will communicate with a nRF52 DK. I will let you know when this example is finished. Until then, you can start by using the multilink central example from sdk 15. Change the m_target_periph_name[] in main.c to be the name that you gave to your Nordic Thingy (if you have not defined a new name, it is most likely "Thingy").
    Then, you can essentially just copy what the lbs button service does to connect to the environment services of the Thingy device (for example temperature) instead. I will assume below that you want to get the temperature data from the Thingy:52.
     
    Start by taking a look at how the lbs_c_init function initializes the LED button collector. The struct ble_lbs_c_init_t can be changed to be an event handler for the Thingy temperature service. Also take a look at the ble_lbs_c_s struct & make sure to change the peer_lbs_db & evt_handler to conform to the new event handler for the temperature service. The lbs_db_t struct should be changed to include the include the cccd_handle of the temperature characteristic & the temperature_handle I believe.
     
    Also make sure to take a look at the lbs_c_evt_handler & update this function to handle a BLE_TES_C_EVT_DISCOVERY_COMPLETE instead of BLE_LBS_C_EVT_DISCOVERY_COMPLETE. Take a look at ble_lbs_on_db_disc_evt() for more info too.
     
    Make sure to update the BLE_LBS_C_EVT_BUTTON_NOTIFICATION event too to be a BLE_TES_C_EVT_TEMPERATURE_NOTIFICATION instead. Take a look at on_hvx() for more info.
     
    There are most likely more lines of code to change, but this is a good starting point. I would definitely make sure to take a good look at the multilink central example & the ble_app_blinky peripheral example (from SDK 15) & make sure you understand how the LED button service (LBS) is initialized, handled & sent over BLE on the peripheral side. Then, take a look at how the LBS is handled on the central side. 
     
    Once you have fully understood this, you can take a look at the Thingy SDK code, see how the temperature service is initialized, handled & sent over BLE & do something similar to the LBS on the central side.
     
    This devzone case could also be a helpful starting point. It might also be useful to take a look at this custom service tutorial to see how to work with services in general, as well as these three links: link 1, link 2, link 3.
  • Here is the example for transferring environment sensor data from the Thingy:52 to a nRF52xx DK: https://github.com/crfosse/Thingy-52-to-nRF52xx. The readme should explain how to use it, but if you are struggling don't hesitate to ask.

    It's still work in progress, but it is functional!

    - Carl Richard

  • What is the purpose of getting the thingy data onto a nrF52xx? I can adopt the example to retrieve the motion data, but I need to store this data so that I can process later. What am I missing?

    Thanks,

    --Rasit

  • Hi Rasit,

    In this demo, we wanted to transfer the Thingy sensor data over BLE to a nrf52 & connect the nRF52 to the cloud via an nrf91 kit. The nRF52 is connected to the 91 kit via serialization. Then, the data is visualized on a website.

    Could you please open a new devzone question regarding your second question?

Reply Children
Related