logo elektroda
logo elektroda
X
logo elektroda

Wicket bell with ESP32 cam - camera stops taking pictures after 30 minutes of inactivity

glogus 1623 23
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 19464962
    glogus
    Level 9  
    Hello
    I'm trying to make a doorbell with an ESP 32 cam. The problem is that after about 30 minutes of inactivity the cam itself stops taking pictures (dark screen), the rest of the ESP32 chip works, sends a notification, opens the striker, only the screen is dark. After a reset it is OK again.
    I will mention that I am a beginner in programming and will be very grateful for any help.
    I have tried uploading various examples from the web, but always the same.
    Regards and please help
  • ADVERTISEMENT
  • #2 19465032
    vieleicht
    Level 37  
    Here they describe similar problems and the conclusion is that the fault lies with the camera. I suggest reducing the frame_rate or swapping the camera/using a different module as a trial.
    https://github.com/esphome/issues/issues/551
  • #3 19465295
    glogus
    Level 9  
    I already have 3 of these modules from different sources and on all of them I have the same thing, then the module is probably out. I have also tried different power sources. I have noticed that when I check it every few minutes it can work fine.
    I will read the link you gave me. Thanks and looking forward to further suggestions
  • #4 19470634
    khoam
    Level 42  
    glogus wrote:
    I have also tried different power sources.
    .
    Are you powering from 5V or 3.3V?
  • #5 19470662
    glogus
    Level 9  
    I supply power from 5V, from various power supplies, even a laboratory one with 5V and 3A output.
    I soldered 100uF and 100nF capacitors onto the 5V and Gnd pins for filtering purposes.
    Recently, after reading the post provided where they suspect overheating of the camera, I glued a heatsink to the camera and nothing helps either.
  • #6 19471371
    khoam
    Level 42  
    Are you using an external antenna or the one on the pcb?
  • #7 19471541
    glogus
    Level 9  
    I'm currently testing on an antenna on a pcb, but the router hangs over the desk on which I'm testing the device. I'm wondering if this problem can be solved by restarting the camera every few minutes (after all, with the intercom it is used sporadically during the day), I just have a problem how to do it, I'm a beginner in programming and these ESP sleeps I don't quite understand.
    Greetings
  • ADVERTISEMENT
  • #8 19471768
    khoam
    Level 42  
    There is not much philosophy in sleep itself. You just have to decide when, i.e. when the conditions are met, the ESP should enter sleep and how the wake-up (de facto restart of the system) should take place. In the latter case, there are several options to choose from, but I think that in this case, waking up by pressing a button and forcing a low state on the selected ESP pin will be the most appropriate (the chip will boot in less than 100ms).
    What specific code are you currently using?
  • #9 19471799
    glogus
    Level 9  
    I am currently testing this example (zip)
    I have also tried others.
    I don't know if waking up via a button will work, or if the connection time to the server will be too long. ( I use my own BLYNK server set up on a malinka)
    Currently there is a constant connection and even when the camera stops working there is a notification to the phone and an open button from the phone and local ( you can't take a picture)
    In this arrangement the ringing trigger is proximity, but this can be changed to a button
  • #10 19472703
    khoam
    Level 42  
    Try maybe the following modification: at the very beginning of the function setup () add a line:
    Code: C / C++
    Log in, to see the code
    Additionally, you should then add the inclusion of two additional header files at the beginning of the program (just after #include "esp_camera.h" ):
    Code: C / C++
    Log in, to see the code
    .
    Compile, load and let us know.
  • ADVERTISEMENT
  • #11 19474739
    glogus
    Level 9  
    Hello
    I've pasted the one as you wrote (hopefully right (attachment)), but unfortunately it didn't help.
    What surprises me is that the LED flashes and the screen is black.
    If it's not a problem for you, please help me make it so that the whole thing resets say every 5 minutes when not in use, as the camera itself probably can't.
    With a manual reset it takes about 20 sec to make a call, so triggering it with the ring button is a bit pointless.
    I am very grateful to you for your help
  • #12 19474763
    khoam
    Level 42  
    I suggest you test the code from this page first: Link .
    Without blynk , just access over WiFi to the camera. There is a detailed description of the configuration at this link.

    Code:
    Code: C / C++
    Log in, to see the code
    .
    glogus wrote:
    With a manual reset, it takes about 20 sec to establish a connection
    .
    This is very, very long.

    glogus wrote:
    the whole thing resets say every 5 minutes when not in use
    .
    This is really not a good idea and I would probably apply it last.
  • #13 19476118
    glogus
    Level 9  
    Hello
    I have done everything as described in the link provided, but it is too complicated and problematic to handle for the household members.
    In addition, there are delays in the notifications.
    In my solution, the notifications come immediately (own server) and the operation consists of receiving the notification, looking at the photo and possibly touching the wicket opening icon. Sharing with householders is just scanning the QR code with their phones.
    So I think probably the best solution though would be a cyclic reset of the module. ( I have no other idea)
    The problem is that I don't really know how to do this.
    The worst part is that I got into this problem without a thorough timing test and crashed the old intercom. (I have provisionally connected a wireless bell, but the gate has to go to open manually).

    Added at 15 [minutes]:

    Sorry to poison you so much (you are the only person who helps such a grandparent- thank you very much).
    I've now noticed that when I reset the camcorder with the button on the board, I get a connection almost instantly and everything works (I was turning off the power supply before)
  • #14 19476462
    khoam
    Level 42  
    glogus wrote:
    I have done everything as described in the link provided, but it is too complicated and problematic for the householder to handle.
    In addition, there are delays in notifications.
    .
    The purpose of this 'exercise' was to verify the correct operation of the camera. Did the problems you described in the first post occur?

    glogus wrote:
    So I think that probably the best solution, however, would be a cyclic module reset. ( I have no other idea)
    .
    Since you insist :) Here is the code for the configAutoRestart() function - this function should be called as last in the setup() function. The argument to configAutoRestart() is the number of seconds after which the ESP should auto-restart.
    Code: C / C++
    Log in, to see the code
    .
    Additionally, the inclusion of a header file should be added:
    Code: C / C++
    Log in, to see the code
    .
    I have checked, it works for me :) .
  • ADVERTISEMENT
  • #15 19477333
    glogus
    Level 9  
    Hello
    Thank you for taking the time to do this.
    In this as you put it "exercise" the camcorder worked for a few hours and then hung up. Unplugging the power and it was OK again.

    I pasted what you sent me and got the error.
    (The library too, of course).

    I pasted it here at the end of the loop void setup()
    startCameraServer();

    Serial.print("Camera Ready! Use 'http://'");
    Serial.print(WiFi.localIP());
    local_IP = WiFi.localIP().toString();
    Serial.println("' to connect");
    Blynk.begin(auth, ssid, password, IPAddress(192,168,0,113), 8080);

    void configAutoRestart(uint64_t secs) {
    const esp_timer_create_args_t __args = {
    .callback = [] (void*) {
    esp_restart();
    },
    .arg = nullptr,
    .dispatch_method = ESP_TIMER_TASK,
    .name = "AutoRestart",
    };
    static esp_timer_handle_t __handle;
    esp_timer_create(&__args, &__handle);
    esp_timer_start_periodic(__handle, secs * 1000000);
    }

    }

    I received an error:

    a function-definition is not allowed here before '{' token

    I do not know where I am making the error.
    If you can write me this for a reboot every 10 minutes

    I WILL BE VERY THANKFUL and sorry to exploit you like this
  • #16 19477343
    khoam
    Level 42  
    The call to the configAutoRestart() function was to be inserted at the end of the setup() function, not its entire definition. You cannot nest a function definition within another function.
    Code: C / C++
    Log in, to see the code
    .
  • #17 19479157
    glogus
    Level 9  
    Hello
    Apologies for such an error, but I've been unwell lately (return of illness).
    Now it works except that after those 10 minutes the whole ESP hangs, just a reset from the board
  • #18 19479317
    khoam
    Level 42  
    glogus wrote:
    Now it works except that after those 10 minutes the whole ESP hangs,
    .
    And what do you mean "hangs"? Does it not perform a restart? Perhaps the reason is that the network connection is not disconnected. Below is my modified configAutoRestart() function, where I have added stopping the WiFi stack from restarting.
    Code: C / C++
    Log in, to see the code
    .
    This time additionally add the inclusion of two header files:
    Code: C / C++
    Log in, to see the code
    .
  • #19 19479682
    glogus
    Level 9  
    I did as you wrote and after 10 minutes no wifi connection, pressing the button on the esp resumes the connection
  • #20 19479697
    khoam
    Level 42  
    Please share the actual code that you are testing and with which you are having the above problem.
  • #21 19480349
    glogus
    Level 9  
    Attached is the code I am testing with your improvements.
    I noticed that when I check the ringtone every few minutes it works fine, when left idle there is now no wifi connection, previously the ringtone worked, only the photo was missing (black screen, strangely the lamp flashed when the photo was triggered).
    The ringtone works with BLYNK on my server, but other projects I have on mim work all the time (weather station, letter notification and others) so it's probably not the server's fault.
  • #22 19480719
    glogus
    Level 9  
    Hello
    I don't know if it's relevant, but today I noticed that while the camera is on standby, it keeps sending images.
    I typed the address of the camcorder into my phone and I am getting the image
  • #23 19480725
    khoam
    Level 42  
    glogus wrote:
    I don't know if it's relevant, but today I noticed that while the camera is on standby it is constantly streaming images.
    .
    This is very significant. It means that the camera in the ESP is working correctly, and the problem lies with the server that receives the data from the ESP. Probably the ESP also restarts correctly, but for some reason the server stops receiving data after such a restart.

    You can't use as much this long delay() in loop() because of Blynk.run() , which also executes in loop(), that is in the same thread. Also in the takePhoto() function are unnecessary delay() - this function is also called from loop() and delays the execution of Blynk.run().
    Code: C / C++
    Log in, to see the code
    .

    Added after 2 [hours] 3 [minutes]: .

    I modified the program you posted in post #21 so that Blynk.run() is called every 10 ms, regardless of what happens in loop() - so you can leave all those delay() out. This 10 ms interval can be changed in the runBlynk() function, which is an additional function in the code, to a larger one so as not to overload the ESP. Test in your network environment.
    I disabled autorestart (I commented out the line with the configAutoRestart() function call. I don't think it is needed.
    Code: C / C++
    Log in, to see the code
    .
    In general, the Blynk library is not written for a multi-threaded environment, so I'm not entirely sure what the side effects will be :)
  • #24 19482199
    glogus
    Level 9  
    I uploaded the code yesterday and it worked all afternoon, I left it overnight and in the morning it was out of picture.
    But strangely enough I reset and it worked all day.
    I'm wondering if by chance it's because I was in range of the camera all day and there was movement (there were changes in the recorded image), and at night there was no movement.
    And I still have a question:
    how to check which software is currently uploaded, because I'm already dumbfounded (I'm testing on two ESPs)

    Added after 38 [minutes]:

    It's already bad, no photo

Topic summary

The discussion revolves around a user experiencing issues with an ESP32-CAM based doorbell project, where the camera stops taking pictures after approximately 30 minutes of inactivity, resulting in a dark screen. Despite the ESP32 chip functioning normally (sending notifications and opening the door), the camera requires a reset to operate again. Various troubleshooting steps were suggested, including reducing the frame rate, using different power sources, and implementing a cyclic reset function to restart the ESP32 periodically. The user also explored the possibility of overheating and power supply issues, while considering the use of an external antenna. Ultimately, the user sought assistance in programming a solution to automatically restart the camera to maintain functionality.
Summary generated by the language model.
ADVERTISEMENT