measurement of RSSI or transit time of a message via BLE with the Nordic 52840 and another slave board.

I have this problem, with a Nordic nRF52840 board I have to transmit a byte of known length, which I have to select a priori, and transmit it to a second slave evaluation board and then measure the RSSI value and the time it takes for the data packet to arrive depending on where the board is located, thus also going back to the distance value at which the two boards are located.
I would then also like to do the same thing with my android smartphone used as a slave.

I have tried to follow the examples I can find of nRF connect for desktop a bit, and in particular the codes available in visual studio code, but the standard codes there do not seem to answer my question.
Could you perhaps help me by explaining where to find an example code to modify to achieve this, and how to program the second board via the nRF52840?

thanks in advance!

Parents
  • Hi, 

    Using signal strength (RSSI) for estimating distance is not a reliable way for getting precise distance measurements. Since there are so many factors such as reflections and physical blocking affect the signal strength of the signal, hence the calculation of distance. I would suggest you consider this sample Bluetooth: nRF Distance Measurement with Bluetooth LE discovery which would also report RSSI value. Also, take a look at this post

    Regards,
    Amanda H.

  • Thank you Amanda for your reply.

    I have managed to get the two Nordic boards talking.
    Now what I would like to be able to do is to save the various RSSI, IFFT and RTT values in a file, so that I can then graph the time trend of these values.
    Can you please suggest a method for doing this?

    If there is a possibility, it would also be useful to save this file inside the nRF52840, so that I don't have to have it connected to the PC during measurements. And then later transfer those data saved in the non-volatile memory to the PC.

    Thank you again for your support!

  • Hi Amanda,

    I tried to upload the example you described and which I found within the GitHub repository (github.com/.../radio_test.c ), as within the examples provided by NRF Connect in VS code, there is no radio_test example.
    Downloading it and doing "open an existing application" in VS Code gives the following errors during compilation:

    1) "No SOURCES given to Zephyr library: lib__libc__common".
    2) "implicit declaration of function 'NRFX_MHZ_TO_HZ' [-Wimplicit-function-declaration]"

    in the default code found on the net, without making any changes.
    How can I proceed to resolve these errors?
    The library mentioned in the error is also present in other applications that run without errors.
    It should also not be a folder location error.

    and also if I try to add the prj.conf file configuration in the building these errors pop up:

    1) sys/printk.h: No such file or directory

     2) #include errors detected based on information provided by the configurationProvider setting. Squiggles are disabled for this translation unit (C:\Users\leonardo\Downloads\sdk-nrf-master\sdk-nrf-master\samples\peripheral\radio_test\src\radio_cmd.c).

     3) cannot open source file "init.h"

     4) init.h: No such file or directory

     5) cannot open source file "shell/shell.h"

  • Hi, 

    Which NCS version are you using?

    The radio_test sample can be found under samples/peripheral/radio_test in the nRF Connect SDK folder structure.

    I would suggest you update the SDK via the Toolchain Manager and then load the radio_test sample from the NCS instead of downloading it from the web. 

    -Amanda H.

  • OK, I solved the update issue, now the building of the "radio_test" application seems to work.

    I remind you that I have 2 boards, the nRF52840 board and the BC840E evaluation board.
    I loaded the radio test programme into the nRF52840 board connected via USB to the PC, and using the "flash" in VS Code.
    To this first board the BC840E board is connected via a 10-wire connection (for the power supply the BC840E is not connected via USB to the pc, but to an external battery), and according to what you told me above, by flashing the programme to the nRF52840 connected via 10 wires to the BC840E, the same programme should also be loaded inside this second board.


    Then through the serial terminal I give the commands you wrote me above ("start_channel" 40 and "start_tx_modulated_carrier"), always with both boards connected as I described, but opening the serial terminal I see these writings printed:
    "bfdegeffcgfedd e!e "f#d$f%f&e'e(f)f*f+c,e-f.g/f0d1g2g3f4f5c6f7g8f9g:c;d<e=g>g?c@eAfBfCgDdEfFeGfHfIdJeKfLeMgNdOfPddffeedee d
    f
    f
    ceffgadfgfddedbgfe e!b "e#f$f%f&e'f(f)e*g+d,g-e.f/g0c1f2f3g4f5e6g7g8e9e:a;g<d=e>f?b@eAfBgCgDdEgFeGfHfIcJfKfLeMhNdOfPfehfeedcd e
    f"......

    The boud rate is correct and I have also tried flashing the board via the NRF Programmer, loading the file 'zephyr.hex' (always keeping the same configuration), instead by VS Code, but it produces the same result.

    That seems to be the correct way you described to me to programme the second BC840E board.

  • Leonardo Balocchi said:
    The boud rate is correct

    What the baud rate do you use?

    Could you try to connect with Putty or use another USB cable?

    -Amanda H.

  • The baud rate is 115200 on the serial settings.

    When I connect only the nRF52840 board to the PC and load the zephyr.hex programme (i.e. without the 10 connection wires to the BC840E) the serial terminal seems to work.

    Instead it prints in the serial terminal continuously the same values I showed you above if I program the nRF52840 with the 10 connection wires attached and then the BC840E as well.

    I tried changing USBs and Putty and the same thing happens.
    Are we sure that's the right way to programme the BC840E? I'm pretty sure the problem lies in flashing the programme on nRF52840 when the other board (BC840 E) is also attached via 10 wires, because only in this case does the programme give problems.

Reply
  • The baud rate is 115200 on the serial settings.

    When I connect only the nRF52840 board to the PC and load the zephyr.hex programme (i.e. without the 10 connection wires to the BC840E) the serial terminal seems to work.

    Instead it prints in the serial terminal continuously the same values I showed you above if I program the nRF52840 with the 10 connection wires attached and then the BC840E as well.

    I tried changing USBs and Putty and the same thing happens.
    Are we sure that's the right way to programme the BC840E? I'm pretty sure the problem lies in flashing the programme on nRF52840 when the other board (BC840 E) is also attached via 10 wires, because only in this case does the programme give problems.

Children
  • Hi, 

    Leonardo Balocchi said:
    Are we sure that's the right way to programme the BC840E?

    From the doc, it seems like that. You also could use the J-Link debug probe to replace nRF52840DK for programming. Do you also try other BC840 E boards? If you also have programming issues with the J-Link debug probe, you should contact the provider since BC840 E is not produced by Nordic. 

    -Amanda H.

  • Hi Amanda,

    I was able to solve the problem and now I can send the carrier from one board and view it via RSSI viewer on the other (with the "radio_test" application).
    I wanted to ask you another thing, now I would need to set up my experimental setup, as I told you, so that I select a single channel (out of the 40 available) and continuously send bit sequences interspersed between the two boards, so that the RSSI is measured.
    Is there a way to set the single channel and save all the RSSI values that are read so that I can then plot them in a graph?

    To go back to the previous problem, that is, the RSSI value measurement with the "nrf_dm" application, where I was seeing inconsistent RSSI values.

    Thanks in advance,

    Leonardo

  • Hi,

    Leonardo Balocchi said:
    Is there a way to set the single channel and save all the RSSI values that are read so that I can then plot them in a graph?

    There is no such example, but you can take a look at this post or the hci_pwr_ctrl sample to get RSSI values. 

    Leonardo Balocchi said:
    To go back to the previous problem, that is, the RSSI value measurement with the "nrf_dm" application, where I was seeing inconsistent RSSI values.

    Could you elaborate more on what you mean by the "inconsistent RSSI values"?

    -Amanda H.

  • Hi Amanda, unfortunately the examples you gave me were not very helpful, they don't explain how to extract RSSI values over time.

    Concerning the second request, the problem is this, when I use the RSSI viewer on the nRF52840 DK, and the radio_test loaded on the BC840 then I read correctly the RSSI value from the RSSI viewer (the two boards are at a distance of 60 cm, so the path loss at 2.4 GHz is about 36 dB, then on the BC I mounted an antenna that has gain 5 dBi, and transmitting 0 dBm with the BC I see that the RSSI is about -34 dBm, as I expect).


    Leaving the same setup, with the nrf_dm example, it prints me an absolutely incorrect RSSI value, we are around -2 dBm (perhaps because in the latter case I see the sum of several channels?).

    So I cannot use the nrf_dm example to extract the RSSi values I need, but I should do it from the RSSI viewer, because from there I read the value I expect according to RSSI theory.

    So my problems are:
    1) how to save the RSSI values from the RSSI viewer desktop application (or if there is another way it may be ok, as long as the RSSI is always correct)
    2) how to keep the instructions sent from the terminal saved in the BC840's memory, because otherwise when I disconnect and then reconnect it, what happens is that the transmission instructions are lost (so I think they are saved in volatile memory)

    Is there a way perhaps to insert terminal commands directly within the main.c function in VS Code?

    Thanks,

    Leonardo

  • Hi,

    Leonardo Balocchi said:
    1) how to save the RSSI values from the RSSI viewer desktop application (or if there is another way it may be ok, as long as the RSSI is always correct)

    It cannot save the RSSI values from the RSSI viewer app which doesn't provide this feature. 

    Leonardo Balocchi said:
    Is there a way perhaps to insert terminal commands directly within the main.c function in VS Code?

    You could modify the sample and assign the value as you want. 

    Regards,
    Amanda H.

Related