Thread: Sleep stops working after 15 minutes without wifi

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2021
    Posts
    8

    Question Sleep stops working after 15 minutes without wifi

    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.
    Last edited by GhostLoveScore; 12-27-2021 at 03:36 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C stops working ad 2nd scanf
    By Alcatraz in forum C Programming
    Replies: 4
    Last Post: 09-05-2017, 09:26 PM
  2. Program stops working when it gets to function
    By Joshino520 in forum C Programming
    Replies: 2
    Last Post: 01-19-2017, 09:00 AM
  3. Program suddenly stops working.
    By KittenAqua in forum C Programming
    Replies: 5
    Last Post: 10-18-2011, 05:45 AM
  4. compiler stops working
    By akkiphadnis in forum C Programming
    Replies: 2
    Last Post: 04-04-2011, 03:42 AM
  5. Program stops working as soon as I input value?..
    By darkmagic in forum C++ Programming
    Replies: 1
    Last Post: 03-08-2011, 02:18 AM

Tags for this Thread