My raspberry pi camera 1.3 is connected to a Rpi 3B+ and I have a script that has the camera take a picture every 5 minutes and save it to a network location. Once in a while, the camera will crash which will be brought back to life by my script. After a couple crashes though, the script doesn't seem to be able to bring the camera back online (but the script doesn't throw an exception for some reason).

I close the script, kill all relevant processes then run the script again but the camera stays dead. I thought maybe the GPU memory was the issue but it is set at 256MB and apparently that should be more than enough.

The only way to fix this seems to be to reboot the pi but obviously that is not ideal.

The script I am running is here:

from picamera import PiCamera
from time import sleep
from datetime import datetime
import am2320

def main():
    flag = 0
    camera = PiCamera()
    camera.resolution = (2592, 1944)
    while 1:
        dateString = datetime.strftime(datetime.now(), '%Y%m%d')
        timeString = datetime.strftime(datetime.now(), '%H%M')
        flag = getPicture(camera, dateString, timeString)
        while flag == 1:
            camera = PiCamera()
            camera.resolution = (2592, 1944)
            flag = getPicture(camera, dateString, timeString)
        for x in range(1, 5): #90*20 = 1800seconds

def getPicture(camera, ds, ts):
        camera.capture('PATH' % (ds, ts))
        return 0
        print("camera crashed... restarting")
        return 1

Please help!

PS. another thing is when this happens and I reboot the pi, the pi boots into a camera preview and refuses VNC connection, which means I have to pull the power on the pi to get it to restart

  • Hi @dsdanielko, and welcome to SE. Can you do a dmesg when this happens, and post any relevant output with the approximate same timestamp? (This sound like a firmware issue with the camera.) – not2qubit Oct 14 '18 at 12:09
  • It happened again yesterday but I only noticed today (last image was recorded 15/10/2018 16:30 BST). This time I didn't get a single "camera crashed... restarting" but the camera stopped recording anyways for some reason. Here is the dmesg: pastebin.com/ZpHB4W1P – dsdanielko Oct 16 '18 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.