esp32-cam, send images to webserver continuously

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
anhay20171
Posts: 7
Joined: Wed Jul 06, 2022 5:41 am

esp32-cam, send images to webserver continuously

Post by anhay20171 » Thu Jul 07, 2022 2:36 pm

Hello!
I am currently writing code to make my esp32-cam send images to web continuously but I encounter this error:
W (54) boot.esp32: PRO CPU has been reset by WDT.
W (54) boot.esp32: WDT reset info: PRO CPU PC=0x40083cc3
W (56) boot.esp32: WDT reset info: APP CPU PC=0x4009089d
The error keeps appearing, I've been fixing it for days but couldn't find out a solution. I can show you all my code if it is necessary, but for brevity, i have figured out this is from the while loop, for example, if my boot.py looks like this:

import machine
from machine import Pin
import camera
import uos
import shutil

uos.mount(machine.SDCard(), "/sd") #mount the SD card
camera.init(0, format=camera.JPEG)
camera.quality(10)
camera.framesize(9)
file = open("sd/"+"a"+".jpg", "wb")
file.write(camera.capture())
file.close()
shutil.copy("sd/a.jpg","static/a.jpg")

#you can find shutil.py here:https://github.com/micropython/micropyt ... /shutil.py. But actually I have add a little function called "copy" to my shutil.py that I would show you later. This function copies file from a folder to another folder
#the reason why I need to store image in sd folder/SD card then copy it static folder is that I want my web take images from static folder. If I directly store it to static folder without store it to the sd folder first, the error would appear!


The above code would work without any errors, but if I want to continuously capture picture so that I put my take-a-picture-code-lines in a while loop, the error would appear, just like this:

import machine
from machine import Pin
import camera
import uos
import shutil

uos.mount(machine.SDCard(), "/sd") #mount the SD card
camera.init(0, format=camera.JPEG)
camera.quality(10)
camera.framesize(9)
while True:
file = open("sd/"+"a"+".jpg", "wb")
file.write(camera.capture())
file.close()
shutil.copy("sd/a.jpg","static/a.jpg")


Here's my shutil.py if you need:

import os

def rmtree(top):
for path, dirs, files in os.walk(top, False):
for f in files:
os.unlink(path + "/" + f)
os.rmdir(path)


def copyfileobj(src, dest, length=512):
if hasattr(src, "readinto"):
buf = bytearray(length)
while True:
sz = src.readinto(buf)
if not sz:
break
if sz == length:
dest.write(buf)
else:
b = memoryview(buf)[:sz]
dest.write(b)
else:
while True:
buf = src.read(length)
if not buf:
break
dest.write(buf)
def copy(src, dest):
with open(src, 'rb') as src_file:
with open(dest, 'wb') as dest_file:
copyfileobj(src_file, dest_file)

I would absolutely appreciate if someone could help me, it's a bit frustrating when working for days but couldn't find a solution. Thanks in advance!

tepalia02
Posts: 99
Joined: Mon Mar 21, 2022 5:13 am

Re: esp32-cam, send images to webserver continuously

Post by tepalia02 » Fri Jul 08, 2022 7:17 am

Looks like a similar problem had been discussed here: https://github.com/espressif/esp-idf/issues/2976
If you do not get any response worthwhile in this forum, I think you can raise your issue in github.

anhay20171
Posts: 7
Joined: Wed Jul 06, 2022 5:41 am

Re: esp32-cam, send images to webserver continuously

Post by anhay20171 » Fri Jul 08, 2022 8:13 am

tepalia02 wrote:
Fri Jul 08, 2022 7:17 am
Looks like a similar problem had been discussed here: https://github.com/espressif/esp-idf/issues/2976
If you do not get any response worthwhile in this forum, I think you can raise your issue in github.
Thank for the reply, I will see it now!

Post Reply