-1

This is the error I get : picamera.exc.PiCameraMMALError: Failed to enable connection: Out of resources

import numpy as np
import os
from picamera import PiCamera
from time import sleep
from gpiozero import LED

l = LED(21)

camera = PiCamera()
camera.rotation = 180
filename = "frame.png"

while 1:
    try:
        camera.capture(filename)
        f = Image.open(filename)
        is_light = np.mean(np.asarray(f)) > 120

        if is_light:
            print("off")
            l.off()

        else:
            print("on")
            l.on()

        os.remove(filename)

    except Exception as e:
        camera.close()
        print(e)
        break


    sleep(2)

quit()

Now if run the above code in Thonny or mu or even with putty it works without errors but does not work if in /etc/profile

What do I do to either solve the error or atleast how to run the program on startup

1 Answer 1

1

I'm not sure what error your are having, but check out this page for information about running programs on the rasrpberry pi on startup.

https://learn.sparkfun.com/tutorials/how-to-run-a-raspberry-pi-program-on-startup#

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.