Raspberry Pi camera goes in/out of being enabled

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
camichaels
 
Posts: 17
Joined: Sat Sep 24, 2022 10:25 pm

Raspberry Pi camera goes in/out of being enabled

Post by camichaels »

Hi. I am almost a complete beginner, so apologies. (Second post ever).

Trying to build the instant camera project (https://learn.adafruit.com/instant-came ... al-printer) with Raspberry Pi 3 Model B, Raspberry Pi Camera Board v2 and Adafruit USB thermal printer (zj-58). I seem to have it mostly working, except it looks like the system cannot connect (be enabled) to the camera consistently. The bash script provided in the project checks to see if user presses a button (connected to GPIO 6), and when they do... a pic is taken from camera and sent to the printer.

Here’s an excerpt of the script that I think is relevant.

while :
do
# Check for shutter button
if [ $(gpio -g read 6) -eq 0 ]; then
raspistill -n -t 200 -w 512 -h 384 -o - | lp

sleep 1

# Wait for user to release button before resuming
while [ $(gpio -g read $SHUTTER) -eq 0 ]; do continue; done
fi
done

When I run the script, the first time I press the button... pic prints. But the next button press, it doesn’t... and I see this in the terminal output:

mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
mmal: camera component couldn't be enabled
mmal: main: Failed to create camera component
mmal: Failed to run camera app. Please check for firmware updates


I’ll wait a moment, press button again… and get same message.
I’ll press again... and then it works.
After that it’s a bit random (i.e., some times it'll print ok for a few presses, but invariably I’ll get the error message that forces me to press button a few times again before it prints).
Ideally, I'd like a print every time I press the button.


In reading other posts, it seems most people who get this camera error… get it all the time, so it’s more about getting their camera connected to begin with. But for me, it’s connected, it’s not connected, it’s connected, and so on.


I don’t touch the camera cable between button presses, so I don’t think the physical connection is bad. And I’ve successfully run

raspistill -v -o test.jpg

from Terminal... and it works 100% of the time (i.e., I’ll just keep submitting this command — rather quickly —, trying to see if camera disconnects like it does when pressing the button… but that’s never the case).


And I've checked the GPIO value for the button press... and it consistently changes as I press/release the button.


Is there something inherently flawed in the script above?

Is the "wait for user to release" line somehow tripping up the camera? Like I press/release/press the button too quickly? (But I’ve also done it where I press/hold/wait 10 sec/press … and get the same connection error appearing).

Any thoughts would be appreciated!

Thanks!

User avatar
adafruit_support_mike
 
Posts: 67391
Joined: Thu Feb 11, 2010 2:51 pm

Re: Raspberry Pi camera goes in/out of being enabled

Post by adafruit_support_mike »

You may have an intermittent connection between the RasPi and the camera cable, or between the camera PCB and the CCD module.

Double-check the RasPi's cable connector to make sure the flex cable is fully seated and the cable lock is completely closed. Also check the tab that connects the camera's CCD module to the PCB. That connection uses a fine-pitch mezzanine connector that can come partially loose, so make sure it's pressed all the way down.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”