Hello everyone, my first post here
I have a strange problem. I have a c program on raspberry pi which sends temperature data every 32 seconds to LoRa device and I receive it on other raspberry pi.
The code works fine when raspberry pi is connected to wifi, but stops after 15 minutes without wifi, and that always happens. My code is a mess right now, but I will put here the part where the program stops working. It's the part where I wait for 32 seconds to ask for another reading from thermometer. It just stops in the middle of "do while" loop
Code:
do{
time(&stop);
tdif=difftime(stop, start);
log=fopen("./log.txt","a");
fprintf(log," %.1f", tdif);
fclose(log);
sleep(1);
}
while(tdif<32);
This code just calculates a time difference between "start" time, which I took in the beginning, and "stop" time until that difference exceedes 32 seconds.
I've tried this with "delay()" as well, but I get the same thing. I tried with clock() too, and you guessed it, same thing.
I'm writing to a file because I don't have ssh when I shut down wifi for that one raspberry pi. Last time it stopped, for example on 5th second in the loop.