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

How to write and save the data in .txt file on my computer?

Hi guys,

Based on the examples that I found in Zephyr samples documentation, I created the program where I am able to measure the voltage and temperature, and then send the data via BLE to my mobile phone. Now, I am interested to know how can I save the values (for example the voltage values) in .txt file on my computer? I tried to use the regular code in C as I did so many times before, but I am still not able to flash my board and run the code. There are multiple errors such as:

1) note: 'fopen' is defined in header '<stdio.h>'; did you forget to '#include <stdio.h>'? - even if I have already included this library

2) warning: assignment to 'FILE *' {aka 'int *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
   64 |  voltage_value = fopen("voltage_values.txt", "a+");

3) warning: passing argument 2 of 'fprintf' makes pointer from integer without a cast [-Wint-conversion]
84 | fprintf(voltage_value, batt_mV);

Is there maybe the different code for nRF52832 board and Zephyr? Can you maybe give me some advice or even send me an example which will be definitely the better option. I am looking forward to hear your answer.

Best regards,

Adnan.

Parents
  • I created the program where I am able to measure the voltage and temperature, and then send the data via BLE to my mobile phone. Now, I am interested to know how can I save the values (for example the voltage values) in .txt file on my computer?

     So how is the nRF connected to your computer? Or do you intend to transfer the file from the mobile phone to the computer? I am not sure I understand your setup.

    BR,

    Edvin

  • The board is connected via USB to my computer and I just want to write some values (in this case the voltage) in .txt file and save that file to my computer, for example in the same folder where my example is. For the second example, I will use the external power source (in my case the environment emulator) and try to do the same thing. This is the simple example in regular C, but as I mentioned I tried using that code but unsuccessfully. Do you understand better now, what I need. 

    Thanks in advance for any type of help.

    Best regards,

    Adnan.

Reply
  • The board is connected via USB to my computer and I just want to write some values (in this case the voltage) in .txt file and save that file to my computer, for example in the same folder where my example is. For the second example, I will use the external power source (in my case the environment emulator) and try to do the same thing. This is the simple example in regular C, but as I mentioned I tried using that code but unsuccessfully. Do you understand better now, what I need. 

    Thanks in advance for any type of help.

    Best regards,

    Adnan.

Children
Related