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.

Related